我正在使用Keras加载mnist数据并进行训练,同时保存了keras数据。我收到以下错误。完整的代码在这里。...
model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Flatten())
model.add(tf.keras.layers.Dense(128, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(128, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(10, activation=tf.nn.softmax))
KERAS_MODEL_NAME = 'keras.hdf5'
tf.keras.models.save_model(model, KERAS_MODEL_NAME)
new_model=tf.keras.models.load_model(KERAS_MODEL_NAME)
predictions = new_model.predict([x_test])
getting following error
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-1-be5d5fd55018> in <module>
29 #tf.keras.models.save_model(model, KERAS_MODEL_NAME)
30 tf.keras.models.save_model(model, KERAS_MODEL_NAME)
---> 31 new_model=tf.keras.models.load_model(KERAS_MODEL_NAME)
32 predictions = new_model.predict([x_test])
AttributeError: 'Sequential' object has no attribute 'output_names'
我还尝试了给定here的所有选项,但是在这里没有用。.