吴裕雄--天生自然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 ... 
随机推荐
- iPad适配tabBarController
			iPad的tabBarController会在底部居中显示,根据不同的需求可能需要把tabBarItem均匀分布显示,具体修改如下 self.tabBar.itemPositioning = UITa ... 
- Essay写作:Conclusion部分写作辅导
			论文写到最后,一般正文就要以Conclusion结束了.Conclusion部分是一篇论文的正文结尾(the last section of a paper,last paragraph),主要是客观 ... 
- Centos 8下普通用户增加root权限
			问题: 解决: 重启Centos,使用root登陆: 
- Docker常用命令,Docker安装Nginx、Redis、Jenkins、tomcat、MySQL
			常用命令 拉取镜像:docker pull xxx启动镜像:docker run --name xxx 8080:8080 -d xxx查看容器:docker ps xxx 停止容器:docker s ... 
- VMware Workstation上新建虚拟机
			准备开始,话不多少,直接上图 点击创建新的虚拟机或者在文件上面选择新建虚拟机 点击完成就可以了 后面的步骤,是在公司电脑上完成的,新建了一个CentOs1,步骤同上,后面继续,然后需要更改配置,点击虚 ... 
- .Net 经典案例
			1.捕捉一只小可爱 using System; using System.Collections.Generic; using System.Linq; using System.Text; usin ... 
- (转)解决windows解决windows 7 部分程序图标显示不正常的问题
			刚解决计算机的管理选项打开出现问题,又发现系统里部分程序的快捷图标显示不出了, 曾在xp里也出现过同样的问题,常理推断,如果系统没有被病毒破坏那可能就是系统图标缓存出现问题 因此,双管齐下,一边检查系 ... 
- ssh: connect to host 120.79.26.164 port 22: Connection timed out报错问题
			要是使用阿里云服务器,出现这种错误,一般是端口没有打开.需要在阿里云控制台中设置端口后,即可使用ssh连接. 
- 【iOS】Swift4.0 GCD的使用笔记
			https://www.jianshu.com/p/47e45367e524 前言 在Swift4.0版本中GCD的常用方法还是有比较大的改动,这里做个简单的整理汇总. GCD的队列 队列是一种遵循先 ... 
- c#  多张图片合成一张图片
			using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System. ... 
