感知机模拟或门的实现:权重和阈值的设置

Posted CSU迦叶

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了感知机模拟或门的实现:权重和阈值的设置相关的知识,希望对你有一定的参考价值。

def orGate(x1, x2):
    w1, w2, theta= 0.5, 0.5, 0.4
    tmp = x1 * w1 + x2 * w2
    if tmp <= theta:
        return 0
    elif tmp > theta:
        return 1


print(orGate(1, 1))
print(orGate(0, 1))
print(orGate(1, 0))
print(orGate(0, 0))

以上是关于感知机模拟或门的实现:权重和阈值的设置的主要内容,如果未能解决你的问题,请参考以下文章