Neural network 什么是非感知器的双重权重和偏差?
上面的权重和偏差应该是什么?Neural network 什么是非感知器的双重权重和偏差?,neural-network,logical-operators,perceptron,Neural Network,Logical Operators,Perceptron,上面的权重和偏差应该是什么? 由于它是一个双重重量的感知器,我尝试了许多值,但最后至少有1个是错误的不能在其中一个输入中使用操作。假设它只考虑第二个输入而忽略第一个输入,下面可以看到一个分隔两个类的行示例(x=0.5) 为了找到权重,让我们使用方程w1x1+w2x2+b=0。由于第一个输入被忽略,这意味着w1=0。方程现在变成w2x2+b=0或x2=-b/w2=常数。假设决策边界为x=0.5,我们可以尝试设置w2=-1或w2=1。对于这些值,b必须分别为0.5和-0.5。对于上面的示例,我们应该
由于它是一个双重重量的感知器,我尝试了许多值,但最后至少有1个是错误的不能在其中一个输入中使用操作。假设它只考虑第二个输入而忽略第一个输入,下面可以看到一个分隔两个类的行示例(x=0.5) 为了找到权重,让我们使用方程w1x1+w2x2+b=0。由于第一个输入被忽略,这意味着w1=0。方程现在变成w2x2+b=0或x2=-b/w2=常数。假设决策边界为x=0.5,我们可以尝试设置w2=-1或w2=1。对于这些值,b必须分别为0.5和-0.5。对于上面的示例,我们应该保持值w2=-1和b=0.5
import pandas as pd
# TODO: Set weight1, weight2, and bias
weight1 = -2.5
weight2 = -1.5
bias = 1.0
# DON'T CHANGE ANYTHING BELOW
# Inputs and outputs
test_inputs = [(0, 0), (0, 1), (1, 0), (1, 1)]
correct_outputs = [True, False, True, False]
outputs = []
# Generate and check output
for test_input, correct_output in zip(test_inputs, correct_outputs):
linear_combination = weight1 * test_input[0] + weight2 * test_input[1] + bias
output = int(linear_combination >= 0)
is_correct_string = 'Yes' if output == correct_output else 'No'
outputs.append([test_input[0], test_input[1], linear_combination, output, is_correct_string])
# Print output
num_wrong = len([output[4] for output in outputs if output[4] == 'No'])
output_frame = pd.DataFrame(outputs, columns=['Input 1', ' Input 2', ' Linear Combination', ' Activation Output', ' Is Correct'])
if not num_wrong:
print('Nice! You got it all correct.\n')
else:
print('You got {} wrong. Keep trying!\n'.format(num_wrong))
print(output_frame.to_string(index=False))