AttributeError:'list'对象没有属性'shape'

时间:2018-02-24 07:23:24

标签: python tensorflow

我正在关注Tensorflow CNN上的演示代码,我遇到了涉及logging_hook的错误

  

文件“Machine_Learning / CNN_model_creator.py”,第105行,在main中       钩= [logging_hook]

以下是我的代码片段:

    #create the estimator
clf = tf.estimator.Estimator(model_fn=cnn_model_fn, model_dir="/model")

#set up logging for predictions
#log the values in the "softmax" tensor with label "probabilities"
tensors_to_log = {"probabilities":"softmax_tensor"}
logging_hook = tf.train.LoggingTensorHook(tensors=tensors_to_log, every_n_iter=50)

#train the model_f
train_input_fn = tf.estimator.inputs.numpy_input_fn(
    x={"x": train_data},
    y=train_labels,
    batch_size=100,
    num_epochs=None,
    shuffle=True
)
clf.train(
    input_fn=train_input_fn,
    steps=20000,
    hooks=[logging_hook]
)

我不完全理解logging_hook的目的,或者当它的值传递给hook时它为什么需要在列表中。任何帮助表示赞赏。

0 个答案:

没有答案