out = f(X@W + b)
out = relut(X@W + b)

import tensorflow as tf

x = tf.random.normal([4, 784])
net = tf.keras.layers.Dense(512)
out = net(x)
out.shape
net.kernel.shape, net.bias.shape
net = tf.keras.layers.Dense(10)
try:
net.bias
except Exception as e:
print(e)
net.build(input_shape=(None, 4))
net.kernel.shape, net.bias.shape
net.build(input_shape=(None, 20))
net.kernel.shape, net.bias.shape
net.build(input_shape=(2, 4))
net.kernel
from tensorflow import keras

x = tf.random.normal([2, 3])
model = keras.Sequential([
keras.layers.Dense(2, activation='relu'),
keras.layers.Dense(2, activation='relu'),
keras.layers.Dense(2)
])
model.build(input_shape=[None, 3])
model.summary()
# [w1,b1,w2,b2,w3,b3]
for p in model.trainable_variables:
print(p.name, p.shape)

吴裕雄--天生自然TensorFlow2教程:全连接层的更多相关文章

  1. 吴裕雄--天生自然TensorFlow2教程:合并与分割

    import tensorflow as tf # 6个班级的学生分数情况 a = tf.ones([4, 35, 8]) b = tf.ones([2, 35, 8]) c = tf.concat( ...

  2. 吴裕雄--天生自然TensorFlow2教程:手写数字问题实战

    import tensorflow as tf from tensorflow import keras from keras import Sequential,datasets, layers, ...

  3. 吴裕雄--天生自然TensorFlow2教程:函数优化实战

    import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D def himme ...

  4. 吴裕雄--天生自然TensorFlow2教程:反向传播算法

  5. 吴裕雄--天生自然TensorFlow2教程:链式法则

    import tensorflow as tf x = tf.constant(1.) w1 = tf.constant(2.) b1 = tf.constant(1.) w2 = tf.consta ...

  6. 吴裕雄--天生自然TensorFlow2教程:多输出感知机及其梯度

    import tensorflow as tf x = tf.random.normal([2, 4]) w = tf.random.normal([4, 3]) b = tf.zeros([3]) ...

  7. 吴裕雄--天生自然TensorFlow2教程:单输出感知机及其梯度

    import tensorflow as tf x = tf.random.normal([1, 3]) w = tf.ones([3, 1]) b = tf.ones([1]) y = tf.con ...

  8. 吴裕雄--天生自然TensorFlow2教程:损失函数及其梯度

    import tensorflow as tf x = tf.random.normal([2, 4]) w = tf.random.normal([4, 3]) b = tf.zeros([3]) ...

  9. 吴裕雄--天生自然TensorFlow2教程:激活函数及其梯度

    import tensorflow as tf a = tf.linspace(-10., 10., 10) a with tf.GradientTape() as tape: tape.watch( ...

随机推荐

  1. 数星星 Stars

    问题 A: 数星星 Stars 时间限制: 1 Sec  内存限制: 128 MB[命题人:admin] 题目描述 输入 第一行一个整数 N,表示星星的数目: 接下来 N 行给出每颗星星的坐标,坐标用 ...

  2. 深入delphi编程理解之消息(五)重写(override)dispatch、wndproc方法和Application.OnMessage事件

    dispatch.wndproc是VCL framework在TWinCtronl定义的虚拟方法,下面程序通过重写(override)这两函数拦截WM_LBUTTONDOWN消息,来与Applicat ...

  3. PHP 基础 自动类型转换之比较运算符

    <?php var_dump(' 123fg456'>=122); var_dump('some string' == 0); var_dump(123.0 == '123d456'); ...

  4. [采坑记录] OneDrive同步失败 不能自动上传 不能同步 不能登陆

    虽然OneDrive送的空间并不大 但是用来传文档什么的还是够了 但是国内各种不舒服 比如说登陆不上(其他的微软系应用解决方法同理) 原因是因为DNS污染的问题 默认电脑链接上网络之后 DNS是路由器 ...

  5. 分布式事务 --- BASE 理论

    部分图片总结出自参考资料 问题 : Base 理论为什么会被提出,动机是什么 Base 和 ACID 的区别与联系 概述 上一篇我们知道CAP 理论,也知道由于现实中网络等原因,分区容错性这一元素大多 ...

  6. python编程出现:expected an indented block错误。

    python编程出现:expected an indented block错误. expected an indented block翻译为:应为缩进块. python中没有像C语言使用{}来表示从属 ...

  7. MyBatis-Plus学习笔记(3):分页查询

    依赖配置可参考:MyBatis-Plus学习笔记(1):环境搭建以及基本的CRUD操作 分页配置 @Configuration public class PlusConfig { @Bean publ ...

  8. python opencv:图像的一些属性与操作

    img = cv.imread(xxx) # 常用的有以下属性 type(img) # img的数据类型 img.shape # img的结构 img.size # img的大小 img.dtype ...

  9. Linux 常用命令——解压缩文件

    tar 解包:tar xvf FileName.tar打包:tar cvf FileName.tar DirName(注:tar是打包,不是压缩!)———————————————.gz解压1:gunz ...

  10. PTA的Python练习题(十三)

    第4章-8 求分数序列前N项和 a=eval(input()) b=2 c=1 d=0 count=0 for i in range(a): count+=b/c d=b b=b+c c=d prin ...