2

我想使用内置的resnet进行tf-slim快速实验。我按照 github 中的README

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.
我该如何解决这个问题?

4

1 回答 1

0

像这样导入:

from tensorflow.contrib.slim.nets import resnet_v1

slim = tf.contrib.slim
于 2017-01-22T19:39:59.853 回答