学习笔记(二)——张量,操作,常用层,建模方式

这篇学习笔记介绍了TensorFlow中的核心概念,包括张量的概念(类似JS的变量),张量的操作(参照JS的math方法),常用的神经网络层(如tf.nn和tf.keras.layers),以及三种模型构建方式:sequential、functional和subclassing模型,并通过与JavaScript的类比帮助理解。
摘要由CSDN通过智能技术生成

语言都是相通的,学习过程中,可以和我的大前端js来比较比较。

1 张量

import tensorflow as tf
#创建张量
mammal = tf.Variable('Elephant',tf.string)
tf.print(tf.rank(mammal))

mystr = tf.Variable(['hello'],tf.string)
tf.print(tf.rank(mystr))

mymat = tf.Variable([[7],[11]],tf.int16)
tf.print(tf.rank(mymat))

tf.constant([1,2,3],dtype=tf.int16)

其实就是相当于js的变量

var a = 1;
console.log(a)

1 操作

#操作
#tf.strings
tf.strings.bytes_split('hello')
tf.strings.to_hash_bucket(['hello','world'],num_buckets=10)

#tf.debugging
a = tf.random.uniform((10,10))
tf.debugging.assert_equal(x=a.shape,y=(10,10))

#tf.random
a = tf.random.uniform(shape=(10,5),minval=0
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值