def lengthy_test(model, testrange=[5,10,20,40,80], epochs=100, verboose=True):
ts = datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
log_path = LOG_PATH_BASE + ts + "_-_" + model.name
tensorboard = TensorBoard(log_dir=log_path,
write_graph=False, #This eats a lot of space. Enable with caution!
#histogram_freq = 1,
write_images=True,
batch_size = model.batch_size,
write_grads=True)
model_saver = ModelCheckpoint(log_path + "/model.ckpt.{epoch:04d}.hdf5", monitor='loss', period=1)
callbacks = [tensorboard, TerminateOnNaN(), model_saver]
for i in testrange:
acc = test_model(model, sequence_length=i, verboose=verboose)
print("the accuracy for length {0} was: {1}%".format(i,acc))
train_model(model, epochs=epochs, callbacks=callbacks, verboose=verboose)
for i in testrange:
acc = test_model(model, sequence_length=i, verboose=verboose)
print("the accuracy for length {0} was: {1}%".format(i,acc))
return
评论列表
文章目录