Which of the following values for the weights and the bias
would result in the final probability of the point to be
0.88 of being blue(positive region, above the line)?A. w1=2, w2=6, bias=2B. w1=3, w2=5, bias=-2.2C. w1=5, w2=4, bias=-3weights=[(2,6),(3,5),(5,4)]bias=[2,-2.2,-3]score1 = weights[0][0] * 0.4 + weights[0][1] * 0.6 + bias[0]score2 = weights[1][0] * 0.4 + weights[1][1] * 0.6 + bias[1]score3 = weights[2][0] * 0.4 + weights[2][1] * 0.6 + bias[2]def find_weights_bias(): #result of the probability function given, 0.88 with sigmoid activation 1/(1+e-score)score is 2#Find w1, w2 and b, for score=w1*0.4+w2*0.6+b weights=[(2,6),(3,5),(5,4)] bias=[2,-2.2,-3] score1 = weights[0][0] * 0.4 + weights[0][1] * 0.6 + bias[0] score2 = weights[1][0] * 0.4 + weights[1][1] * 0.6 + bias[1] score3 = weights[2][0] * 0.4 + weights[2][1] * 0.6 + bias[2] print(score1,score2,score3) #condensed form score1, score2, score3 = (w1 * 0.4 + w2 * 0.6 + b for (w1, w2), b in zip(weights, bias)) print(score1,score2,score3) if score1 == 2.0: print ("First choice is correct!") if score2 == 2.0: print ("Second choice is correct!") elif score3 == 2.0: print ("Third choice is correct!") return score1,score2,score3 find_weights_bias()
Showing posts with label sigmoid. Show all posts
Showing posts with label sigmoid. Show all posts
Thursday, January 23, 2020
Find weights and bias in neural nets in python.
Tuesday, January 21, 2020
How to use sigmoid activation function in python in basic neural nets.
The
sigmoid function is defined as sigmoid(x) = 1/(1+e-x). If the score is defined
by 4x1 + 5x2 - 9 = score, then which of the following points has
exactly a 50% probability of being blue or red? (Choose all that are correct.)
- (1,1)
- (2,4)
- (5,-5)
- (-4,5)
First,
we construct a linear function to add the weights and bias term. Then, we use
activation function to return the scores to probabilities. Sigmoid function
returns values between 0 and 1.
fig1: sigmoid function
from math import e
#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 + e - score)
print("X",x,score,y)
#call the function
linear_func(features)
#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 + e - score)
print("X",x,score,y)
#call the function
linear_func(features)
Subscribe to:
Posts (Atom)
