Machine Learning - The Sigmoid Function

Calculate Node Output.

Task
You are given the values for w1, w2, b, x1 and x2 and you must compute the output for the node. Use the sigmoid as the activation function.

Input Format
w1, w2, b, x1 and x2 on one line separated by spaces

Output Format
Float rounded to 4 decimal places

Sample Input
0 1 2 1 2

Sample Output
0.9820

img-component
 

Explanation
w1 = 0, w2 = 1, b = 2, x1 = 1, x2 = 2

=================================

import math
w1, w2, b, x1, x2 = [float(x) for x in input().split()]

f=-1*(w1*x1+w2*x2+b)

y=1/(1+math.e**f)

print(round(y,4))
posted @ 2024-02-22 23:21  白话  阅读(3)  评论(0编辑  收藏  举报