tensorflow2.0基础(一)

本文深入讲解了TensorFlow的基础概念,包括数值类型、张量操作、字符串处理等关键内容,通过实例演示了如何创建和操作张量,以及字符串的常用处理方法。
部署运行你感兴趣的模型镜像
# 数值类型 , 标量(维度为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://blog.youkuaiyun.com/q5c521/article/details/105233743

您可能感兴趣的与本文相关的镜像

TensorFlow-v2.15

TensorFlow-v2.15

TensorFlow

TensorFlow 是由Google Brain 团队开发的开源机器学习框架,广泛应用于深度学习研究和生产环境。 它提供了一个灵活的平台,用于构建和训练各种机器学习模型

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值