0
学習プロセス中にいくつかのランダムサンプルの出力を予測するようモデルに頼んでみたいです。現在、私はtf.contrib.learn.monitors.EveryN
から派生したクラスを構築し、次のようにevery_n_step_end
を上書き:モデルのトレーニング中に予測結果のサンプルを印刷するにはどうすればよいですか?
def every_n_step_end(self, step, outputs):
# evaluate the model on the validation set
self._estimator.evaluate(
input_fn=input_fn_eval,
metrics=validation_metrics,
steps=None)
# generate some random samples
for _ in range(FLAGS.num_samples):
input_sample, output_sample, label = random.choice(validation_set)
prob = self._estimator.predict(input_fn=lambda: get_features(input_sample, output_sample))
print("{}:{}:{}:{}".format(input_sample, output_sample, prob[0, 0], label))
問題は、それが各反復である、predict
関数は、チェックポイントとなどからモデルを読み込むには、適切な方法か?