0
0
Computer Visionml~10 mins

Model optimization (pruning, quantization) in Computer Vision - Interactive Code Practice

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

Complete the code to apply pruning to a model layer.

Computer Vision
import tensorflow_model_optimization as tfmot
prune_low_magnitude = tfmot.sparsity.keras.[1](pruning_schedule)
pruned_model = prune_low_magnitude(model)
Drag options to blanks, or click blank then click option'
Aprune
Bprune_model
Cpruning_schedule
Dprune_low_magnitude
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect function names like 'prune' or 'prune_model'.
2fill in blank
medium

Complete the code to convert a TensorFlow model to a quantized TFLite model.

Computer Vision
converter = tf.lite.TFLiteConverter.from_keras_model(model)
converter.optimizations = [tf.lite.[1].OPTIMIZE_FOR_SIZE]
tflite_quant_model = converter.convert()
Drag options to blanks, or click blank then click option'
AOptimize
BQuantization
COptimizeMode
DOptimizeForSize
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect optimization flags like 'Quantization' or 'OptimizeForSize'.
3fill in blank
hard

Fix the error in the pruning callback setup.

Computer Vision
callbacks = [tfmot.sparsity.keras.UpdatePruningStep(), tfmot.sparsity.keras.[1](log_dir)]
Drag options to blanks, or click blank then click option'
APruningSummaries
BPruningSummary
CPruningCallback
DPruningLogger
Attempts:
3 left
💡 Hint
Common Mistakes
Using singular form or incorrect callback names.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps layer names to their pruning status.

Computer Vision
pruning_status = {layer.name: layer.[1] for layer in model.layers if hasattr(layer, '[2]')}
Drag options to blanks, or click blank then click option'
Apruning_step
Bpruned
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing attribute names like 'pruning_step'.
5fill in blank
hard

Fill all three blanks to create a quantization-aware training model setup.

Computer Vision
import tensorflow_model_optimization as tfmot
quantize_model = tfmot.quantization.keras.[1](model)
quantize_model.compile(optimizer=[2], loss=[3])
Drag options to blanks, or click blank then click option'
Aquantize_model
B'adam'
C'sparse_categorical_crossentropy'
Dquantize_annotate_model
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong function names or loss strings.