Implementing neural networks in Python