+ 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

24th Nov 2018, 5:28 PM
AOYAGI Hugo
AOYAGI Hugo - avatar
12 Respostas
+ 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.
26th Nov 2018, 12:06 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 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.
26th Nov 2018, 7:16 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 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
25th Nov 2018, 3:44 PM
Pete Cowling
Pete Cowling - avatar
+ 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...
26th Nov 2018, 6:57 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 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.
24th Nov 2018, 6:33 PM
Pete Cowling
Pete Cowling - avatar
+ 3
Kuba Siekierzyński man can you help?
26th Nov 2018, 8:22 AM
Sarvesh Yadav
Sarvesh Yadav - avatar
+ 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 :/
25th Nov 2018, 6:59 AM
AOYAGI Hugo
AOYAGI Hugo - avatar
+ 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
26th Nov 2018, 8:22 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 1
Thanks for the help anyway :)
25th Nov 2018, 4:06 PM
AOYAGI Hugo
AOYAGI Hugo - avatar
+ 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
26th Nov 2018, 6:52 PM
AOYAGI Hugo
AOYAGI Hugo - avatar
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 ?
26th Nov 2018, 7:06 PM
AOYAGI Hugo
AOYAGI Hugo - avatar
0
سلام
27th Nov 2018, 6:52 PM
ali mehranzade