【问题标题】:Tensorflow version ''1.1.0' SKCompat AttributeErrorTensorflow 版本 ''1.1.0' SKCompat AttributeError
【发布时间】: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


    【解决方案1】:

    我想知道现在是否有任何优雅的解决方案。正如 OP 指出的那样,使用 SKCompat() 包装器可以避免警告,这似乎是将来要做的事情;但另一方面,evaluate() 函数会以这种方式中断。

    【讨论】:

      【解决方案2】:

      我忘了声明:

      loss = None
      train_op = None
      

      在我的 vggnet_model 函数中,这似乎是错误的根源。删除 learn.SKcompat() 会引发警告,但该模型现在训练良好且运行良好。

      【讨论】:

        猜你喜欢
        • 2018-02-11
        • 2018-02-24
        • 1970-01-01
        • 2019-08-02
        • 1970-01-01
        • 2018-09-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多