Ejemplo n.º 1
0
void NeuralNetwork::build_weight_matrix(synapse& weights,
                                        const int n_from,
                                        const int n_to)
{
    for (int i = 0; i < n_from; i++) {
        weights.push_back(nerve());
        for (int j = 0; j < n_to; j++) {
            weights[i].push_back(rzero(2.0*rand() - 1.0));
        }
    }
}
Ejemplo n.º 2
0
void NeuralNetwork::build_feedback_matrix(synapse& feedback,
                                          const int n_from,
                                          const int n_to)
{
    for (int i = 0; i < n_from; i++) {
        feedback.push_back(nerve());
        for (int j = 0; j < n_to; j++) {
            feedback[i].push_back(0.0);
        }
    }
}
Ejemplo n.º 3
0
void identity_matrix(NeuralNetwork& neural_network,
                     const int n_inputs, const int n_outputs)
{
    double node;
    synapse input_grid;
    synapse output_grid;

    // Set up the inputs and outputs
    for (int i = 0; i < n_inputs; i++) {

        input_grid.push_back(nerve());
        output_grid.push_back(nerve());

        for (int j = 0; j < n_outputs; j++) {
            node = (j == i) ? 1.0 : 0.0;
            input_grid[i].push_back(node);
            output_grid[i].push_back(node);
        }
    }

    // Set up the network structure, train it, and show test results
    neural_network.train(input_grid, output_grid, THINKER_MAX_CYCLES, 0.5);
    neural_network.test(input_grid, output_grid);
}