I receive the following error in in Pyhotn 3 and TF 2.0.
"ValueError: You tried to call count_params on digits, but the layer isn't built. You can build it manually via: digits.build(batch_input_shape)." at line new_model.summary().
what is the problem and how to solve it?
inputs = keras.Input(shape=(784,), name='digits')
x = layers.Dense(64, activation='relu', name='dense_1')(inputs)
x = layers.Dense(64, activation='relu', name='dense_2')(x)
outputs = layers.Dense(10, activation='softmax', name='predictions')(x)
model = keras.Model(inputs=inputs, outputs=outputs, name='3_layer_mlp')
model.summary()
(x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data()
x_train = x_train.reshape(60000, 784).astype('float32') / 255
x_test = x_test.reshape(10000, 784).astype('float32') / 255
model.compile(loss='sparse_categorical_crossentropy',
optimizer=keras.optimizers.RMSprop(),
metrics=['accuracy'])
history = model.fit(x_train, y_train,
batch_size=64,
epochs=2)
model.save('saved_model', save_format='tf')
new_model = keras.models.load_model('saved_model')
new_model.summary()