相关疑难解决方法(0)

感知器学习算法不收敛到0

这是我在ANSI C中的感知器实现:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

float randomFloat()
{
    srand(time(NULL));
    float r = (float)rand() / (float)RAND_MAX;
    return r;
}

int calculateOutput(float weights[], float x, float y)
{
    float sum = x * weights[0] + y * weights[1];
    return (sum >= 0) ? 1 : -1;
}

int main(int argc, char *argv[])
{
    // X, Y coordinates of the training set.
    float x[208], y[208];

    // Training set outputs.
    int outputs[208];

    int i = 0; // iterator

    FILE *fp;

    if …
Run Code Online (Sandbox Code Playgroud)

c algorithm machine-learning perceptron neural-network

62
推荐指数
2
解决办法
2万
查看次数