英文:
'Tensor' vs 'tf.Tensor' tensorflow
问题
Tensor
和 tf.Tensor
是相同的,它们都表示一个张量对象。它们之间没有区别。宗旨,它们的显示方式略有不同,但它们都代表相同类型的张量。
英文:
I am exploring tensorflow internals, and sometimes when I print the value of a tensor, I will see data like the following: Tensor("x/PlaceholderWithDefault:0", shape=(), dtype=int32)
and other times I will see tf.Tensor(0, shape=(), dtype=int32)
.
What is the difference between these two expressions? Are Tensor
and tf.Tensor
different? And if not, why are they displayed differently (and seem to have different behavior)?
答案1
得分: 1
当你看到输出的Tensor("x/PlaceholderWithDefault:0", 形状=(), 数据类型=int32)时,它是TensorFlow的占位符对象。占位符是符号性张量,充当TensorFlow计算图的输入节点。当你创建一个占位符时,你定义了它的形状和数据类型,但没有提供任何值。
当你看到输出"tf.Tensor(0, 形状=(), 数据类型=int32)"时,它是一个TensorFlow张量对象。这个输出格式显示了张量的实际值,以及它的形状和数据类型。
英文:
When you see the output Tensor("x/PlaceholderWithDefault:0", shape=(), dtype=int32), it is the TensorFlow placeholder object. Placeholders are symbolic tensors that act as input nodes to the TensorFlow computational graph. When you create a placeholder, you define its shape and data type but do not provide any values for it.
When you see the output "tf.Tensor(0, shape=(), dtype=int32)", it is a TensorFlow tensor object. This output format shows the actual value of the tensor, along with its shape and data type.
Thank You.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论