2017-04-14 47 views
0

我想使用Tensorflow上DNNRegressor.fitValidationMonitor触发一次

ValidationMonitor但它被触发一次global_step = 1时。如何解决它?

every_n_step设置为1这样

validation_monitor = tf.contrib.learn.monitors.ValidationMonitor(
    test_dataset.data, 
    test_dataset.target, 
    every_n_steps=1) 

regressor = tf.contrib.learn.DNNRegressor(feature_columns=feature_columns, 
              hidden_units=[2], 
              model_dir="/home/maciej/tf-logs") 


regressor.fit(x=train_dataset.data, 
       y=train_dataset.target, 
       steps=1000, 
       monitors=[validation_monitor]) 

我得到在标准输出上有什么损失大约日志和有关验证的单一一个:

INFO:tensorflow:Saving dict for global step 201: global_step = 201, loss = 5.50003 
INFO:tensorflow:Validation (step 201): loss = 5.50003, global_step = 201 
INFO:tensorflow:global_step/sec: 96.1045 
INFO:tensorflow:loss = 6.3935, step = 301 
INFO:tensorflow:global_step/sec: 154.978 
INFO:tensorflow:loss = 4.77587, step = 401 
INFO:tensorflow:global_step/sec: 158.06 
INFO:tensorflow:loss = 3.72956, step = 501 
INFO:tensorflow:global_step/sec: 151.51 
INFO:tensorflow:loss = 3.04578, step = 601 

这也证实了tensorboard。

完整的代码和日志可以在这里找到: https://gist.github.com/maciejjaskowski/9f791e517f379c41d20cc72619909fe6

回答

0

正如Monitoring tutorial解释, ValidationMonitors依靠保存检查站。

考虑增加检查点与每x秒:

config=tf.contrib.learn.RunConfig(save_checkpoints_secs=5) 

这为我工作。