Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.
6252 Discussions

Wrong weights conversion during graph generation


Hi to everyone,


I'm trying to make it work a very simple neural network with the following structure:



  • Input of 3 84 3 (row, col, channels)


  • Conv2D with kernel 3x3, filter 1 and stride 3


  • Flatten layer where the output is only 28


  • A series of Dense layers of 28 ---> 256 ---> 128 ---> 64 ---> 32 ---> 5 with all Relu activations except for the last one that is linear.


    initial_model = load_model('stage_4_1510.h5')






    initial_model.trainable = False


    input = Input(shape=(3, 84, 3), name='input')


    x = Conv2D(filters=1, kernel_size=(3,3), use_bias=False,


    strides=(1,3), padding='valid', trainable=False,




    x = Flatten()(x)


    x = initial_model(x)


    model = Model(inputs=input, outputs=x)


    model.compile(loss='mse', optimizer='rmsprop')


    shape = (1,3,3,3,1)


    model.load_weights('stage_4_1510.h5', by_name=True)


    weights = np.empty(shape)









The network has been trained in Keras and so from .h5 I had to transform the model in .pb file.


At that point, in order to verify that everything was correct , I printed out the weights and everything was perfect.


So, I used the mvNCCompiler to get the .graph file and I generated it without problems with the following message:



No Bias


No Bias


No Bias


No Bias


No Bias


Fusing DeptwiseConv + Pointwise Convolution into plain Convolution


Fusing Add and Batch after Convolution


Eliminate layers that have been parsed as NoOp


Fusing Pad and Convolution2D


Fusing Scale after Convolution or FullyConnect


Fusing standalone postOps


Fusing Permute and Flatten


Fusing Eltwise and Relu


Fusing Concat of Concats


Evaluating input and weigths for each hw layer


Network Input tensors ['input:0#17']


Network Output tensors ['sequential_1/dense_5/BiasAdd:0#33']


Blob generated



It seems everything fine so far, but unfortunately the network, during the inference time, gives random outputs ( not coherent with the original network).


I'm sure that the problem is in the conversion and in particular in the fully connected part because with some tests I verified that the output of the convolutional part is correct.


So, considering that I can touch and get my hand the compiler, what I have to do? Do you have any idea? Thx

0 Kudos
1 Reply

Hi @EscVM


Could answer the following questions:



  • What are you using to test your model? If you are using your own code, do you mind sharing that with me to give it a try.

  • Have you tried to test with mvNCCheck? Make sure you are specifying an input image with -i followed with the path of the file

  • What version of the NCSDK are you using?




0 Kudos