Python 从tf.estimator.estimator spec获取值
当PREDICT ModeKey传递给tf.estimator.estimator时,返回的estimator Spec对象是iterablePython 从tf.estimator.estimator spec获取值,python,tensorflow,Python,Tensorflow,当PREDICT ModeKey传递给tf.estimator.estimator时,返回的estimator Spec对象是iterable predictions = { 'class_ids': tf.argmax(input=logits, axis=1), 'logits': logits } if mode == tf.estimator.ModeKeys.PREDICT: return tf.estimator.EstimatorSpec(mode, predictions=p
predictions = { 'class_ids': tf.argmax(input=logits, axis=1), 'logits': logits }
if mode == tf.estimator.ModeKeys.PREDICT:
return tf.estimator.EstimatorSpec(mode, predictions=predictions)
那么
为每个这样的预测生成一行
....
{'class_ids': 1, 'logits': array([-32976400., -30171870.], dtype=float32)}
{'class_ids': 1, 'logits': array([-32958380., -30386898.], dtype=float32)}
{'class_ids': 1, 'logits': array([-32940332., -30601930.], dtype=float32)}
{'class_ids': 1, 'logits': array([-32922300., -30816956.], dtype=float32)}
....
我怎样才能让列车模式钥匙返回一些不可接受的东西?理想情况下,我希望在培训中的定义步骤打印使用的每个特征值和计算的logit。我回来了
if mode == tf.estimator.ModeKeys.TRAIN:
return tf.estimator.EstimatorSpec(
mode,
loss=loss,
predictions=predictions,
train_op=train_objective)
那么
prediction_results = classifier.train(input_fn=lambda: dataset_input_fn(
file_dataset_feed,
perform_shuffle=True,
repeat_count=100))
for x, each in enumerate(prediction_results):
print(each)
生产
TypeError: 'Estimator' object is not iterable
TypeError: 'Estimator' object is not iterable