Генерация Си кода из нейросетей
Автор
#include <stdio.h>
#include <stdbool.h>
float ifelse(bool cond, float a, float b) { return cond ? a : b; }
#include <math.h>
void neural_net(float* LHS, const float* RHS) {
LHS[0] = 0.7022008f * tanh(-0.32191858f * RHS[0] + -0.6533903f * RHS[1]) + 0.089636445f * tanh(-0.6533903f * RHS[9] + -0.32191858f * RHS[8]) + -0.17584637f * tanh(-0.32191858f * RHS[1] + -0.6533903f * RHS[2]) + -0.25202173f * tanh(-0.32191858f * RHS[2] + -0.6533903f * RHS[3]) + 0.098273665f * tanh(-0.32191858f * RHS[3] + -0.6533903f * RHS[4]) + -0.49644724f * tanh(-0.32191858f * RHS[4] + -0.6533903f * RHS[5]) + 0.570838f * tanh(-0.32191858f * RHS[6] + -0.6533903f * RHS[7]) + 0.6785635f * tanh(-0.32191858f * RHS[5] + -0.6533903f * RHS[6]) + 0.22922707f * tanh(-0.32191858f * RHS[7] + -0.6533903f * RHS[8]);
}
int main(int argc, char const *argv[]){
float out[1];
float in[] = {0.5657125603471046,0.30643581995144964,0.8650717385990054,0.028638136948423876,0.10198107516800481,0.12725352329167416,0.3662408939165933,0.11736462347396193,0.9021544066800209,0.8748426394517218};
neural_net( out, in );
printf( "%f\n", out[0] );
return 0;
}