2016-12-04 765 views
2

我想使用內置resnettf-slim進行快速實驗。我根據READMEgithub那樣:AttributeError:模塊'tensorflow.contrib.slim'沒有屬性'nets'

import tensorflow as tf 
import tensorflow.contrib.slim as slim 

resnet = tf.contrib.slim.nets.resnet_v1 

mnist = input_data.read_data_sets('MNIST_data', one_hot=True) 
x = tf.placeholder("float", shape=[None, 784]) 
y_ = tf.placeholder("float", shape=[None, 10]) 
pred = resnet.resnet_v1_50(x) 

cross_entropy = -tf.reduce_sum(y_ * tf.log(pred)) 

,但得到這樣的錯誤:AttributeError: module 'tensorflow.contrib.slim' has no attribute 'nets'。我已經安裝了最新版本的tensorflow-0.12.0
我該如何解決這個問題?

回答

0

進口這樣的:

from tensorflow.contrib.slim.nets import resnet_v1 

slim = tf.contrib.slim 
相關問題