'How to find out version of Tensorflow used in HDF5 model
After I have saved a tensorflow
model in HDF5 format, how can I find out what version of tensorflow
it was built using?
Solution 1:[1]
The only thing I am aware of, when loading a model with the Keras
h5 format, is using model.to_json()
, but you will only get the Keras
version and backend
that were used:
import tensorflow as tf
import numpy as np
import json
model = tf.keras.Sequential([
tf.keras.layers.Input((256, 256, 3)),
tf.keras.layers.Conv2D(16, 3, padding='same', activation='relu', strides=1,
data_format='channels_last'),
tf.keras.layers.MaxPooling2D(),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(128, activation='relu'),
tf.keras.layers.Dropout(0.1),
tf.keras.layers.Dense(5, activation = 'softmax')
])
model.compile(loss='categorical_crossentropy', optimizer='adam')
model.save("test.h5", save_format='h5')
model = tf.keras.models.load_model('test.h5')
meta_data = json.loads(model.to_json())
print('keras_version:', meta_data['keras_version'], 'backend:', meta_data['backend'])
keras_version: 2.7.0 backend: tensorflow
So you would have to find out which Tensorflow
versions are compatible with this Keras
version, but should not be too difficult.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | AloneTogether |