tensorflow: Fail to use tf.transpose() after tf.nn.embedding_lookup() and tf.layers.conv1d() while build a tflite file

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 16.04.3
  • TensorFlow installed from (source or binary): source
  • TensorFlow version (or github SHA if from source): 1.13.1

Provide the text output from tflite_convert 2019-04-12 16:14:22.935998: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] Before Removing unused ops: 13 operators, 22 arrays (0 quantized) 2019-04-12 16:14:22.936163: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] Before general graph transformations: 13 operators, 22 arrays (0 quantized) 2019-04-12 16:14:22.939819: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] After general graph transformations pass 1: 6 operators, 14 arrays (0 quantized) 2019-04-12 16:14:22.939890: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] After general graph transformations pass 2: 5 operators, 12 arrays (0 quantized) 2019-04-12 16:14:22.939945: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] After general graph transformations pass 3: 5 operators, 12 arrays (0 quantized) 2019-04-12 16:14:22.939972: F tensorflow/lite/toco/graph_transformations/propagate_fixed_sizes.cc:1605] Check failed: axis < input_shape.dimensions_count() (76044600 vs. 4) Aborted (core dumped)

# Copy and paste here

Also, please include a link to a GraphDef or the model if possible.

Any other info / logs

Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. ipts = tf.placeholder(dtype=tf.int32, shape=(None, 50), name='x') embedding = tf.get_variable(name='embedding', shape=[3000, 256], initializer=initializer) res = tf.nn.embedding_lookup(params=embedding, ids=ipts) res = tf.layers.conv1d(ipts, 100, 1) res = tf.transpose(res, perm=[0, 2, 1]) # Here cause the BUG sess = tf.Session() sess.run(tf.global_variables_initializer()) converter = tf.contrib.lite.TFLiteConverter.from_session(sess, [ipts], [res]) tflite_model = converter.convert() open('converted_model.tflite', 'wb').write(tflite_model)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 16 (3 by maintainers)

Most upvoted comments

I can reproduce it under tf-nightly now. But with a simpler code:

def func():
  ipts = tf.placeholder(dtype=tf.float32, shape=(None, 50, 50), name='x')
  y = tf.layers.conv1d(ipts, filters=2, kernel_size=1)
  res = tf.transpose(y, perm=[0,2,1]) # Here cause the BUG
  sess = tf.Session()
  sess.run(tf.global_variables_initializer())

  converter = tf.lite.TFLiteConverter.from_session(sess, [ipts], [res])
  tflite_model = converter.convert()

func()

Also found some interesting things to bypass this error:

  1. Change the 1st dim of ipts to something > 1. or
  2. use only one filter in conv1d. or
  3. use another perm=[1,0,2]

Either of these could eliminate the error. Please stay tuned a bit as I continue to investigate the issue. Thanks.