Генерация Си кода из нейросетей
Автор
#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.1f + 7.0f * tanh(-0.72043973f * RHS[6] + -1.1665595f * RHS[7]) + 3.0f * tanh(-0.72043973f * RHS[2] + -1.1665595f * RHS[3]) + 6.0f * tanh(-0.72043973f * RHS[5] + -1.1665595f * RHS[6]) + 5.0f * tanh(-0.72043973f * RHS[4] + -1.1665595f * RHS[5]) + tanh(-0.72043973f * RHS[0] + -1.1665595f * RHS[1]) + 2.0f * tanh(-0.72043973f * RHS[1] + -1.1665595f * RHS[2]) + 8.0f * tanh(-0.72043973f * RHS[7] + -1.1665595f * RHS[8]) + 4.0f * tanh(-0.72043973f * RHS[3] + -1.1665595f * RHS[4]) + 9.0f * tanh(-1.1665595f * RHS[9] + -0.72043973f * RHS[8]);
}
int main(int argc, char const *argv[]){
float out[1];
float in[] = {0.5692651172857585,0.89576328107994,0.031887694179403625,0.030866578709145998,0.0044065208024239855,0.42789849201650365,0.2983015448094558,0.48988845566296324,0.5464080496015603,0.15085709322023555};
neural_net( out, in );
printf( "%f\n", out[0] );
return 0;
}