‘Tensor’ vs ‘tf.Tensor’ tensorflow

huangapple go评论50阅读模式
英文:

'Tensor' vs 'tf.Tensor' tensorflow

问题

Tensortf.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.

huangapple
  • 本文由 发表于 2023年2月6日 03:46:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/75355045.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定