【问题标题】:AttributeError: module 'tensorflow' has no attribute 'select'AttributeError:模块“张量流”没有属性“选择”
【发布时间】:2017-12-25 20:29:26
【问题描述】:

这是一个简单的深度学习程序:

import tensorflow as tf
import numpy as np

A = 3
B = tf.convert_to_tensor([1, 2, 3, 4])
C = tf.convert_to_tensor([1, 1, 1, 1])
D = tf.convert_to_tensor([0, 0, 0, 0])

with tf.Session() as sess:
    print(sess.run(tf.select(A > 1, 'A', 'B')))
    print(sess.run(tf.select(False, 'A', 'B')))
    print(sess.run(tf.select(B > 2, C, D)))

当我运行它时,出现以下错误:

AttributeError: 模块 'tensorflow' 没有属性 'select'。

那么,接下来我该怎么做?有什么函数可以替代 tf.select 吗?

【问题讨论】:

    标签: python-3.x select tensorflow deep-learning


    【解决方案1】:

    tf.select 自 v0.12 起已弃用,并在 v1.0 中重命名为 tf.where 以匹配 numpy 的命名。 release notes中提到过。

    【讨论】:

      猜你喜欢
      • 2020-06-09
      • 1970-01-01
      • 2018-09-25
      • 2020-01-04
      • 2018-04-01
      • 2020-04-29
      • 2018-04-29
      • 2019-12-28
      • 1970-01-01
      相关资源
      最近更新 更多