【问题标题】:What is the best way to replace tensorflows placeholder for version 2.5.0 in google colabs python?在 google colabs python 中替换 2.5.0 版 tensorflows 占位符的最佳方法是什么?
【发布时间】:2021-05-31 19:08:34
【问题描述】:

我正在做一个项目,并试图用可行的东西替换这段代码。我正在使用 tensorflow 2.5.0 版,并面临以下错误。 AttributeError: 模块 'tensorflow' 没有属性 'placeholder'

for ui in range(num_unrollings):
    train_inputs.append(tf.placeholder(tf.float32, shape [batch_size,D],name='train_inputs_%d'%ui))
    train_outputs.append(tf.placeholder(tf.float32, shape=[batch_size,1], name = 'train_outputs_%d'%ui))

【问题讨论】:

    标签: python tensorflow google-colaboratory


    【解决方案1】:

    试试这个

    tf.compat.v1.placeholder(dtype, shape=None, name=None)
    

    官方documentation.

    【讨论】:

    • 谢谢!我没有意识到您可以将其他版本仅用于这样的一项任务!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-21
    • 2010-10-13
    • 2015-12-31
    • 1970-01-01
    • 2021-02-19
    • 2016-07-21
    • 2021-04-12
    相关资源
    最近更新 更多