【发布时间】:2020-08-30 10:01:48
【问题描述】:
我正在研究一些神经网络,因为它看起来很有趣。我将python代码翻译成java,它的工作方式和我想的一样。它每次都给我正确的值。虽然我想知道你在代码中哪里实现了Sigmoid函数。我在计算输出后实现了它,但即使没有 Sigmoid 函数,它的工作方式也是一样的。
我学习的网站:https://towardsdatascience.com/first-neural-network-for-beginners-explained-with-code-4cfd37e06eaf
This is my Perceptron function:
public void Perceptron(int input1,int input2,int output) {
double outputP = input1*weights[0]+input2*weights[1]+bias*weights[2];
outputP = Math.floor((1/(1+Math.exp(-outputP))));
if(outputP > 0 ) {
outputP = 1;
}else {
outputP = 0;
}
double error = output - outputP;
weights[0] += error * input1 * learningRate;
weights[1] += error * input2 * learningRate;
weights[2] += error * bias * learningRate;
System.out.println("Output:" + outputP);
}
另外,如果我不添加 Math.floor(),它只会给我很多小数。
【问题讨论】:
标签: java neural-network sigmoid