I get this error message and I do not know how to correct my code to fix it.
module ‘tensorflow.python.saved_model.registration’ has no attribute ‘get_registered_name’
for trait_idx in range(full_targets.shape[1]):
# convert targets to one-hot encoding
targets = full_targets[:, trait_idx]
n_data = targets.shape[0]
expdata["trait"].extend([trait_labels[trait_idx]] * n_splits)
expdata["fold"].extend(np.arange(1, n_splits + 1))
skf = StratifiedKFold(n_splits=n_splits, shuffle=False)
k = -1
for train_index, test_index in skf.split(inputs, targets):
x_train, x_test = inputs[train_index], inputs[test_index]
y_train, y_test = targets[train_index], targets[test_index]
# converting to one-hot embedding
y_train = tf.keras.utils.to_categorical(y_train, num_classes=n_classes)
y_test = tf.keras.utils.to_categorical(y_test, num_classes=n_classes)
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)
expdata["acc"].append(100 * max(history.history["val_accuracy"]))
The error is on the line:
model.save(path)