为感知器设定阈值

2024-05-29 07:33:53 发布

您现在位置:Python中文网/ 问答频道 /正文

如何设置单层感知器的阈值? 我有


    import numpy as np
    import sklearn
    from sklearn.linear_model import Perceptron

    xs = np.array([
      # x1 x2
        0, 0, #m1
        0, 1,
        1, 0,
        1, 1
    ]).reshape(4, 2)

    ys = np.array([1, 1, 0, 1]).reshape(4,)

    ppn = Perceptron(max_iter=10, eta0=0.2, random_state=0)

    ppn.fit(xs, ys)

我要做的是训练ppn权重,用初始值 权重=(0,0),eta=0.2,阈值=0,5

例如,对于m1,首字母:ys=1:

^{2}$

如果一劳永逸,学习应该停止 执行重量更新。在

如何将ppn的阈值设置为0.5?在


Tags: importnumpynp阈值sklearnarray权重感知器

热门问题