吴裕雄--天生自然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 ...
随机推荐
- C# 控件缩写规范
标准控件缩写规范 类 型 前 缀 示 例 Adrotator adrt adrtTopAd BulletedList blst blstCity Button btn btnSubmit Calend ...
- C# 控制台应用程序从外部传参运行和调试
参考:/*十有三博客*/ 新建一个用于演示的控制台应用程序项目,然后在Program.cs的入口Main方法里编写如下代码 foreach (var arg in args) { Console.Wr ...
- Web服务器:Apache的安装使用
Apache我们很熟悉,已经用了不短时间的tomcat就是apache公司开发的,那么这款以公司命名的所谓的Web服务器Apache,又到底什么呢? 一.概念 Apache是一个静态的Web服务器,是 ...
- Golang的运算符-逻辑运算符
Golang的运算符-逻辑运算符 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.逻辑运算符概述 !: 非运算符,表示NOT(有种取反的意思),如"!ture" ...
- P1042 字符统计
P1042 字符统计 转跳点:
- HihoCoder第七周:完全背包问题
1043 : 完全背包 时间限制:20000ms 单点时限:1000ms 内存限制:256MB 描述 且说之前的故事里,小Hi和小Ho费劲心思终于拿到了茫茫多的奖券!而现在,终于到了小Ho领取奖励的时 ...
- 简述哲学Essay写作
哲学类essay写作对于中国留学生来说算是比较难的作业了,它不仅有结构要求,还注重逻辑的紧密性.很多同学都不知道该怎么下手.今天小编就给同学们分享哲学essay写作的结构.同学们可以尝试按照以下方法来 ...
- Elasticsearch 过滤
章节 Elasticsearch 基本概念 Elasticsearch 安装 Elasticsearch 使用集群 Elasticsearch 健康检查 Elasticsearch 列出索引 Elas ...
- PHP四种输出语句
//echo 深入理解echo ,echo是一个函数 //echo 功能:向浏览器输出一个或多个字符串; //echo 返回值:void 无返回值; echo "今天是个好天气"; ...
- list的泛型
更新记录 [1]2020.02.12-21:26 1.完善内容 正文 在学习list集合时,我看到书上写list的格式时 List<E> list = new ArrayList<& ...