下面我创建了一个名为“op testing”的 tf 占位符:
self.center_words = tf.placeholder(tf.int32, shape=[self.batch_size], name='op testing')
print("Extracting the op", self.center_words.op)
当我打印 self.center_words.op 时,它会打印出如下结构:
op: "Placeholder"
attr {
key: "dtype"
value {
type: DT_INT32
}
}
attr {
key: "shape"
value {
shape {
dim {
size: 128
}
}
}
}
这适用于任何 TensorFlow 变量、函数输出等。这是什么.op?
最佳答案
TensorFlow 操作,也称为 Ops,是节点 对 Tensor 对象执行计算或使用 Tensor 对象执行计算。计算后,它们返回零或 更多的张量,可以被图中后面的其他操作使用。要创建操作, 你在 Python 中调用它的构造函数,它接受任何需要的 Tensor 参数 它的计算,称为输入,以及正确计算所需的任何其他信息 创建 Op,称为属性。 Python 构造函数返回一个句柄到 操作的输出(零个或多个 Tensor 对象),可以传递的就是这个输出 继续其他操作或Session.run
关于python - tensorflow "op"有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43290373/