我正在跟踪Tensorflow CNN的演示代码,我遇到了这个错误,涉及到logging\u hookFile "Machine_Learning/CNN_model_creator.py", line 105, in main
hooks=[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]
)
我不完全理解记录_hook的目的,也不明白当它的值传递给hooks时,它为什么需要在一个列表中。感谢任何帮助。在