# This script should train for one step and store the events file in model_dir:
model_dir = '/tmp/test'
shutil.rmtree(model_dir, ignore_errors=True)
estimator = tf.estimator.Estimator(
model_fn,
params=params,
model_dir=model_dir)
estimator.train(input_fn=make_input_fn(None), steps=1)
现在,如果我运行ls /tmp/test
,我会看到:
[quant@home tmp]$ ls test/
checkpoint events.out.tfevents.1529978068.376da96eeba4 graph.pbtxt model.ckpt-1.data-00000-of-00001 model.ckpt-1.index model.ckpt-1.meta
但是,如果我再次使用相同的内核(即在我的jupyter笔记本的相同实例中)运行相同的脚本,则会看到以下内容:
[quant@home tmp]$ ls test/
checkpoint graph.pbtxt model.ckpt-1.data-00000-of-00001 model.ckpt-1.index model.ckpt-1.meta
如果我更改目录名称(例如,更改为/tmp/test2
),则会再次打印事件文件,但这只是第一次。
很明显,某处捕获了一些状态,但是在哪里,如何完全重置估算器?
答案 0 :(得分:0)
我在Jupyter Notebook中也注意到了一些类似的行为。我正在使用Python类包装所有这些内容,但这仍然不能使其保持“干净”。
据我观察,事件文件创建后,只要不删除它,该文件仍会不断更新。删除后,将不会创建新的事件文件。
到目前为止,我有三种解决方案: 1.重新启动Jupyter会话,这有点不方便。 2.继续使用不同的目录。 3.保留事件文件(取决于您的情况)