吴裕雄--天生自然TensorFlow2教程:填充与复制
import tensorflow as tf a = tf.reshape(tf.range(9), [3, 3])
a
tf.pad(a, [[0, 0], [0, 0]])
tf.pad(a, [[
1,
0,
], [0, 0]])
tf.pad(a, [[1, 1], [0, 0]])
tf.pad(a, [[1, 1], [1, 0]])
tf.pad(a, [[1, 1], [1, 1]])
a = tf.random.normal([4, 28, 28, 3])
a.shape
# 对图片的行和列padding两行
b = tf.pad(a, [[0, 0], [2, 2], [2, 2], [0, 0]])
b.shape
a = tf.reshape(tf.range(9), [3, 3])
a
# 1表示行不复制,2表示列复制为两倍
tf.tile(a, [1, 2])
tf.tile(a, [2, 1])
tf.tile(a, [2, 2])
aa = tf.expand_dims(a, axis=0)
aa
tf.tile(aa, [2, 1, 1])
# 不占用内存,性能更优
tf.broadcast_to(aa, [2, 3, 3])
吴裕雄--天生自然TensorFlow2教程:填充与复制的更多相关文章
- 吴裕雄--天生自然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 ...
随机推荐
- 吴裕雄 Bootstrap 前端框架开发——Bootstrap 按钮:按钮标签
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- 标准查询运算符---LINQ
Where 根据给定的谓词对序列进行过滤 Select 指定要包含一个对象或对象的一部分 SelectMany 一种查询类型,返回集合的集合.该方法将这些结果合并为一个单独的集合 Take 接受一个输 ...
- Deep Image Retrieval: Learning global representations for image search In ECCV, 2016学习笔记
- 论文地址:https://arxiv.org/abs/1604.01325 contribution is twofold: (i) we leverage a ranking framework ...
- 新闻网大数据实时分析可视化系统项目——17、Spark2.X分布式弹性数据集
1.三大弹性数据集介绍 1)概念 2)优缺点对比 2.Spark RDD概述与创建方式 1)概述 在集群背后,有一个非常重要的分布式数据架构,即弹性分布式数据集(resilientdistribute ...
- git下载安装、配置及idea初始化
安装 wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.19.0.tar.gz git 安装依赖 yum -y insta ...
- 013、Java中int类型转换byte
01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public ...
- 吴裕雄 Bootstrap 前端框架开发——Bootstrap 字体图标(Glyphicons):glyphicon glyphicon-chevron-right
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name ...
- ACM-最优配餐
题目描述: 最优配餐 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 栋栋最近开了一家餐饮连锁店,提供外卖服务.随着连锁店越来越多,怎么合理的给客户送餐成为了一个急需解决的问 ...
- 2020牛客寒假算法基础集训营4 I 匹配星星
https://ac.nowcoder.com/acm/contest/3005/I 又做麻烦了,悲催... 将所有星星按x坐标为第一关键字,z为第二关键字排好序 那么一个z=1的星星匹配的是x比它小 ...
- JuJu团队11月29号工作汇报
JuJu团队11月29号工作汇报 JuJu Scrum 团队成员 今日工作 剩余任务 困难 于达 生成所有mini batch, 支持不同batch_size 优化代码 熟悉julia 婷婷 ...