Norm output Precision issues
Hi, I'm trying to use the compute library for implementing the Alexnet . For 1st Normalization layer we are facing huge precision issues when compared to output from other platform(Eg: GPU) for a given input . Download the input and outputs from the below link to test the norm layer https://drive.google.com/open?id=0B8m_q7acVVbbQU5aMFhtblFSd1E .Below is the code I'm using in arm-compute library
main()
{
// The src tensor which will contain the input image
Tensor dup_src;
// The weights and biases tensors should be initialized with the values inferred with the training
Tensor dst;
NENormalizationLayer NormLayer;
float *inp = (float *)malloc(55*55*96*sizeof(float));
FILE *fp;
fp = fopen("norm_inp.bin","rb");
fread(inp,4,55*55*96,fp);
fclose(fp);
/* [Initialize tensors] */
dup_src.allocator()->init(TensorInfo(TensorShape(55*55*96), 1, DataType::F32));
dst.allocator()->init(TensorInfo(TensorShape(55*55*96), 1, DataType::F32));
NormLayer.configure(&dup_src, &dst, NormalizationLayerInfo(NormType::CROSS_MAP,5, 2.0E-5, 0.75, 1.0));
dup_src.allocator()->allocate();
dst.allocator()->allocate();
std::copy_n((unsigned char*)inp , 55*55*96*sizeof(float), (unsigned char*)dup_src.buffer() + dup_src.info()->offset_element_in_bytes(Coordinates(0, 0)));
NormLayer.run();
float *out = (float*)(dst.buffer() + dst.info()->offset_element_in_bytes(Coordinates(0, 0)));
fp = fopen("norm_out.txt","w");
for(int i=0;i<55*55*96;i++)
fprintf(fp,"%f\n",out[i]);
fclose(fp);
}
Can you check it and let us know if it is expected or some inherent bug is there.
Thanks, G.Praveen.
Hello @uu-praveeng,
By just looking at the code I notice that you create a 1D tensor and then you want to do a cross map normalization:
/* [Initialize tensors] */
dup_src.allocator()->init(TensorInfo(TensorShape(55*55*96), 1, DataType::F32));
dst.allocator()->init(TensorInfo(TensorShape(55*55*96), 1, DataType::F32));
NormLayer.configure(&dup_src, &dst, NormalizationLayerInfo(NormType::CROSS_MAP,5, 2.0E-5, 0.75, 1.0));
I would expect it to be a 3D tensor instead like:
/* [Initialize tensors] */
dup_src.allocator()->init(TensorInfo(TensorShape(55U /*width*/, 55U /*height*/, 96U /*feature maps*/), 1, DataType::F32));
dst.allocator()->init(TensorInfo(TensorShape(55U, 55U, 96U), 1, DataType::F32));
NormLayer.configure(&dup_src, &dst, NormalizationLayerInfo(NormType::CROSS_MAP,5, 2.0E-5, 0.75, 1.0));
You should be careful on how you will copy the data then as you might have padding. Have a look at Moritz' comment with the window and the iterator in #28
Hi George,
I am trying to use the 3D tensor shape as you have suggested after norm.configure. the input tensor shape increased huge from 1161600 to 1351680. And it is showing the 1st feature map 1st value will be started from 12th byte.
Is there any example code to copy the 96 feature maps of 55x55 dims into input tensor. I think straight forward copy_n cannot be used for above copying since there could be padding in the featuremap(widthxheight) wise or in width wise.
Thanks
I was able to know the desired padded settings using the const arm_compute::Strides &strides_in_bytes = tensor.info()->strides_in_bytes();
But again memcpy will be overhead .Anyways Thanx
@uu-praveeng Could you please give more details about where the weights come from ? Why do you say "memcpy will be overhead" ? I assume the values come from a file, right ? What's the issue with loading the file one row at the time ?
Hi Anthony,
As of now there are no overheads nor issues in implementing the Alexnet with the latest release. Except for grouped convolution implementation which I think you are working on and issue 47.
Thanks for your support .