Ir para conteúdo
Fórum Script Brasil
  • 0

saharayoub

Pergunta

Sou iniciante no forum e tenho que fazer um programa que simule redes neurais em c++.

Estou usando o Dev C++ e baixei a biblioteca famm más não consigo usa ela no DEV C++ como devo proceder?

Já instalei pelo package manager e não dá certo.

#include <stdio.h>

#include "fann.h"

int FANN_API test_callback(struct fann *ann, struct fann_train_data *train,
    unsigned int max_epochs, unsigned int epochs_between_reports, 
    float desired_error, unsigned int epochs)
{
    printf("Epochs     %8d. MSE: %.5f. Desired-MSE: %.5f\n", epochs, fann_get_MSE(ann), desired_error);
    return 0;
}

int main()
{
    fann_type *calc_out;
    const unsigned int num_input = 2;
    const unsigned int num_output = 1;
    const unsigned int num_layers = 3;
    const unsigned int num_neurons_hidden = 3;
    const float desired_error = (const float) 0;
    const unsigned int max_epochs = 1000;
    const unsigned int epochs_between_reports = 10;
    struct fann *ann;
    struct fann_train_data *data;

    unsigned int i = 0;
    unsigned int decimal_point;

    printf("Creating network.\n");
    ann = fann_create_standard(num_layers, num_input, num_neurons_hidden, num_output);

    data = fann_read_train_from_file("xor.data");

    fann_set_activation_steepness_hidden(ann, 1);
    fann_set_activation_steepness_output(ann, 1);

    fann_set_activation_function_hidden(ann, FANN_SIGMOID_SYMMETRIC);
    fann_set_activation_function_output(ann, FANN_SIGMOID_SYMMETRIC);

    fann_set_train_stop_function(ann, FANN_STOPFUNC_BIT);
    fann_set_bit_fail_limit(ann, 0.01f);

    fann_set_training_algorithm(ann, FANN_TRAIN_RPROP);

    fann_init_weights(ann, data);
    
    printf("Training network.\n");
    fann_train_on_data(ann, data, max_epochs, epochs_between_reports, desired_error);

    printf("Testing network. %f\n", fann_test_data(ann, data));

    for(i = 0; i < fann_length_train_data(data); i++)
    {
        calc_out = fann_run(ann, data->input);
        printf("XOR test (%f,%f) -> %f, should be %f, difference=%f\n",
               data->input[0], data->input[1], calc_out[0], data->output[0],
               fann_abs(calc_out[0] - data->output[0]));
    }

    printf("Saving network.\n");

    fann_save(ann, "xor_float.net");

    decimal_point = fann_save_to_fixed(ann, "xor_fixed.net");
    fann_save_train_to_fixed(data, "xor_fixed.data", decimal_point);

    printf("Cleaning up.\n");
    fann_destroy_train(data);
    fann_destroy(ann);

    return 0;
}

Link para o comentário
Compartilhar em outros sites

0 respostass a esta questão

Posts Recomendados

Até agora não há respostas para essa pergunta

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152k
    • Posts
      651,8k
×
×
  • Criar Novo...