Hello!
I would like to know the way numbers are handled in the deep learning softmax function.
After performing 3 convolutions I have output numbers for the first 1000 spaces (printed out).
The shape of this convolution input is (32,3,3,16).
then prelu, and maxpool.
The following operation is another convolution of shape (2,1,1,32) to obtain the scores.
This output for this matrix is mostly Nan, and then some numbers that make general sense for a score (0-1)...so my question would be where are these nans coming from?
Are they expected?
Should i write a small function to obtain the scores at each stride instead of all score for all convolutions?
Could it be that my Data is not normalized?
--> As a side note, I have a hunch that it could be something to do with weight ordering
the ESP lib is: (N H W C)
caffe's output is: (N C H W)
in-> (N C H W)
I have translated these formats using the method below with numpy
first step: np.moveaxis(in,1,3)
out-> (N W H C )
second step: np.moveaxis(in, 1,2)
out-> ( N H W C)
flatten the array using np.reshape(in,-1)
load the array into dl_matrix3d_t using a for loop
(using out = in.transpose(0,2,3,1) also provides the same result)
as an example (this is from the input to the bounding box layer)
original Shape from caffe (4, 32, 1, 1)
new shape for ESP lib(4, 1, 1, 32)
flatten and load
OUTPUT FROM MODEL:
here is the code for the neural layers of the network: ( i have erased the free and some printout methods to save space, but will attach the whole code if context is needed)
dl_matrix3d_t *filt_c1 = dl_matrix3d_alloc(10,3,3,3);
dl_matrix3d_t *bias1 =dl_matrix3d_alloc(1,1,1,10);
dl_matrix3d_t *prelu1 =dl_matrix3d_alloc(1,1,1,10);
dl_matrix3d_t *out1 =dl_matrix3d_alloc(10,1,1,10);
getpnet_conv1_0(filt_c1);//pnetVals.h
getpnet_conv1_1(bias1);//pnetvals.h
getpnet_prelu1_0(prelu1);//pnetvals.h
// 3x3 convolution 1
out1= dl_matrix3dff_conv_3x3(in,filt_c1,bias1,1,1,PADDING_SAME);
dl_matrix3d_p_relu(out1, prelu1);
dl_matrix3d_global_pool(out1);
dl_matrix3d_t *filt_c2 = dl_matrix3d_alloc(16,3,3,10);
dl_matrix3d_t *bias2 = dl_matrix3d_alloc(1,1,1,16);
dl_matrix3d_t *out2= dl_matrix3d_alloc(1,1,1,16);
//this might need to be moved until after conv_2
dl_matrix3d_t *prelu2 = dl_matrix3d_alloc(1,1,1,16);
getpnet_conv2_0(filt_c2);
getpnet_conv2_1(bias2);
getpnet_prelu2_0(prelu2);
out2 = dl_matrix3dff_conv_3x3(out1,filt_c2,bias2,1,1,PADDING_SAME);
dl_matrix3d_p_relu(out2,prelu2);
dl_matrix3d_global_pool(out2);
//=====================================
dl_matrix3d_t *filt_c3 = dl_matrix3d_alloc(32,3,3,16);
dl_matrix3d_t *bias3 = dl_matrix3d_alloc(1,1,1,32);
dl_matrix3d_t *out3= dl_matrix3d_alloc(1,1,1,32);
//get weights
getpnet_conv3_0(filt_c3);
getpnet_conv3_1(bias3);
out3 = dl_matrix3dff_conv_3x3(out2,filt_c3,bias3,1,1,PADDING_SAME);
dl_matrix3d_free(out2);
dl_matrix3d_free(bias3);
dl_matrix3d_t *prelu3 = dl_matrix3d_alloc(1,1,1,32);
getpnet_prelu3_0(prelu3);
dl_matrix3d_p_relu(out3,prelu3);
dl_matrix3d_free(prelu3);
dl_matrix3d_global_pool(out3);
//=====================================
dl_matrix3d_t *score_filter=dl_matrix3d_alloc(2,1,1,32);
dl_matrix3d_t *score_bias = dl_matrix3d_alloc(1,1,1,2);
dl_matrix3d_t *score_out = dl_matrix3d_alloc(1,1,1,2);
getpnet_score_0(score_filter);
getpnet_score_1(score_bias);
score_out = dl_matrix3dff_conv_3x3(out3,score_filter,score_bias,1,1,PADDING_SAME);
dl_matrix3d_free(score_filter);
dl_matrix3d_free(score_bias);
dl_matrix3d_softmax(score_out);
//====================================
dl_matrix3d_t *bbox_filter=dl_matrix3d_alloc(4,1,1,32);
dl_matrix3d_t *bbox_bias=dl_matrix3d_alloc(1,1,1,4);
dl_matrix3d_t *bbox_out=dl_matrix3d_alloc(1,1,1,4);
getpnet_bbox_pred_0(bbox_filter);
getpnet_bbox_pred_1(bbox_bias);
bbox_out = dl_matrix3dff_conv_3x3(out3,bbox_filter,bbox_bias,1,1,PADDING_SAME);
dl_matrix3d_free(out3);
dl_matrix3d_free(bbox_filter);
dl_matrix3d_free(bbox_bias);
printf("\n\nALLOCATING OUTPUT...\n\n\n");
//=========================================
// SET MEMORY //
//output is a global variable
setOutput(bbox_out,1);// bounding boxes
setOutput(score_out,0);//score output
dl_matrix3d_free(bbox_out);
// dl_matrix3d_free(score_out);
printf("\n\n");
int i;
printf("\n\nFROM PNET LOOP:\nscore: ");
for (i=0;i<1500;i++)
{
printf("---:%f :---", score_out->item[i]);
}
printf("\n\n");
xSemaphoreGive(skeletonKey);
vTaskDelay(1000/portTICK_PERIOD_MS);
vTaskDelete( NULL );