吴裕雄--天生自然TensorFlow2教程:Broadcasting
Broadcasting可以理解成把维度分成大维度和小维度,小维度较为具体,大维度更加抽象。也就是小维度针对某个示例,然后让这个示例通用语大维度。

import tensorflow as tf x = tf.random.normal([4,32,32,3])
x.shape
(x+tf.random.normal([3])).shape
(x+tf.random.normal([32,32,1])).shape
(x+tf.random.normal([4,1,1,1])).shape
try:
(x+tf.random.normal([1,4,1,1])).shape
except Exception as e:
print(e)
(x+tf.random.normal([4,1,1,1])).shape
b = tf.broadcast_to(tf.random.normal([4,1,1,1]),[4,32,32,3])
b.shape
a = tf.ones([3,4])
a.shape
a1 = tf.broadcast_to(a,[2,3,4])
a1.shape
a2 = tf.expand_dims(a,axis=0) # 0前插入一维
a2.shape
a2 = tf.tile(a2,[2,1,1]) # 复制一维2次,复制二、三维1次
a2.shape
吴裕雄--天生自然TensorFlow2教程:Broadcasting的更多相关文章
- 吴裕雄--天生自然TensorFlow2教程:手写数字问题实战
import tensorflow as tf from tensorflow import keras from keras import Sequential,datasets, layers, ...
- 吴裕雄--天生自然TensorFlow2教程:函数优化实战
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D def himme ...
- 吴裕雄--天生自然TensorFlow2教程:反向传播算法
- 吴裕雄--天生自然TensorFlow2教程:链式法则
import tensorflow as tf x = tf.constant(1.) w1 = tf.constant(2.) b1 = tf.constant(1.) w2 = tf.consta ...
- 吴裕雄--天生自然TensorFlow2教程:多输出感知机及其梯度
import tensorflow as tf x = tf.random.normal([2, 4]) w = tf.random.normal([4, 3]) b = tf.zeros([3]) ...
- 吴裕雄--天生自然TensorFlow2教程:单输出感知机及其梯度
import tensorflow as tf x = tf.random.normal([1, 3]) w = tf.ones([3, 1]) b = tf.ones([1]) y = tf.con ...
- 吴裕雄--天生自然TensorFlow2教程:损失函数及其梯度
import tensorflow as tf x = tf.random.normal([2, 4]) w = tf.random.normal([4, 3]) b = tf.zeros([3]) ...
- 吴裕雄--天生自然TensorFlow2教程:激活函数及其梯度
import tensorflow as tf a = tf.linspace(-10., 10., 10) a with tf.GradientTape() as tape: tape.watch( ...
- 吴裕雄--天生自然TensorFlow2教程:梯度下降简介
import tensorflow as tf w = tf.constant(1.) x = tf.constant(2.) y = x * w with tf.GradientTape() as ...
随机推荐
- 访问eureka 显示xml
两种解决方式: 方式一:(我是通过此方式解决的) 一个博客“http://blog.csdn.net/l5764773160/article/details/77483730”,他的解决方案是: 将项 ...
- Java 布尔运算
章节 Java 基础 Java 简介 Java 环境搭建 Java 基本语法 Java 注释 Java 变量 Java 数据类型 Java 字符串 Java 类型转换 Java 运算符 Java 字符 ...
- LocalDateTime整合到SpringBoot + MyBatis中
啥也不说先贴两个代码: 一:MVC层配置 @Configuration public class JacksonConfig { /** 默认日期时间格式 */ public static final ...
- Elasticsearch常用的设置
action.destructive_requires_name: true 用于设置删除只限于特定名称指向的数据, 而不允许通过指定 _all来删除所有索引
- tornado5.0+async+await
不使用数据库的情况下实现异步 使用gen.sleep()模拟阻塞 使用gen.sleep(time) 而不是time.sleep(),time.sleep()阻塞整个进程,看gen.sleep()源码 ...
- [题解] LuoguP6075 [JSOI2015]子集选取
传送门 ps: 下面\(n\)和\(k\)好像和题目里的写反了...将就着看吧\(qwq\) 暴力打个表答案就出来了? 先写个结论,答案就是\(2^{nk}\). 为啥呢? 首先你需要知道,因为一个集 ...
- vue学习(一)ES6常用语法
1 ES6常用语法 1.1 变量提升 例① # 变量提升 <div id="app"> </div> <script> console.log( ...
- POJ 3368:Frequent values
Frequent values Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 14764 Accepted: 5361 ...
- 使用模拟器调试react-native步骤(安卓机)
1.在cmd界面搭建react-native 环境: 可参考https://reactnative.cn/docs/0.51/getting-started.html#content (1)npm i ...
- sql server 日期时间数据类型
1.日期和时间数据类型 (1)在sqlserver 2008之前,SQL Server 支持datetime 和 smalldatetime 两种日期时间数据类型.这两种数据类型日期和时间是不可分割的 ...