Friday, 9 June 2023

saving a model I get: module 'tensorflow.python.saved_model.registration' has no attribute 'get_registered_name'

When I try to save my ternsorflow model I get this error message. What is the problem here and how do I fix it?

    model = tf.keras.models.Sequential()

    # define the neural network architecture
    model.add(
        tf.keras.layers.Dense(50, input_dim=hidden_dim, activation="relu")
    )
    model.add(tf.keras.layers.Dense(n_classes))

    k += 1
    model.compile(
        optimizer=tf.keras.optimizers.Adam(learning_rate=lr),
        loss=tf.keras.losses.BinaryCrossentropy(from_logits=True),
        metrics=["mse", "accuracy"],
    )

    history = model.fit(
        x_train,
        y_train,
        epochs=epochs,
        batch_size=batch_size,
        validation_data=(x_test, y_test),
        verbose=0,
    )

    folder = "model_mlp_lm"
    file = f"m{k}_model"
    os.makedirs(folder, exist_ok=True)
    path = f"{folder}/{file}"
    if os.path.isfile(path) is False:
        model.save(path)

module 'tensorflow.python.saved_model.registration' has no attribute 'get_registered_name'



from saving a model I get: module 'tensorflow.python.saved_model.registration' has no attribute 'get_registered_name'

No comments:

Post a Comment