【发布时间】:2019-01-25 16:51:31
【问题描述】:
假设在 Python 3.6 中,我在 tensorflow 中创建了两个占位符,并为每个占位符分配了一个名称。但是,我在 python 中使用相同的变量来存储每个张量。
import tensorflow as tf
tfs = tf.InteractiveSession()
p3 = tf.placeholder(tf.float32,name='left')
p3 = tf.placeholder(tf.float32,name='right')
我现在如何使用我分配的名称而不是变量名称来创建操作?
op1 = left * right
op2 = tf.multiply(left,right)
显然第一个不起作用,因为 python 没有名为“left”或“right”的变量,但似乎在第二种情况下我应该能够引用名称。如果没有,我为什么还要费心在张量上设置名称?
以防万一,我在 AWS Sagemaker conda_tensorflow_p36 上执行此操作
【问题讨论】:
标签: python python-3.x tensorflow