4.6k 4 分钟

# Lenet5 网络模型 import torchfrom torch import nnfrom torch.nn import functional as Fclass Lenet5(nn.Module): """ for cifar10 dataset. """ def __init__(self): super(Lenet5, self).__init__() self.conv_unit = nn.Sequential( # x: [b, 3, 32, 32] => [b, 16, ] nn.Conv2d(3,...
8.1k 7 分钟

# 什么是卷积神经网络 注意,是把一个 kernel 里的三个窗口做完运算后生成的三个值累加起来,得到新的 feature map。对于下一层有 16 个通道,则是把一个 kernel 里的 16 个窗口做完运算后生成的 16 个值累加起来,算作一个新的 feature。 # 代码示例 # 类风格 API # 函数风格 API ‍ # 池化层和采样 # 池化层 最大池化:取 kernel 里的最大值 平均池化:取 kernel 里的平均值 # 上采样 将特征图放大 # BatchNorm # Image Normalization 这里的均值和方差是统计了数百万张图片在 RGB...
1k 1 分钟

# 过拟合问题 # 欠拟合 当 train acc. is bad 并且 test acc. is bad as well 可以认为是欠拟合,但现在神经网络的学习能力太强了,所以这种问题不常见 # 过拟合 当 train loss and acc. is much better 但是 test acc. is worse 就是过拟合,也就是泛化能力 Generalization Performance 不够,所以目前的主要问题就是如何缓解过拟合问题 # 训练 / 验证 / 测试集的划分 对于测试集,我们不能做任何事情,所以通常来说将训练集划分为训练集和验证集 #...
9.7k 9 分钟

# Logistic Regression # Q1 why not maximize accuracy? acc.=∑I(predi==yi)len(Y)acc.=\frac{\sum I\left(pred_{i}==y_{i}\right)}{len\left(Y\right)} acc.=len(Y)∑I(predi​==yi​)​ 如果最小化 accuracy,会造成 gradient = 0 的现象。因为用 sigmoid 做激活函数,小于 0.5 判断为 0,大于 0.5 判断为 1,如果参数 w 从 0.4 提升到 0.45,但因为还是小于...
3.3k 3 分钟

# 常见函数的梯度 # 基础 导数 derivative 偏微分 partial derivative 梯度 gradient ∇f=(∂f∂x1;∂f∂x2;…;∂f∂xn)\nabla f=\left(\frac{\partial f}{\partial x_1};\frac{\partial f}{\partial x_2};\ldots;\frac{\partial f}{\partial x_{n}}\right) ∇f=(∂x1​∂f​;∂x2​∂f​;…;∂xn​∂f​) # 常见激活函数及其梯度 # Sigmoid /...
1.9k 2 分钟

# Broadcasting 自动扩展维度语法糖 # 关键点 A 和 B 张量做 broadcasting,如果 B 前面缺失一个维度,则自动在前面插入一个维度 插入的维度大小为 1,接下来会自动将其维度大小为 1 的维度扩张到和 A 张量相同位置维度一样的大小 例子:Bias [32, 1, 1] -> [1, 32, 1, 1] -> [4, 32, 14, 14] 所以 broadcasting 的本质就是 unsqueeze + expand # 案例 for actual demanding [class, students,...
2k 2 分钟

# 基本数据类型 # 基本数据类型 ​​ # 常用类型 FloatTensor DoubleTensor ByteTensor IntTensor LongTensor # 标量 ​ ​​ 常用来表示 Loss # 一维张量 ​ ​​​ 有三种方式: 给定内容生成一维张量 给定维度大小生成一维张量 从 np 中得到一维张量 常用于 Bias 神经元的偏置,和 Linear Input # 二维张量 dim、size () 和 shape 的区分。对于一个维度为 [2, 2] 这样的张量,它的: dim 为 2,也就是数学上的 Rank,秩; size () 和 shape...
1.7k 2 分钟

# 常见词汇 # Border 国界;边界 cross the border 过了边界 You should never try to illegally cross the board into a different country. # Declaration card /form 海关申报书 Most countries require you to fill in a declaration card. # Arrival card /form 入境卡 For China, foreigners just have to fill in a small arrival card. #...
3.9k 4 分钟

# 常见词汇 # Terminal 航站楼 I need to go to terminal 1. # Airline 航空公司 What airline are you flying with? I'm flying with Air China / Air Canada. # International flight 国际航班 It's an international flight, so it should be in terminal 3. # Domestic flight 国内航班 I'm just taking a domestic flight. #...
571 1 分钟

# 临摹相同尺寸草图图片 在草图编辑状态,点击「 工具 」->「 草图工具 」->「 草图图片 」即可导入草图,然后根据尺寸确定缩放关系,将草图移至原点即可 # 尺寸链 水平尺寸链或竖直尺寸链,先点击构造线确定原点,再点击其他线确定尺寸。 右击添加到尺寸链,可以再次打开上次的尺寸链继续添加 # 尺寸圆弧条件修改 先点击圆弧尺寸,左侧属性栏选择第二栏「 引线 」,在下方修改圆弧条件即可 # 鼠标笔势由 4 笔势改为 8 笔势 点击「 工具 」-> 「 自定义 」->「 鼠标笔势 」即可切换 4 笔势或 8...