Forums - Failure to Convert Very Simple Tensorflow Model

2 posts / 0 new
Last post
Failure to Convert Very Simple Tensorflow Model
mike18
Join Date: 18 Jun 18
Posts: 1
Posted: Thu, 2018-06-28 14:23

Hello, 

Thank you for building this tool, we are thinking of using it at our company. I am having trouble converting a very simple model which only includes two Conv2D and a Dense Layer.

The code for tensorflow is:


with tf.variable_scope('layer1') as layer1:
conv1 = tf.layers.conv2d(
inputs=images,
filters=M,
kernel_size=[W, W],
padding='same',
name='conv1',
use_bias=False
)
activation1 = tf.nn.relu(conv1, name='relu1')

with tf.variable_scope('layer2') as layer2:
conv2 = tf.layers.conv2d(
inputs=activation1,
filters=N,
kernel_size=[1,1],
activation=tf.nn.relu,
padding='same',
name='conv2',
use_bias=False
)
activation2 = tf.nn.relu(conv2, name='relu2')

with tf.variable_scope('layer3') as layer3:
out = tf.layers.dense(activation2, units=1, name='FullyConnected')

 

The output I am getting:

 
2018-06-28 14:11:13.477127: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2018-06-28 14:11:13,830 - 366 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (layer3/FullyConnected/Tensordot/transpose_1) not consumed by converter: Transpose.
2018-06-28 14:11:13,830 - 366 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (layer3/FullyConnected/Tensordot/MatMul) not consumed by converter: MatMul.
2018-06-28 14:11:13,830 - 366 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (layer2/conv2/Conv2D) not consumed by converter: Conv2D.
2018-06-28 14:11:13,830 - 366 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (layer1/conv1/Conv2D) not consumed by converter: Conv2D.
2018-06-28 14:11:13,830 - 366 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (layer2/conv2/Relu) not consumed by converter: Relu.
2018-06-28 14:11:13,830 - 366 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (layer3/FullyConnected/Tensordot) not consumed by converter: Reshape.
2018-06-28 14:11:13,830 - 366 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (layer3/FullyConnected/BiasAdd) not consumed by converter: BiasAdd.
2018-06-28 14:11:13,830 - 366 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (layer3/FullyConnected/Tensordot/transpose) not consumed by converter: Transpose.
2018-06-28 14:11:13,830 - 366 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (layer2/relu2) not consumed by converter: Relu.
2018-06-28 14:11:13,830 - 366 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (layer1/relu1) not consumed by converter: Relu.
2018-06-28 14:11:13,830 - 366 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (layer3/FullyConnected/Tensordot/Reshape) not consumed by converter: Reshape.
2018-06-28 14:11:13,831 - 366 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (layer3/FullyConnected/Tensordot/Reshape_1) not consumed by converter: Reshape.
2018-06-28 14:11:13,831 - 122 - ERROR - Conversion failed: ERROR_TF_OPERATION_NOT_MAPPED_TO_LAYER: Some operations in the Tensorflow graph were not resolved to a layer. You can use --allow_unconsumed_nodes for partial graph resolution!
 

 

<strong> However, when I remove the  last dense layer, the model compiles fine . I find this interesting because when I add the last dense layer, it says a Conv2D operation is not consumed < /strong> . It seems like a few people have experienced this "NOT CONSUMED" issue. Do you think you can help me clarify the rules regarding <strong> What defines resolving an operation to an layer ? < / strong>. 

Thanks!

  • Up0
  • Down0
gesqdn-forum
Join Date: 4 Nov 18
Posts: 184
Posted: Tue, 2019-10-15 03:50
Hi,
I faced the same issue while using the dense layer (tf.layers.dense API). The reason for the issue is that there is a reshape operation being applied to weights (introduced by tf.layer.dense API). The converter missinterprets it as part of the model execution and hence tries to convert to a layer which it can't since there are no input layers to it. 
 
You can use reshape(tf.reshape API) between a convolution and fully connected to flatten the tensor and it will work fine.
 
Hope this helps!
Thanks
  • Up0
  • Down0
or Register

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.