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. IEC 60958 && IEC 61937

    IEC 60958 IEC 60958是一种传递数字音频的接口规范,相比I2S,IEC60958通过一根线同时传递时钟信号和数据信号.IEC 60958用来传递两channel,16/20/24bit ...

  2. P &R 12

    Floorplan包含: IO floorplan: 涉及板级设计.封装设计的交互,接口协议(timing相关),对一些高速接口需要做特殊考虑(如信号完整性等). Power plan:芯片的电源和低 ...

  3. java.util.Properties类,保存时保留注释及格式不变

    原文地址:http://blog.csdn.net/benbenxiongyuan/article/details/53006097 参考地址:http://www.iteye.com/topic/1 ...

  4. 【WPF学习】第十四章 事件路由

    由上一章可知,WPF中的许多控件都是内容控件,而内容控件可包含任何类型以及大量的嵌套内容.例如,可构建包含图形的按钮,创建混合了文本和图片内容的标签,或者为了实现滚动或折叠的显示效果而在特定容器中放置 ...

  5. JS数组删除

    --------------let items=['a','1',0,2,100,null,NaN,undefined,]; -------------要求以上数据执行后输出['1',0,2,100] ...

  6. mysql 查询结果保存为表

    mysql> create table stunow select distinct 学号,姓名,密码 from stu12to15 ;

  7. 占位符 css

    == 普通的英文半角空格   ==   ==   == no-break space (普通的英文半角空格但不换行)   == 中文全角空格 (一个中文宽度)   ==   == en空格 (半个中文 ...

  8. 在IDEA离线安装lombok插件

    1.打开,找到自己IDEA版本,idea http://plugins.jetbrains.com/plugin/6317-lombok/versions 2.下载,导入安装

  9. Tiny-shell

    Tiny-shell:一个模仿bash的极简shell (一) 概述 通过构建一个简单的shell,能够对shell的工作原理进行一些了解.主要有: 重定向 流水线 前台信号处理 进程组 后台进程 作 ...

  10. Android学习09

    SharedPreferences SharedPreferences,是一种轻量级的数据存储方式,采用Key/value的方式 进行映射,Sp通常用于记录一些参数配置.行为标记等! 1.获得mSha ...