单片机上网络计算函数
void layer_to_layer(
int lin_num,
int lout_num,
float32_t* input,
float32_t* output,
float32_t* w,
float32_t* b
)
{
float32_t *temp;
memset(output, 0,
lout_num * sizeof(float32_t));
temp = (float32_t *)malloc(lin_num * sizeof(float32_t));
for (int i=0;i<lout_num;i++)
{
#ifdef ARM_M4
arm_mult_f32(input,w+i*lin_num,temp,lin_num); //CMSIS-DSP库 向量相乘
#else
for (int i=0;i<lin_num;i++) //非DSP指令
{
*(temp+i)=*(input)*(*(w+i*lin_num))
}
#endif
for (int j=0;j<lin_num;j++)
{
*(output+i)=*(output+i)+*(temp+j);
}
*(output+i)=*(output+i)+*(b+i);
*(output+i)=logsig_fun(*(output+i));
}
free(temp);
}
|