jorgenkg / python-neural-network

This is an efficient implementation of a fully connected neural network in NumPy. The network can be trained by a variety of learning algorithms: backpropagation, resilient backpropagation and scaled conjugate gradient learning. The network has been developed with PYPY in mind.
BSD 2-Clause "Simplified" License
297 stars 98 forks source link

Attempting tranpose on int returned from linear_function #7

Closed huntrar closed 8 years ago

huntrar commented 8 years ago

Traceback (most recent call last): File "/neuralnet.py", line 101, in backpropagation input_signals, derivatives = self.update( training_data, trace=True ) File "/neuralnet.py", line 436, in update derivatives.append( self.layers[i][1](signal, derivative = True).T ) AttributeError: 'int' object has no attribute 'T'

The issue in this case is linear_function, which returns 1 if derivative = True, and obviously this cannot be transposed.

huntrar commented 8 years ago

The simple fix here would be to check the return type for int before transposing, which I have done for my own purposes. Let me know if you would like me to add this fix to my current open PR.

jorgenkg commented 8 years ago

I quickly pushed an update to fix the issue. Thanks for the heads-up, @huntrar!