tf.Tensor

概述

张量

解释参见:
https://www.malaoshi.top/show_1EF4ZcUuSEBb.html

属性

shape

形状

dtype

所有元素的类型

常用方法

numpy()

返回张量的值

例子

import tensorflow as tf

a = tf.constant([1.0, 2.0])
print(a)
print(a.shape)
print(a.dtype)
print(a.numpy())

执行结果:

tf.Tensor([1. 2.], shape=(2,), dtype=float32)
(2,)
<dtype: 'float32'>
[1. 2.]

原文出处:/show_1EF4ZcVklrdc.html