2017-05-25 148 views
0

我正在嘗試使用TF 1.1.0使用MNIST CNN教程提供的here來實現VGGnet。我收到的錯誤信息是:Tensorflow版本''1.1.0'SKCompat屬性錯誤

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的包裝由於棄用警告,但我可以」似乎找不到任何有關如何使用包裝估計器來評估模型的信息。

回答

0

我忘了聲明:

loss = None 
train_op = None 

在我vggnet_model功能,這似乎是錯誤的來源。刪除learn.SKcompat()拋出警告,但模型訓練良好,現在運行良好。

1

我不知道現在是否有優雅的解決方案。正如OP指出的那樣,使用SKCompat()包裝可以避免警告,並且這似乎是將來要做的事情;但另一方面,evaluate()函數就是這樣打破的。