kaldi nnet3

kaldi nnet3

nnet3 component

参考 :《Kaldi语音识别实战》P209

基于计算图构建网络结构

以component为标识的行定义了每个节点的类型和输入输出维度,以Component-node为标识的行定义了每个节点的输入。定义节点输入的方法被称为描述符(Descriptors),用于表示节点之间如何连接,默认情况下,直接取输入节点的输出作为输入。常用的描述符包括:

  • 节点名,这是最基本的描述符,即不做任何操作;
  • 拼接(Append),将给定描述符拼接在一起,维度相当于各描述符维度之和;
  • 求和(Sum),对给定描述符求和,要求各个描述符维度一致;
  • 常量(Const),不要求指定描述符,而是根据参数生成一个描述符,如Const(1.0,512)生成一个512维的单位矢量;
  • 缩放(Scale),对给定描述符的每一维进行缩放;
  • 偏移(Offset),对给定描述符在t轴或x轴上进行偏移;
  • 替换(Replace),用于将给定描述符的某个轴设为指定常量,例如,当有拼接时变(声学特征)和时不变(说话人特征)两组特征时,可以指定时不变特征的t轴为0(也就是不管什么时刻,说话人特征都是那100维固定向量)
  • 判断(IfDefined和Failover),用于根据不同的情况改变描述符的行为。

src/nnet3/nnet-descriptor.h :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<descriptor>  ::=   <node-name>      ;; node name of kInput or kComponent node.
<descriptor> ::= Append(<descriptor>, <descriptor> [, <descriptor> ... ] )
<descriptor> ::= Sum(<descriptor>, <descriptor>)
<descriptor> ::= Const(<value>, <dimension>) ;; e.g. Const(1.0, 512)
<descriptor> ::= Scale(<scale>, <descriptor>) ;; e.g. Scale(-1.0, tdnn2)
;; Failover or IfDefined might be useful for time t=-1 in a RNN, for instance.
<descriptor> ::= Failover(<descriptor>, <descriptor>) ;; 1st arg if computable, else 2nd
<descriptor> ::= IfDefined(<descriptor>) ;; the arg if defined, else zero.
<descriptor> ::= Offset(<descriptor>, <t-offset> [, <x-offset> ] ) ;; offsets are integers
;; Switch(...) is intended to be used in clockwork RNNs or similar schemes. It chooses
;; one argument based on the value of t (in the requested Index) modulo the number of
;; arguments
<descriptor> ::= Switch(<descriptor>, <descriptor> [, <descriptor> ...])
;; For use in clockwork RNNs or similar, Round() rounds the time-index t of the
;; requested Index to the next-lowest multiple of the integer <t-modulus>,
;; and evaluates the input argument for the resulting Index.
<descriptor> ::= Round(<descriptor>, <t-modulus>) ;; <t-modulus> is an integer
;; ReplaceIndex replaces some <variable-name> (t or x) in the requested Index
;; with a fixed integer <value>. E.g. might be useful when incorporating
;; iVectors; iVector would always have time-index t=0.
<descriptor> ::= ReplaceIndex(<descriptor>, <variable-name>, <value>)

component和component-node:

component 是类;

component-node 是类的实例

kaldi nnet3 写一个cnn:

kernel是用time-offsets和height-offsets设置得到的卷积核大小;

image-20221009190513492

kaldi nnet3写一个lstm

delay指的是进行几次循环

image-20221009190903142

image-20221009191218981