【发布时间】:2017-05-25 22:08:46
【问题描述】:
我正在尝试使用 TF 1.1.0 实现 VGGnet,使用提供的 MNIST CNN 教程here。我收到的错误消息是:
AttributeError: 'SKCompat' object has no attribute 'evaluate'
我的这部分代码抛出了 AttributeError:
#create estimator
vggnet_classifier = learn.SKCompat(learn.Estimator(model_fn=vggnet_model, model_dir= "/tmp/vgg_net"))
# Set up logging for predictions
tensors_to_log = {"probabilities": "softmax_tensor"}
logging_hook = tf.train.LoggingTensorHook(tensors=tensors_to_log, every_n_iter=100)
#train model
vggnet_classifier.fit(
x=X_train,
y=y_train,
batch_size=100,
steps=2,
monitors=[logging_hook])
# Configure the accuracy metric for evaluation
metrics = {
"accuracy":
learn.MetricSpec(metric_fn=tf.metrics.accuracy, prediction_key="classes"),}
# Evaluate the model and print results
eval_results = vggnet_classifier.evaluate(x=X_val, y=y_val, metrics=metrics)
print(eval_results)
由于弃用警告,我最初在 learn.Estimator 周围添加了 SKCompat() 包装器,但我似乎找不到任何有关如何使用包装后的估计器来评估模型的信息。
【问题讨论】:
标签: python python-3.x tensorflow deep-learning