int width_image_input =0;
int height_image_input = 0;
int width_image_C1 = 0;
int height_image_C1 = 0;
int width_image_S2 = 0;
int height_image_S2 = 0;
int width_image_C3 = 0;
int height_image_C3 = 0;
int width_image_S4 = 0;
int height_image_S4 = 0;
int width_image_C5 = 0;
int height_image_C5 = 0;
int width_image_output = 0;
int height_image_output = 0;
int width_kernel_conv = 0;
int height_kernel_conv = 0;
int width_kernel_pooling = 0;
int height_kernel_pooling = 0;
int num_map_input = 0;
int num_map_C1 = 0;
int num_map_S2 = 0;
int num_map_C3 = 0;
int num_map_S4 = 0;
int num_map_C5 = 0;
int num_map_output = 0;
int len_weight_C1 = 0;
int len_bias_C1 = 0;
int len_weight_S2 = 0;
int len_bias_S2 = 0;
int len_weight_C3 = 0;
int len_bias_C3 = 0;
int len_weight_S4 = 0;
int len_bias_S4 = 0;
int len_weight_C5 = 0;
int len_bias_C5 = 0;
int len_weight_output = 0;
int len_bias_output = 0;
int num_neuron_input = 0;
int num_neuron_C1 = 0;
int num_neuron_S2 = 0;
int num_neuron_C3 = 0;
int num_neuron_S4 = 0;
int num_neuron_C5 = 0;
int num_neuron_output = 0;
fread(&width_image_input, sizeof(int), 1, fp);
fread(&height_image_input, sizeof(int), 1, fp);
fread(&width_image_C1, sizeof(int), 1, fp);
fread(&height_image_C1, sizeof(int), 1, fp);
fread(&width_image_S2, sizeof(int), 1, fp);
fread(&height_image_S2, sizeof(int), 1, fp);
fread(&width_image_C3, sizeof(int), 1, fp);
fread(&height_image_C3, sizeof(int), 1, fp);
fread(&width_image_S4, sizeof(int), 1, fp);
fread(&height_image_S4, sizeof(int), 1, fp);
fread(&width_image_C5, sizeof(int), 1, fp);
fread(&height_image_C5, sizeof(int), 1, fp);
fread(&width_image_output, sizeof(int), 1, fp);
fread(&height_image_output, sizeof(int), 1, fp);
fread(&width_kernel_conv, sizeof(int), 1, fp);
fread(&height_kernel_conv, sizeof(int), 1, fp);
fread(&width_kernel_pooling, sizeof(int), 1, fp);
fread(&height_kernel_pooling, sizeof(int), 1, fp);
fread(&num_map_input, sizeof(int), 1, fp);
fread(&num_map_C1, sizeof(int), 1, fp);
fread(&num_map_S2, sizeof(int), 1, fp);
fread(&num_map_C3, sizeof(int), 1, fp);
fread(&num_map_S4, sizeof(int), 1, fp);
fread(&num_map_C5, sizeof(int), 1, fp);
fread(&num_map_output, sizeof(int), 1, fp);
fread(&len_weight_C1, sizeof(int), 1, fp);
fread(&len_bias_C1, sizeof(int), 1, fp);
fread(&len_weight_S2, sizeof(int), 1, fp);
fread(&len_bias_S2, sizeof(int), 1, fp);
fread(&len_weight_C3, sizeof(int), 1, fp);
fread(&len_bias_C3, sizeof(int), 1, fp);
fread(&len_weight_S4, sizeof(int), 1, fp);
fread(&len_bias_S4, sizeof(int), 1, fp);
fread(&len_weight_C5, sizeof(int), 1, fp);
fread(&len_bias_C5, sizeof(int), 1, fp);
fread(&len_weight_output, sizeof(int), 1, fp);
fread(&len_bias_output, sizeof(int), 1, fp);
fread(&num_neuron_input, sizeof(int), 1, fp);
fread(&num_neuron_C1, sizeof(int), 1, fp);
fread(&num_neuron_S2, sizeof(int), 1, fp);
fread(&num_neuron_C3, sizeof(int), 1, fp);
fread(&num_neuron_S4, sizeof(int), 1, fp);
fread(&num_neuron_C5, sizeof(int), 1, fp);
fread(&num_neuron_output, sizeof(int), 1, fp);
fread(weight_C1, sizeof(weight_C1), 1, fp);
fread(bias_C1, sizeof(bias_C1), 1, fp);
fread(weight_S2, sizeof(weight_S2), 1, fp);
fread(bias_S2, sizeof(bias_S2), 1, fp);
fread(weight_C3, sizeof(weight_C3), 1, fp);
fread(bias_C3, sizeof(bias_C3), 1, fp);
fread(weight_S4, sizeof(weight_S4), 1, fp);
fread(bias_S4, sizeof(bias_S4), 1, fp);
fread(weight_C5, sizeof(weight_C5), 1, fp);
fread(bias_C5, sizeof(bias_C5), 1, fp);
fread(weight_output, sizeof(weight_output), 1, fp);
fread(bias_output, sizeof(bias_output), 1, fp);
fflush(fp);
fclose(fp);
out2wi_S2.clear();
out2bias_S2.clear();
out2wi_S4.clear();
out2bias_S4.clear();
calc_out2wi(width_image_C1_CNN, height_image_C1_CNN, width_image_S2_CNN, height_image_S2_CNN, num_map_S2_CNN, out2wi_S2);
calc_out2bias(width_image_S2_CNN, height_image_S2_CNN, num_map_S2_CNN, out2bias_S2);
calc_out2wi(width_image_C3_CNN, height_image_C3_CNN, width_image_S4_CNN, height_image_S4_CNN, num_map_S4_CNN, out2wi_S4);
calc_out2bias(width_image_S4_CNN, height_image_S4_CNN, num_map_S4_CNN, out2bias_S4);
return true;
}
bool CNN::saveModelFile(const char* name)
{
FILE* fp = fopen(name, "wb");
if (fp == NULL) {
return false;
}
评论
查看更多