+ 1
Sigmoid function
If there is 2nd test case which is 0 1 2 1 -2, for example, why my code does not work for it? w1,w2,b,x1,x2 = list(map(int, input().split())) import math output = w1*x1 + w2*x2 + b output = 1/(1 + math.exp(output*-1)) print(f"{output:.3f}")
11 ответов
+ 3
Zhenis Otarbay , why do you change the first line for the coefficients w1, w2, b, x1, x2 - it is given in the solution for a reason. Second thing is it is mentioned you should round the result to 4 decimal digits, not to format it. Look at your code corrected.
https://code.sololearn.com/cl8sjJcwc7IZ/?ref=app
+ 4
import math
w1, w2, b, x1, x2 = [float(x) for x in input().split()]
activation_function = -1*((w1*x1)+(w2*x2)+b)
y = 1 / (1 + math.e ** activation_function)
print(round(y,4))
+ 3
Thomas Monette why so many
+ 2
Zhenis Otarbay , I have already answered it.
+ 2
w1, w2, b, x1, x2 = [float(x) for x in input().split()]
from math import*
print(round(1/(1+exp(-(w1*x1+w2*x2+b))), 4))
+ 1
TheWh¡teCat 🇧🇬 could you tell what is the problem with this brother's code? https://www.sololearn.com/Discuss/2329570/?ref=app
+ 1
TheWh¡teCat 🇧🇬 thanks bro, now I think, understand it, the last thing I am stack is the forest of trees, could you approach it?
+ 1
Zhenis Otarbay, I can, but that's not the purpose. You should try it by yourself. If you have problem, then you can share your code in separate question, not here to mix many questions in one topic. There are many people here who can help you.
+ 1
w1, w2, b, x1, x2 = [float(x) for x in input().split()]
import math
y=(w1*x1)+(w2*x2)+b
z = math.exp(-y)
sig = 1 / (1 + z)
sig = round(sig,4)
print(sig)
+ 1
really simple:
import math
w1, w2, b, x1, x2 = [float(x) for x in input().split()]
x = (w1 * x1) + (w2*x2) + b
y = 1 / (1 + (math.exp(-x)))
print(round(y,4))
math.exp does ∑ function
+ 1
w1, w2, b, x1, x2 = [float(x) for x in input().split()]
from math import*
y = 1/(1+exp(-(w1*x1+w2*x2+b)))
print(round(y, 4))