1

Creating error, but I can find what string they are referring to. line 132: callbacks=[tensorboard, checkpoint],

filepath = "LSTM_Final-{epoch:02d}" # unique file name that will include the epoch and the validation acc for that epoch
checkpoint = ModelCheckpoint("models\\{}.model".format(filepath, monitor='val_acc', verbose=1, save_best_only=True, mode='max')) # saves only the best ones

# Train model
history = model.fit(
    np.array(train_x), np.array(train_y),
    batch_size=BATCH_SIZE,
    epochs=EPOCHS,
    validation_data=(np.array(validation_x), np.array(validation_y)),
    callbacks=[tensorboard, checkpoint],
)
4
  • tensorboard = TensorBoard(log_dir="logs\\{}".format(NAME)) Commented Mar 16, 2020 at 23:32
  • post full error message. Commented Mar 18, 2020 at 0:25
  • NAME = f"mylog" Commented Mar 18, 2020 at 0:39
  • that's clearly not helpful. But try using val_acc instead of val_loss. Commented Mar 18, 2020 at 1:05

2 Answers 2

1

You didn't provide the code for ModelCheckpoint() but I'm going to assume that it takes a few parameters.

Edit: OP commented that it's from keras.callbacks.callbacks.ModelCheckpoint(). The documentaiton says this should fix it.

Note from documentation: filepath can contain named formatting options, which will be filled with the values of epoch and keys in logs (passed in on_epoch_end).

filepath = "LSTM_Final-{epoch:02d}-{value_acc:.2f}"
checkpoint = ModelCheckpoint(filepath, monitor='val_acc', verbose=1, save_best_only=True, mode='max')
Sign up to request clarification or add additional context in comments.

9 Comments

from my research the filepath string is used in format() and doesn't need an f for f-string
@mystack you're not calling format on "LSTM_Final-{epoch:02d}".
@mystack what is this line doing? checkpoint = ModelCheckpoint("models\\{}.model".format(filepath, monitor='val_acc', verbose=1, save_best_only=True, mode='max'))? What do you want the first parameter to look like?
It creates a file in folder models called LSTM_Final-(the # of the epic that it is).model Is that what you were asking of?
@mystack okay, I think I understand the issue. Updated.
|
0

The problem was that the data is labeled and the code will only accept unlabeled data. Unfortunately this was not indicated well by the error log.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.