【问题标题】:Doubts perceptron怀疑感知器
【发布时间】:2018-10-04 05:10:55
【问题描述】:

我正在自己研究机器学习,我发现了以下感知器的签名:

def ClassicPerceptron(W,X,Y,maxiter=1000,reorder=True):
    """ClassicPerceptron function implements the most basic perceptron. 

    This algorithm starts by reordering the training samples and their labels
    if reorder is equal to True. Then, it iterates for all the samples, as many
    times as it takes, to correctly classify all the samples, or until the number 
    of iterations reaches maxiter.

    Parameters
    ----------
    W : numpy array of floats
        The initial set of weights for the perceptron classificator.
    X : numpy array of floats
        The dataset with the bias (first column is equal to 1.0).
    Y : numpy array of floats
        The labels (-1.0, ou 1.0) for each line of X.
    maxiter : integer
        The maximum number of iterations allowed before stopping.
    reorder : boolean
        reorder the training samples and their labels.

    Returns
    -------
    W : numpy array of floats
        The last set of weights for the perceptron classificator.
    niter : integer
        The current number of iterations until success, or maxiter. 
        This is just to have an idea on how many iterations it took 
        to converge.

    """

我觉得很好奇,因为该算法不尊重权重的更新,因为到目前为止我们都看到了使用权重的更新,实际上我不太理解这个定义,我以为这种重新排序会打乱训练例子,不过我有点迷茫,想轻看这个算法怎么顶。 PS:请不要用代码回复,只是喜欢一个解释。

【问题讨论】:

    标签: machine-learning perceptron


    【解决方案1】:

    嗯,依我看,既然你可以通过reorder=False,重新排序步骤是可选的,所以当它说

    然后,它对所有样本进行多次迭代,以正确分类所有样本,或者直到迭代次数达到最大值。

    它似乎正在更新/调整权重,直到它正确找到最佳解决方案(用超平面分隔类)或直到达到maxiter。换句话说,它似乎尊重权重的更新

    如果可能的话,如果您能向我们提供方法实现,那将会很有帮助,这样可以理解重新排序训练集背后的概念或想法。

    除了这种训练方法之外,还可以通过求解线性系统来计算biasweights,例如:X * W = Y。其中X训练样本 加上额外的偏置列,W 权重数组 加上偏置权重,Y 训练标签强>。其实乍一看,我还以为这就是方法的意图。

    在这种情况下,重新排序步骤有助于获得交错形式的矩阵或获得lower triangular matrix。两者都使用集合中的d 样本,其中d 是维度(特征数量加一,用于偏差)

    请注意,为了解决这个线性系统,您需要将 X * W 的单个结果(即:来自 X 的单行与来自 W 的唯一列)考虑为 1 或 -1。您可以通过将 limiar 以上的每个结果视为 1 来实现这一点。否则,-1。

    【讨论】:

      猜你喜欢
      • 2018-03-04
      • 1970-01-01
      • 1970-01-01
      • 2013-10-09
      • 2018-10-18
      • 2017-10-01
      • 2016-09-06
      • 2011-10-01
      • 1970-01-01
      相关资源
      最近更新 更多