Tensorflow2.0报错:ProfilerNotRunningError: Cannot stop profiling. No profiler is running.
这个是TensorFlow的一个在win下的bug。 linux应该没这个问题。
解决方法:
将logdir用os.path.join包装一下
logdir = os.path.join(‘logs’, current_time) # 这样
logdir = ‘./logs/’ + current_time # 不要这样
实例错误显示:
logdir = './cnn_selu_callbacks' #在window下运行会出错
if not os.path.exists(logdir):
os.mkdir(logdir)
output_model_file = os.path.join(logdir,
"fashion_mnist_model.h5")
callbacks = [
keras.callbacks.TensorBoard(log_dir=logdir),
keras.callbacks.ModelCheckpoint(output_model_file,
save_best_only = True),
keras.callbacks.EarlyStopping(patience=5, min_delta=1e-3),
]
history = model.fit(x_train_scaled, y_train, epochs=10,
validation_data=(x_valid_scaled, y_valid),
callbacks = callbacks)
按照上述描述包装logdir:
# 把这个路径用包装一下
logdir = os.path.join("cnn_selu_callbacks") #修改为os.path.join
if not os.path.exists(logdir):
os.mkdir(logdir)
output_model_file = os.path.join(logdir,
"fashion_mnist_model.h5")
callbacks = [
keras.callbacks.TensorBoard(log_dir=logdir),
keras.callbacks.ModelCheckpoint(output_model_file,
save_best_only = True),
keras.callbacks.EarlyStopping(patience=5, min_delta=1e-3),
]
history = model.fit(x_train_scaled, y_train, epochs=10,
validation_data=(x_valid_scaled, y_valid),
callbacks = callbacks)