逻辑函数定义为 sigmoid(x) = 1/(1+e^(-x))。如果得分由公式 4×1 + 5×2 – 9 = score 定义,那么以下哪个点恰好有50%的概率是蓝色或红色?(选择所有正确答案。)
答案:(1,1) – (2,4) – (5,-5), (-4,5)
有人能解释一下如何解这道题吗?
回答:
我在上同样的Udacity课程。你问错了问题,得到了错误的答案。应该是1/1(1+e^(-x))
正确的代码是
from math import e,pow#Equation: 4x1+5x2-9=score#weights are 4,5 and bias is -9, find the sigmoid(x) = 1/(1+e-x).features=[(1,1),(2,4),(5,-5),(-4,5)]def linear_func(features): for x in features: score= 4*x[0]+ 5*x[1]-9 y = 1 / (1 + pow(e,- score)) print("X",x,score,y) #call the functionlinear_func(features)
答案是1,1和-4,5
Udacity上的答案:那是正确的。从直觉上看,如果你查看逻辑函数的图表,当得分评估为零时,概率总是50%。