【问题标题】:What should be the double weights and bias for NOT perceptron?NOT 感知器的双重权重和偏差应该是多少?
【发布时间】:2020-07-27 07:39:16
【问题描述】:
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))

上面的权重和偏差应该是多少? 很困惑,因为它是一个双倍权重感知器,我尝试了很多值,但最后至少 1 是错误的

【问题讨论】:

    标签: neural-network logical-operators perceptron


    【解决方案1】:

    NOT 运算可用于其中一个输入。假设它只考虑第二个输入并忽略第一个输入,下面可以看到分隔两个类的线示例 (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 的值。

    Decision boundary of a NOT perceptron

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-01
      • 1970-01-01
      • 2018-01-09
      • 2014-12-09
      • 1970-01-01
      • 2017-02-07
      • 2014-12-11
      • 1970-01-01
      相关资源
      最近更新 更多