tensorflow2.0基础(一)

# 数值类型 , 标量(维度为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

发布了11 篇原创文章 · 获赞 1 · 访问量 188

猜你喜欢

转载自blog.csdn.net/q5c521/article/details/105233658