【问题标题】:How to predict result of sigmoid function in Machine Learning如何在机器学习中预测 sigmoid 函数的结果
【发布时间】:2017-06-29 04:42:10
【问题描述】:

我正在学习 Coursera 机器学习课程,我对 sigmoid 函数有点困惑。

我实现了如下的 sigmoid 函数:

g = 1 ./ (1+e.^(-z));

并写了一个函数来预测结果,它看起来像

p = sigmoid(X*theta) >= 0.5

问题说

"For a student with an Exam 1 score
of 45 and an Exam 2 score of 85, you should expect to see an admission
probability of 0.776" 

但我不确定如何将这两个 x 值插入到我创建的函数中。

如果 theta 为 0.218,那么 45 和 85 的考试成绩如何得出 0.776 的概率?谁能解释一下?

谢谢

【问题讨论】:

    标签: machine-learning octave


    【解决方案1】:

    概率由sigmoid函数给出,

     p = sigmoid(X*theta)
     # Since there are two inputs, the model will have 2 weights and a bias.
     p = sigmoid(0.45*w1+0.85*w2+b)
     # The actual output is given by
     y = 0.776
     # Loss function
     loss = (p-y)^2
     # Find the weights by minimizing the loss function using gradient descent.
    

    【讨论】:

    • 谢谢,但我不太确定。 Sigmoid 函数被定义为只有一个参数,我不确定 w1 和 w1 和 b 来自哪里。
    • w1、w2 和 b 是您在公式中定义为 theta 的值,X 是 [0.45, 0.85]。 sigmoid 的输入只有一个数字。
    • 那么 w1、w2 和 b 是我的梯度下降得到的参数吗?
    • 是的,我运行上面的代码得到:sigmoid(-0.1806*0.45+0.9136*0.85+0.5473)
    • 谢谢!顺便说一句,只是一个额外的问题。当我们第一次测试我们的成本函数时,我看到分配首先使用零向量和非零向量对其进行测试。有什么区别,哪一种是正确的方式?
    猜你喜欢
    • 2019-06-16
    • 2021-11-26
    • 1970-01-01
    • 1970-01-01
    • 2011-10-04
    • 2018-08-23
    • 2017-06-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多