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.

Wrong output shape in compiled tanh layer

idata
Employee
734 Views

Hi everyone.

 

Recently I tried to port Deepgaze network on NCS. https://github.com/mpatacchiola/deepgaze/blob/master/deepgaze/head_pose_estimation.py

 

But compiled network always return wrong values.

 

During compilation following warnings appeared:

 

[Spoiler ]

 

 

! /usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py:766: DeprecationWarning: builtin type EagerTensor has no module attribute

 

! EagerTensor = c_api.TFE_Py_InitEagerTensor(_EagerTensorBase)

 

! /usr/local/lib/python3.5/dist-packages/tensorflow/python/util/tf_inspect.py:45: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() instead

 

! if d.decorator_argspec is not None), _inspect.getargspec(target))

 

! /usr/local/lib/python3.5/dist-packages/h5py/init.py:34: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.

 

! from ._conv import register_converters as _register_converters

 

! /usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/tensor_util.py:509: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead

 

! return np.fromstring(tensor.tensor_content, dtype=dtype).reshape(shape)

 

!

 

 

Network also doesn't pass mnNCCheck, so I tried to check part of it to find which layer causes problem.

 

Here is structure of network from mvNCProfile:

 

0 BiasAdd

 

1 Tanh

 

2 MaxPool

 

3 LRN

 

4 BiasAdd_1

 

5 Tanh_1

 

6 MaxPool_1

 

7 LRN_1

 

8 BiasAdd_2

 

9 Tanh_2

 

10 MaxPool_2

 

11 LRN_2

 

12 add

 

13 Tanh_3

 

14 add_1

 

15 output

 

So:

 

-in input

 

-on BiasAdd_1 - pass

 

-on Tanh_1 - throws an error: ValueError: cannot reshape array of size 32768 into shape (1,32,32,128)

 

-on MaxPool_1 - fails check because of low accuracy

 

Here is log for exception in tanh:

 

[Spoiler]

 

 

! mvNCCheck tf_model.meta -in input -on Tanh_1 -is 64 64

 

!

 

! Traceback (most recent call last):

 

! File "/usr/local/bin/mvNCCheck", line 152, in

 

! quit_code = check_net(args.network, args.image, args.inputnode, args.outputnode, args.nshaves, args.inputsize, args.weights, args)

 

! File "/usr/local/bin/mvNCCheck", line 137, in check_net

 

! timings, myriad_output = run_myriad(graph_file, args, file_gen=True)

 

! File "/usr/local/bin/ncsdk/Controllers/MiscIO.py", line 192, in run_myriad

 

! myriad_output = myriad_output.reshape(sz)

 

! ValueError: cannot reshape array of size 32768 into shape (1,32,32,128)

 

 

Then I compared graphs from tensorboard and mvNCProfile

 

And it appears that in mvNCProfile layers Tanh_1 and Tanh_2 has wrong output shape:

 

Tanh_1 takes tensor (128, 32, 32) and returns (32, 32, 32), but it should be also (128,32,32). In tensorboard this layer has right shape.

 

Tanh_2 input=(256, 16, 16) output = (16,16,16)

 

But "Tanh" and "Tanh_3" has right shapes (64,64,64) and (256,1, 1)

 

Images for Tanh_1 layer

 

[Spoiler]

 

 

! mvNCProfile:

 

!

 

! Tensorboard

 

!

 

 

Here you can find both graph images in full size:

 

tensorboard

 

mvProfile

 

I also tried to change tanh to relu. And in this case network was able to pass check and relu layers had right shape.

 

There is repo with small example, so you may try to reproduce this error. https://github.com/AlexSPN/Deepgaze-to-ncs-error

 

I use following environment:

 

NCSDK V1.12.00 2018-01-10

 

Python 2.7.12 - used for my scripts

 

Python 3.5.2 - seems to be used when I call mvNCCheck or mvNCCompile (at least in warnings python 3.5 was mentioned)

 

tensorflow 1.4.0

 

If I am missing out something, please let me know. Thanks!

0 Kudos
1 Reply
idata
Employee
469 Views

@SPN Thanks for reporting this issue in such a complete manner. We were able to reproduce your issue and are investigating the root cause.

0 Kudos
Reply