/neuralnet2cpp

Compute your R 'neuralnet' neural network using cpp code

Primary LanguageRMIT LicenseMIT

neuralnet2cpp

Compute your R 'neuralnet' neural network using cpp code.

You can train you neural network with R:

> library( 'neuralnet' )
> data <- data.frame( i1 = c(1, 2, 4), i2 = c(5, 5, 6), o = c(1, 1, 0) )
> net <- neuralnet( o~i1+i2, hidden = c( 5, 2 ) )

Then test your net:

> test <- data.frame( i1 = 5, i2 = 1 )
> res <- compute( net, test )
> res$net.result
               [,1]
[1,] -0.08056605515

And convert that network into cpp:

> compute.gen.cpp( net, "~/myprojects/subfolder/compute.cpp" )

Test your network using compute.cpp:

int main(int argc, char *argv[])
{
    const double covariates[2] = { 5, 1 };
    double results[1] = { 0 };
    neuralnet::compute( &covariates[0], &results[0] );
    printf( "%f\n", results[0] ); // -0.080566
    return 0;
}