【问题标题】:AttributeError: module 'tensorflow.contrib.slim' has no attribute 'nets'AttributeError:模块“tensorflow.contrib.slim”没有属性“nets”
【发布时间】:2017-04-18 20:16:06
【问题描述】:

我想使用tf-slim 中的内置resnet 进行快速实验。我是按照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
我该如何解决这个问题?

【问题讨论】:

    标签: python tensorflow tf-slim


    【解决方案1】:

    像这样导入:

    from tensorflow.contrib.slim.nets import resnet_v1
    
    slim = tf.contrib.slim
    

    【讨论】:

      猜你喜欢
      • 2018-04-14
      • 2019-02-18
      • 1970-01-01
      • 2020-01-01
      • 2019-07-20
      • 2021-11-05
      • 2021-11-04
      • 2021-02-23
      相关资源
      最近更新 更多