0

[SOLVED] Something is wrong my simple neural network project

I need some help, with my code project, i write a simple neural network, with 1 layer, and something is wrong, i hope someone can help me in this problem https://code.sololearn.com/cW4394FlrBPQ/?ref=app

2nd Nov 2021, 12:39 PM
Domonkos Gyömörey
Domonkos Gyömörey - avatar
4 odpowiedzi
+ 3
I think you misunderstood what the activation function is. The activation function has nothing to do in the dataset, it belongs to the neuron and never change. In your case your activation function is this part: datas[i][2] = dstas[i][0]<0?-1:1; Which is an "step" function. Check this link https://es.m.wikipedia.org/wiki/Funci%C3%B3n_de_activaci%C3%B3n
3rd Nov 2021, 8:12 PM
Benjamin Alejandro Luna
Benjamin Alejandro Luna - avatar
+ 1
Hello. What are exactly the output values you expect with given inputs?
3rd Nov 2021, 6:46 PM
Benjamin Alejandro Luna
Benjamin Alejandro Luna - avatar
+ 1
Benjamin Alejandro Luna Thank you very much, I really misunderstood the functionality of the activating function, thanks to you I understood better a small part of neural networks, and as the saying goes we learn from our mistakes, thank you for your help!
3rd Nov 2021, 8:36 PM
Domonkos Gyömörey
Domonkos Gyömörey - avatar
0
Benjamin Alejandro Luna In this program is simple, in the method the array[i][2] item is the target value, this is the expect value it is auto generate If x < 0 the output is -1 else output is 1 Oh wait the problem is in the activation function? Which is return x value for y? So the expect value is not just -1 if x<0, otherwise if x<y expect value is -1 else 1?😅 //Activation function public static float actFunc(float x){ return x; } //Generate dataset function public static float[][] genDataSet(int num){ Random r = new Random(); float datas[][] = new float[num][3]; for(int i =0;i<num;i++){ datas[i][0] = (r.nextFloat()*2)-1; datas[i][1] = actFunc(datas[i][0]); datas[i][2] = datas[i][0]<0?-1:1; } return datas; }
3rd Nov 2021, 7:42 PM
Domonkos Gyömörey
Domonkos Gyömörey - avatar