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