【问题标题】:When do you implement the Sigmoid function in a neural network?你什么时候在神经网络中实现 Sigmoid 函数?
【发布时间】: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


    【解决方案1】:

    不是专家,但它用于代替您输出 1 或 0 的条件。这是您的阈值函数。在这种情况下,您使用的是阶梯函数;你可以用你的 sigmoid 函数替换整个条件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-25
      • 2017-06-20
      • 1970-01-01
      • 2017-07-28
      • 2014-03-26
      • 2020-09-27
      • 2017-07-11
      • 2018-07-01
      相关资源
      最近更新 更多