0
0
TensorFlowml~10 mins

TensorFlow Lite conversion - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a TensorFlow Lite converter from a saved model.

TensorFlow
import tensorflow as tf
converter = tf.lite.TFLiteConverter.from_[1]('saved_model_dir')
Drag options to blanks, or click blank then click option'
Akeras_model
Bsaved_model
Cconcrete_function
Dgraph_def
Attempts:
3 left
💡 Hint
Common Mistakes
Using from_keras_model() when the model is saved as a saved model directory.
Confusing from_concrete_function() with from_saved_model().
2fill in blank
medium

Complete the code to convert the TensorFlow model to TensorFlow Lite format.

TensorFlow
tflite_model = converter.[1]()
Drag options to blanks, or click blank then click option'
Asave
Bexport
Cconvert
Dcompile
Attempts:
3 left
💡 Hint
Common Mistakes
Using save() which does not exist on the converter object.
Using compile() which is unrelated to conversion.
3fill in blank
hard

Fix the error in saving the TensorFlow Lite model to a file.

TensorFlow
with open('model.tflite', 'wb') as f:
    f.[1](tflite_model)
Drag options to blanks, or click blank then click option'
Awrite
Bwritelines
Csave
Dappend
Attempts:
3 left
💡 Hint
Common Mistakes
Using writelines() which causes a TypeError with bytes.
Using save() which is not a file method.
4fill in blank
hard

Fill both blanks to enable post-training quantization for the converter.

TensorFlow
converter.optimizations = [[1].DEFAULT]
converter.target_spec.supported_types = [[2].int8]
Drag options to blanks, or click blank then click option'
Atf.lite.Optimize
Btf.lite.Quantize
Ctf
Dtf.lite.Converter
Attempts:
3 left
💡 Hint
Common Mistakes
Using tf.lite.Quantize which does not exist.
Confusing Converter class with optimization enums.
5fill in blank
hard

Fill all three blanks to convert a Keras model to TensorFlow Lite and save it.

TensorFlow
import tensorflow as tf
converter = tf.lite.TFLiteConverter.from_[1](keras_model)
tflite_model = converter.[2]()
with open('model.tflite', '[3]') as f:
    f.write(tflite_model)
Drag options to blanks, or click blank then click option'
Akeras_model
Bsaved_model
Cconvert
Dwb
Attempts:
3 left
💡 Hint
Common Mistakes
Using from_saved_model() for Keras model.
Opening file in text mode instead of binary mode.
Using save() instead of convert().