0
我做了一个TensorFlow估计具有一定的借鉴作用:TensorFlow:是否适合以相当于拟合1大增量的小步增量?
estimator = tf.contrib.learn.Estimator(
model_fn=_model_fn_for_penguin_model,
model_dir=/tmp/penguin_classification,
config=tf.contrib.learn.RunConfig(
save_summary_steps=5))
然后叫estimator.fit
训练模型。我注意到,如果我在小步增量(不批量大小)像10列车上,OptimizeLoss指标收敛:
step_increment = 10
for step in xrange(0, 1e6, step_increment):
# Train for certain increment of steps.
estimator.fit(
input_fn=_input_fn_for_train, steps=step_increment)
我可以告诉基于TensorBoard(奇怪的是,损失我的评价数据集实际上增加...但可能是不相关的问题)
但是,如果我用一个更大的一步增量大小如200,损失上下波动:
step_increment = 200
for step in xrange(0, 1e6, step_increment):
# Train for certain increment of steps.
estimator.fit(
input_fn=_input_fn_for_train, steps=step_increment)
这让我困惑,因为在我看来,上面的2个代码片段应该在一天结束时做同样的事情:训练一百万步的模型。情况并非如此吗?
我不相信这是源于随机播种 - 我可以一贯地重现这种行为。
这里是输入功能。
def make_input_fn(mode):
def internal_input_fn():
include_target = mode != tf.contrib.learn.ModeKeys.INFER
feature_spec = tf.contrib.layers.create_feature_spec_for_parsing(
feature_columns=_get_feature_columns(
include_target_column=include_target))
feature_map = tf.contrib.learn.read_batch_features(
batch_size=100,
features=feature_spec,
file_pattern=os.path.join("/tmp", mode + ".tfrecord"),
queue_capacity=250,
randomize_input=True,
reader=tf.TFRecordReader)
target = feature_map.pop() if include_target else None
return feature_map, target
return internal_input_fn
我认为我的输入函数(发布)确实做了随机化。也许随机化不适用于'tf.TFRecordReader'? – dangerChihuahua007
随机化适用于记录阅读器,但也许你没有足够的随机性。 –