0
0
TensorFlowml~10 mins

HDF5 format in TensorFlow - Interactive Code Practice

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

Complete the code to save a TensorFlow model in HDF5 format.

TensorFlow
model.save('my_model.[1]')
Drag options to blanks, or click blank then click option'
Ahdf5
Bhdf
Chdf6
Dh5
Attempts:
3 left
💡 Hint
Common Mistakes
Using .hdf or .hdf5 extensions which are not recognized by TensorFlow save method by default.
Using unsupported or incorrect file extensions.
2fill in blank
medium

Complete the code to load a TensorFlow model saved in HDF5 format.

TensorFlow
loaded_model = tf.keras.models.[1]('my_model.h5')
Drag options to blanks, or click blank then click option'
Aload
Bloadmodel
Cload_model
DloadKeras
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'load' which is not a valid function in tf.keras.models.
Misspelling the function name.
3fill in blank
hard

Fix the error in the code to save the model in HDF5 format.

TensorFlow
model.save('model[1]')
Drag options to blanks, or click blank then click option'
A.h5
B.hdf
C.txt
D.json
Attempts:
3 left
💡 Hint
Common Mistakes
Using '.txt' or '.json' extensions which do not save the model correctly.
Omitting the file extension.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that stores layer names and their weights from a model.

TensorFlow
weights_dict = {layer.[1]: layer.[2] for layer in model.layers}
Drag options to blanks, or click blank then click option'
Aname
Bweights
Cbias
Doutput
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'bias' instead of 'weights' which only gives part of the parameters.
Using 'output' which is not an attribute for this purpose.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that stores layer names and the count of their weights if the layer has weights.

TensorFlow
weights_count = {layer.[1]: len(layer.[2]) for layer in model.layers if layer.[3]
Drag options to blanks, or click blank then click option'
Aname
Bweights
Dhas_weights
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'bias' or 'output' instead of 'weights'.
Not checking if the layer has weights before counting.