# 数值类型 , 标量(维度为0, Scalar) 向量(维度为1, Vector)
# 矩阵(Matrix) 统称为 张量(Tensor)
import tensorflow as tf
a = 1.2
aa = tf.constant(1.2)
type(a), type(aa), tf.is_tensor(aa)
(float, tensorflow.python.framework.ops.EagerTensor, True)
import tensorflow as tf
x = tf.constant([1, 2.,3.3])
x
<tf.Tensor: id=0, shape=(3,), dtype=float32, numpy=array([1. , 2. , 3.3], dtype=float32)>
import tensorflow as tf
x = tf.constant([1,2.,3.3])
x.numpy()
array([1. , 2. , 3.3], dtype=float32)
import tensorflow as tf
x = tf.constant([[1,2],[3,4]])
x, x.shape
(<tf.Tensor: id=3, shape=(2, 2), dtype=int32, numpy=
array([[1, 2],
[3, 4]])>, TensorShape([2, 2]))
#字符串类型 import tensorflow as tf
a = tf.constant('hello, Deep learning')
# tf.string模块中,提供有小写化lower(),拼接join(),长度length(),切分split()
tf.strings.lower(a) #小写化字符串
<tf.Tensor: id=8, shape=(), dtype=string, numpy=b'hello, Deep learning'>
接下来,tensorflow2.0基础(二)链接:https://www.cnblogs.com/yuanlibin/p/10002654.html