在TensorFlow2.0中,“Tensor”(相对于“hazentensor”)有什么用处?

2024-09-29 21:28:27 发布

您现在位置:Python中文网/ 问答频道 /正文

在Tensorflow 2.0中,我们看到的主要“张量”实际上是EagerTensorstensorflow.python.framework.ops.EagerTensor更准确地说):

x = [[2.]]
m = tf.matmul(x, x)
type(m)
# returns tensorflow.python.framework.ops.EagerTensor

但是,在某些情况下,我们有符号Tensor对象(tensorflow.python.framework.ops.Tensor),如TF1.X所示。
例如,在keras中:

^{pr2}$

那么,这些符号在Tensorflow中的用法是什么呢

  • 在TF库内部:Keras至少使用了这些张量,但是它在其他地方(使用图,比如tf.功能,或tf.data.Dataset)? 在
  • 在API中:这些工具的最终用户是否有实际用途?在

Tags: 对象tftensorflowtype符号情况frameworkops
1条回答
网友
1楼 · 发布于 2024-09-29 21:28:27

In the TF library internals: Keras is at least using these tensors, but is it used at other places (which are using a graph, like tf.function, or tf.data.Dataset)?

嗯,是的。你的直觉是正确的。EagreTensor表示一个张量,该张量的值已在eager模式下计算,而{}表示图中可能尚未计算的张量节点。在

In the API: is there an actual use for end-users of these?

好吧,在某种程度上,我们一直在使用它们。我们创建keras模型,tf.data.Dataset但是,实际上,对于绝大多数用例,我们并不倾向于实例化或直接与Tensor对象本身交互,所以可能只想不必担心对象类型,而将其视为tensorflow内部的实现细节。在

相关问题 更多 >

    热门问题