float共32bit:1bit符号位,8bit指数位,23bit底数位。如下表示:
S E8 M23
浮点与二进制转换公式如下:
\(Y = (-1)^{s} \times m \times 2^{e},其中m = 1.M23,e = E8 - 127\)
以浮点数12.5,举例说明:
\(12.5 \\
=> 1100.1 \\
=> 1.1001 \times 2^{3} \\
=> E8 = 3 + 127 = 130 = 1000 0010 \\
M23= 1001 0000 0000 0000 000 \\
=> 0 1000 0010 1001 0000 0000 0000 000\)
对应表示如下:
Format | Bits | Sign | Exponent | Fraction |
---|---|---|---|---|
FP32 | 32 | 1 | 8 | 23 |
FP16 | 16 | 1 | 5 | 10 |
BF16 | 16 | 1 | 8 | 7 |
RNN:Recurrent Neural Networks,循环神经网络,能够应用于空间或时间先后相关的场景,比如文字解析、语音识别。
RNN模型结构简单描述,如下图:
其中X0、X1、……、Xt,可以理解成多个输入,或者对单个输入拆分成的多个输入,比如一张图片的多个字符拆分、语音的拆分等等;h0、h1、…、ht可以理解成多个输出,通常也可能最终被concat到一起,做为一个输入。
上图是单向的,也就是h1会受h0的影响,h2会受h1、h0的影响,…,但反过来不会。RNN网络也会有双向的情况,使前后互相影响。
文本 | 文件 | 其他 |
---|---|---|
Command-C 拷贝 Command-V 粘贴 Command-X 剪切 Command-Z 撤销 Command-A 全选 command-S 保存 Command-F 查找 |
Command <- 删除文件 Command c 拷贝文件 Command v 粘贴文件 Command option v 移动文件 |
Command Shift 4 选取截图 Command Shift 3 全屏截图 Control 空格 切换输入法 |
SSD中定义PriorBox,预选框。
layer {
name: "conv13_mbox_priorbox"
type: "PriorBox"
bottom: "conv13"
bottom: "data"
top: "conv13_mbox_priorbox"
prior_box_param {
min_size: 105.0
max_size: 150.0
aspect_ratio: 2.0
aspect_ratio: 3.0
flip: true
clip: false
variance: 0.1
variance: 0.1
variance: 0.2
variance: 0.2
offset: 0.5
}
Deconvolution是Convolution的逆操作。Convolution是将大尺寸feature map转换成小尺寸feature map,而Deconvolution是将小feature map转换成大feature map。两者shape计算过程对比:
# Convolution:
kernel = ic * oc * kh * kw
on = in
oh = (ih + 2 * pad_h - kh)/sh + 1
ow = (iw + 2 * pad_w - kw)/sw + 1
# Deconvolution:
kernel = ic * oc * kh * kw
on = in
oh = (ih - 1) * sh + kh - 2 * pad_h
ow = (iw - 1) * sw + kw - 2 * pad_w
int8_value
的weight范围是[-127, 127]
,zero_point
为0;activations/inputs
范围是[-128, 127]
,zero_point
范围是[-128, 127]
threshold理解为某个tensor的元素最大值,则:
\(Y = F(X) (float运算) \\
=> y = f(x),其中 x = X \times \frac{128}{threshold_x}, Y = y \times \frac{threshold_y}{128} (int8运算)\)
per-axis
,表示某个维度每一片都有一个scale和zero_point
,比如per-channel
表示每个channel都有一个scale和zero_point
per-tensor
,表示整个tensor用一个scale和zero_point