+ 2
I need help with my neural network code.
Hey everybody, I'm currently trying to make a Neural Network class as you can see in the code linked below. To test it, I tried to use the XOR problem, unfortunatly i'm not getting any results :-(. I'd like to know if anyone could help me figure out what's wrong with it, I'm struggling to find where I went wrong. Tbanks in advance :-) PS: I know I could've used numpy, tensorflow or many other libraries to do this but I wanted to try to do one myself, I'm not trying to get a super optimized Neural Network ^^ https://code.sololearn.com/cxoYWVvEsGZ7/?ref=app
12 Antworten
+ 7
I'll check it out in the evening. Maybe something wrong with the matrix operation functions?
What I would do is to try to quickly re-write it to numpy and see if it's a logical or rather an implementation problem.
+ 6
AOYAGI Hugo In the class definition they are __init__ialized as lists, not np.arrays. I'm just not sure how it will behave later on when you apply vectorized methods to them.
Not to worry though, I'll get my hands on it in a while and see what seems to be the problem.
+ 4
I think it is a problem with the value r. Print r inside the for loop, then print it outside. Both are random integers, not a value from training_data[1]. Sorry I can’t be more help, hopefully this helps you find the problem
+ 4
AOYAGI Hugo What I meant was to rewrite the functions to numpy methods and variables to numpy arrays. Only then can you be sure that all the operations are vectorized. I'm afraid there might be some scalar operation in mid-way and it alone spoils the whole effect...
+ 3
That is really cool. I am new to neural networks, but I’ll try to help if I can. There is no errors; what is the problem? It is giving consistent results.
+ 3
Kuba Siekierzyński man can you help?
+ 2
With the XOR problem, the neural network should only output a 1 when the inputs are 1(True) and 0(False)
Here it seems to give out the same output for every input :/
+ 2
Check out the official implementation of a 3-input NN here on Sololearn. It's done in numpy and has only the required functions implemented.
But...
all in numpy :)
https://www.sololearn.com/learn/738/?ref=app
+ 1
Thanks for the help anyway :)
+ 1
I just rewrote it with numpy as you suggested, however it seems to give out the same outputs. I'm guessing it's an issue with the formula in the back propagation but i can't quite see what. The formula i'm using is the one explained in the 3Blue1Brown videos.
https://code.sololearn.com/cz6UAAviJh1m/?ref=app
0
I'm not sure i understand what you mean by rewriting functions to numpy methods and variables to numpy arrays. Aren't all the variables used in operations are numpy arrays: biases, weights and inputs ?
0
سلام