Forums - tf.nn.depthwise_conv2d DLC Conversion Failed

1 post / 0 new
tf.nn.depthwise_conv2d DLC Conversion Failed
jerry.wj_chen
Join Date: 5 Mar 18
Posts: 7
Posted: Fri, 2018-04-27 00:30

My environment: Ubuntu14.04 / Python 2.7 / tensorflow 1.3.0 / SNPE 1.13.0

I build a simple network for testing depthwise layer convertion with code

img = tf.placeholder(tf.float32, shape=[None, 128, 128, 1], name='ODD')
kernel_shape = [3, 3, 1, 2] # in_channel=1, depth_multiplier=2
stride_shape = [1, 1, 1, 1]
depth_kernel = tf.get_variable('DepthConv/depth_kernel', shape=kernel_shape, dtype=tf.float32)
logits = tf.nn.depthwise_conv2d(img, depth_kernel, strides=stride_shape, padding='SAME', name='DepthConv/depthwise2d')
After training, i put the result frozen_graph into Ubuntu 14.04 and run dlc conversion
snpe-tensorflow-to-dlc --graph ${graph} --input_dim ODD 128,128,1 --out_node DepthConv/depthwise2d --verbose 
This results in the error message:
Quote:
/home/jerrywj/snpe-1.13.0/lib/python/converters/tensorflow/layers/convolution.py:336: RuntimeWarning: error_code=1002; error_message=Layer paramter value is invalid. Layer DepthConv/depthwise2d: weights have wrong number of input channels; error_component=Model Validation; line_no=587; thread_id=139731316676416
 
I have tried with different config
img = tf.placeholder(tf.float32, shape=[None, 128, 128, 3], name='ODD')
kernel_shape = [3, 3, 3, 1] # in_channel=3, depth_multiplier=1
stride_shape = [1, 1, 1, 1]
depth_kernel = tf.get_variable('DepthConv/depth_kernel', shape=kernel_shape, dtype=tf.float32)
logits = tf.nn.depthwise_conv2d(img, depth_kernel, strides=stride_shape, padding='SAME', name='DepthConv/depthwise2d')

This time it works.

To summary, this problem seems happened when depth multiplier > 1.

I want to ask that does anyone face the same problem as  mine?

The maximum value of depth multiplier is 1?

  • Up0
  • Down0

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.