Why Unsupported Ops in the model before optimization (IteratorV2, IteratorGetNext)?

515 views
Skip to first unread message

Sabrina Kletz

unread,
Jan 18, 2019, 6:29:53 AM1/18/19
to TensorFlow.js Discussion
I try to convert a trained model with TensorFlow into a tensorflowjs model using the provided converter with the following statement:

tensorflowjs_converter \
 
--input_format=tf_session_bundle \
 
--output_node_names='InceptionV1/Logits/Predictions/Reshape_1' \
 
--output_format=tensorflowjs \
 
/path/to/save_bundle \
 
/path/to/web_model

But this results in the following error:
ValueError: Unsupported Ops in the model before optimization
IteratorV2, IteratorGetNext

I tested TensorFlow 1.11 and 1.12, I use TFRecordDataset and an Iterator but I have no idea why Op 'IteratorV2' and not Op 'Iterator' is created. I initialize it in the following way:

dataset_train = tf.data.TFRecordDataset([filename_train])
dataset_train
= dataset_train.map(
 map_func
=lambda x: _parse_and_decode_and_preprocess(x, is_training=True))
dataset_train
= dataset_train.batch(_BATCH_SIZE, drop_remainder=True)
dataset_train
= dataset_train.repeat()

iterator_train
= dataset_train.make_initializable_iterator()
images_train
, labels_train = iterator_train.get_next()

However, when I add the following parameter to  tensorflowjs_converter

--skip_op_check=SKIP_OP_CHECK

then the desired output files are created. But when I use this output files in JavaScript  

<script src="https://cdnjs.cloudflare.com/ajax/libs/tensorflow/0.14.2/tf.min.js"></script>
...
<script>
const MODEL_URL = './tensorflowjs_model.pb';
const WEIGHTS_URL = './model/weights_manifest.json';
const model = await loadFrozenModel(MODEL_URL, WEIGHTS_URL);
const cat = document.getElementById('cat');
model
.execute({input: tf.fromPixels(cat)});
</script>

It results in a similar error that Tensorflow Op is not supported: IteratorV2

Does anybody know what the problem could be?
Thank you,
Best


Stan Bileschi

unread,
Jan 24, 2019, 10:28:38 AM1/24/19
to TensorFlow.js Discussion, Daniel Smilkov
+Daniel
Is IteratorV2 a core tensorflow op that is missing in TFJS?

Daniel Smilkov

unread,
Jan 24, 2019, 12:04:38 PM1/24/19
to Stan Bileschi, Ping Yu, TensorFlow.js Discussion
Hi Sabrina,

The converter is trying to convert the training piece of that model too, which involves operations used by dataset. We don't yet support all those ops on the js side, mostly since data feeding at inference time in the browser can be quite different than at training time on the server (e.g. feeding from a webcam).

In the meantime, if you can identify the intermediate node name that comes right after the dataset ops, and use model.execute() by feeding the image in that intermediate node.

You can also feed any intermediate nodes using a map as the input type. For example, given the graph
   InputNode => Intermediate => OutputNode,
you can execute the subgraph Intermediate => OutputNode by calling
    model.execute('IntermediateNode' : tf.tensor(...));

ps. We stopped monitoring this email and moved new discussions to Stack Overflow under the "tensorflow.js" tag to take advantage of the vibrant community there.

Daniel

Reply all
Reply to author
Forward
0 new messages