kaldi-ctc src/ctcbin 底层命令学习

来源:互联网 发布:黑暗森林威慑 知乎 编辑:程序博客网 时间:2024/06/06 11:43
打开kaldi-ctc/src/ctcbin   里面有关于ctc操作的14条底层命令,接下来我们慢慢来学习以下:
1、./ctc-graph-info
     作用:print CTC decoding graph info  打印CTC解码图的信息
     用法:./ctc-graph-info <trans-model> <in-fst>
     例如:./ctc-graph-info exp/tree_mono/final.mdl CTC.fst  
                 输入两个参数为每个label的转移模型和该图的有限状态机fst
     其他参数:
     --config         :   读取配置文件(string类型,默认值为"")
     --help            :   打印用法信息(bool类型,默认值为false,即默认不打印)
     --print-args   :    打印命令行参数至标准错误流stderr (bool类型,默认值为true,用于产生log日志)
     --verbose      :    日志长短的等级(等级越高日志信息越多)(int类型,默认值为0)

2、./ctc-make-decoding-graph
     作用:Executes the last stages of creating a CTC decoding graph, given an LG.fst on the input
              给定LG.fst作为输入,得到最终的有限状态机CTC.fst.类似于传统方法中从LG.fst到HCLG.fst的过程。
     用法:./ctc-make-decoding-graph <in-fst> <out-fst>
     例如:fstrmsymbols data/lang/phones/disambig.int LG.fst | ctc-make-decoding - CTC.fst
              这个命令一般用在make_graph的脚本中。
     其他参数:
     --config         :   读取配置文件(string类型,默认值为"")
     --help            :   打印用法信息(bool类型,默认值为false,即默认不打印)
     --print-args   :    打印命令行参数至标准错误流stderr (bool类型,默认值为true,用于产生log日志)
     --verbose      :    日志长短的等级(等级越高日志信息越多)(int类型,默认值为0)

3、./nnet2-ctc-compute-from-egs
     作用:Does the neural net computation, taking as input the nnet-training examples(typically an archive with the extension .egs), ignoring the labels; it outputs as a matrix the result. Used mostly for debugging.
              把训练样本作为输入(一般是后缀为.egs的压缩文件),计算神经节点,输出为一个矩阵,通常用来调试。
     用法:nnet-ctc-compute-from-egs [options] <model-in> <egs-rspecifier> <feature-wspecifier>
     例如:nnet-ctc-compute-from-egs final.mdl egs.10.1.ark ark:-
              输入为初始模型,之前计算的.egs的输入特征数据,输出为计算得到的矩阵。
     其他参数:
     --config         :   读取配置文件(string类型,默认值为"")
     --help            :   打印用法信息(bool类型,默认值为false,即默认不打印)
     --print-args   :    打印命令行参数至标准错误流stderr (bool类型,默认值为true,用于产生log日志)
     --verbose      :    日志长短的等级(等级越高日志信息越多)(int类型,默认值为0)

4、./nnet2-ctc-compute-prob
     作用:Computes and prints the average log-prob per frame of the given data with a neural net. The input of this is the output of e.g. nnet-get-egs. Aside from the logging output, which goes to the standard error, this program prints the average log-prob per frame to the standard output. Also see nnet-logprob, which produces a matrix of log-probs for each utterance.
     计算并且打印给定数据的每帧在神经节点上的平均对数概率。输入是nnet-get-egs的输出,即分好的训练数据(包括特征和序列标签)。将每帧的平均对数概率打印至标准输出。与nnet-logprob一样,对每句话产生一个对数概率的矩阵。
     用法:nnet2-ctc-compute-prob [options] <model-in> <training-examples-in>
     例如:nnet2-ctc-compute-prob 1.nnet ark:valid.egs
     其他参数:
     --config         :   读取配置文件(string类型,默认值为"")
     --help            :   打印用法信息(bool类型,默认值为false,即默认不打印)
     --print-args   :    打印命令行参数至标准错误流stderr (bool类型,默认值为true,用于产生log日志)
     --verbose      :    日志长短的等级(等级越高日志信息越多)(int类型,默认值为0)

5、./nnet2-ctc-init-model
     作用:Initialize CTC transition-model object
     用法:nnet2-ctc-init-model [options] <tree-in> <topo-file> <nnet> <ctc-model-out>
     例如:./nnet2-ctc-init-model tree topo nnet dir/o.mdl
              初始化模型,在ctc/train.sh 的脚本中调用。
     options:
     --binary              :    输出为二进制模式(bool类型,默认值为true)
     其他参数:
     --config         :   读取配置文件(string类型,默认值为"")
     --help            :   打印用法信息(bool类型,默认值为false,即默认不打印)
     --print-args   :    打印命令行参数至标准错误流stderr (bool类型,默认值为true,用于产生log日志)
     --verbose      :    日志长短的等级(等级越高日志信息越多)(int类型,默认值为0)

6、./nnet2-ctc-latgen-faster
     作用:Generate lattices using neural net model. 计算完概率后使用该命令生成词图
     用法:./nnet-latgen-faster [options] <nnet-in> <fst-in|fsts-rspecifier> <feature-rspecifier> <lattice-wspecifier> [<words-wspecifier> [<alignments-wspecifier>]]
     options:
     --acoustic-scale                  :    声学似然函数的规整系数(float类型,默认值为1)
     --allow-partial                     :    如果为true,即使没有到达终止状态也产生输出(bool类型,默认值为true)
     --beam                               :  解码减枝,减枝值越大,速度越慢但是结果越准确(float类型,默认值为16)
     --beam-delta                       :    解码过程中的增量,这个参数和max-active的约束一起影响加速效果,数值越大结果越准确(float类型,默认值为0.5)
     --blank-threshold                :    如果blank的概率比该阈值大,则跳过该帧(加快计算速度),设置为1.0就舍弃跳过操作(float类型,默认值为0。98)
     --delta                                :  fst determinnzation的容忍度(Tolerance)(float类型,默认值为0。000976562)
     --determinize-lattice            :    如果为true,determinize the lattice(词图决策)(每个词序列只保留最佳的pdf序列)(bool类型,默认值为true)
     --frame-shift                        :    允许平移监督数据的时间值(包括ivector数据)-对增加的数据有效。(int类型,默认值为0)
     --frame-subsampling-factor  :    frame 二次采样因子(int类型,默认值为0)
     --hash-ratio                         :     在解码过程中设置,控制哈系行为(float类型,默认值为2)
     --lattice-beam                      :    词图生成beam。越大越慢,词图越深(float类型,默认值为10)
     --max-active                        :     解码器最大激活状态。越大越慢,但是越精确(int类型,默认值为2147483647)
     --max-mem                          :    determinization中最大的可能内存使用(int类型,默认值为50000000)
     --min-active                         :     解码过程中最小的激活状态(int类型,默认值为200)
     --minimize                            :  如果为true,在determinization后进行push和minimize(bool类型,默认值为false)
     --phone-determiniza             :    如果为true,在音素和词上座determinization的初始化(bool类型,默认值为true)
     --prune-interval            : Interval (in frames) at which to prune tokens (int, default = 25)
     --use-gpu                   : yes|no|optional|wait, only has effect if compiled with CUDA (string, default = "yes")
      --word-determinize          : If true, do a second pass of determinization on words only (see also           --phone-determinize) (bool, default = true)
      --word-symbol-table         : Symbol table for words [for debug output] (string, default = "") 
    其他参数:
     --config         :   读取配置文件(string类型,默认值为"")
     --help            :   打印用法信息(bool类型,默认值为false,即默认不打印)
     --print-args   :    打印命令行参数至标准错误流stderr (bool类型,默认值为true,用于产生log日志)
     --verbose      :    日志长短的等级(等级越高日志信息越多)(int类型,默认值为0)

7、./nnet2-ctc-train-simple
     作用:Train the neural network parameters with backprop and stochastic gradient descent using minibatches(CTC). Training examples would be produced by nnet-ctc-get-egs.
              使用反向传播和批量梯度下降对神经网络参数进行训练,,训练样本通过nnet-ctc-get-egs命令生成。
     用法:./nnet2-ctc-train-simple [options] <model-in> <training-examples-in> <model-out>
     例如:./nnet2-ctc-train-simple 1.nnet ark:1.egs 2.nnet
     Options:
         --binary : 输出为二进制模式 (bool类型, 默认值为true)
        --max-allow-frames : 每个minibatch允许的最大的帧数(int类型, 默认值为1000)
        --max-param-change : 每个minibatch允许的最大的改变的参数, measured in Frobenius norm over the entire model  (float类型, 默认值为 10)
        --minibatch-size :每个minibatch的训练样本数 (int类型, 默认值为128)
        --minibatches-per-phase : Number of minibatches to wait before printing training-set objective. (int, default = 50)
        --momentum : momentum constant to apply during training (help stabilize update). e.g. 0.9. Note: we automatically multiply the learning rate by (1-momenum) so that the 'effective' learning rate is the same as before (because momentum would normally increase the effective learning rate by 1/(1-momentum)) (float, default = 0)
        --srand : 随机数种子 (relevant if you have layers of type AffineComponentPreconditioned with l2-penalty != 0.0 (int类型, 默认值为0)
        --zero-stats : If true, zero occupation counts stored with the neural net (only affects mixing up). (bool, default = true)
     其他参数:
     --config         :   读取配置文件(string类型,默认值为"")
     --help            :   打印用法信息(bool类型,默认值为false,即默认不打印)
     --print-args   :    打印命令行参数至标准错误流stderr (bool类型,默认值为true,用于产生log日志)
     --verbose      :    日志长短的等级(等级越高日志信息越多)(int类型,默认值为0)

8、./nnet-ctc-get-egs
     作用:Get full-utterance examples of the data for neural network training. note that this does not randomize the order of utterance.
              得到神经网络训练的所有样本,这一步不会随机化发音的顺序
     用法:./nnet-ctc-get-egs [options] <features-rspecifier> <pdf-id-rspecifier> <training-examples-out>
     例如:./nnet-ctc-get-egs --left-context=0 --right-context=0 "$feats" "ark:gunzip -c exp/nnet/ali.1.gz" ark:-
              把特征和对其标签作为输入,产生可以用于神经网络的带标签的特征数据
     Options:
     --const-feat-dim      : If specified, the last const-feat-dim dimensions of the feature input are treated as constant over the context window (so are not spliced) (int类型, 默认值为 0)
     --ctc                       : 是否给CTC生成训练数据. (bool类型, 默认值为 true)
     --left-context          : 神经网络需要的上文的帧数. (int类型, 默认值为 0)
     --right-context        : 神经网络需要的下文的帧数. (int类型, 默认值为 0)
     其他参数:
     --config         :   读取配置文件(string类型,默认值为"")
     --help            :   打印用法信息(bool类型,默认值为false,即默认不打印)
     --print-args   :    打印命令行参数至标准错误流stderr (bool类型,默认值为true,用于产生log日志)
     --verbose      :    日志长短的等级(等级越高日志信息越多)(int类型,默认值为0)

9、./nnet-ctc-copy-egs
     作用:Copy examples (typically single frames) for neural network training, possibly changing the binary mode. Supports multiple wspecifiers, in which case it will write the examples round-robin to the outputs.
         复制神经网络的训练样本,支持多个输出写入符,可以输出为文本格式。
     用法:./nnet-ctc-copy-egs [options] <egs-rspecifier> <egs-wspecifier1> [<egs-wspecifier2> ...]
     例如:./nnet-ctc-copy-egs ark:train.egs ark,t:text.egs
     Options:
     --random                              :     如果为true,则将每帧任意输出到archives(bool类型,默认值为false)
     --srand                                 :    随机数种子(当random=true的时候使用)
     其他参数:
     --config         :   读取配置文件(string类型,默认值为"")
     --help            :   打印用法信息(bool类型,默认值为false,即默认不打印)
     --print-args   :    打印命令行参数至标准错误流stderr (bool类型,默认值为true,用于产生log日志)
     --verbose      :    日志长短的等级(等级越高日志信息越多)(int类型,默认值为0

10、./nnet-ctc-perturb-egs
     作用:Copy examples, perturbing them by adding a specified amount(--noise-factor) times the within-class covariance of the examples. the Cholesky factor of the examples(obtained from the --write-cholesky option of nnet-get-feature-transform) must be supplied.
              复制样本,并对样本增加噪声进行数据的增加
     用法:nnet-ctc-perturb-egs [options] <cholesky> <egs-rspecifier> <egs-wspecifier>
     例如:nnet-ctc-perturb-egs --noise-factor=0.2 exp/nnet5/cholesky.tpmat ark:- ark:-
     Options:
     --noise-factor : Factor to multiply noise generated from within-class variance by before adding to egs (float, default = 0.1)
     --srand : Seed for random number generator (int, default = 0)
     其他参数:
     --config         :   读取配置文件(string类型,默认值为"")
     --help            :   打印用法信息(bool类型,默认值为false,即默认不打印)
     --print-args   :    打印命令行参数至标准错误流stderr (bool类型,默认值为true,用于产生log日志)
     --verbose      :    日志长短的等级(等级越高日志信息越多)(int类型,默认值为0

11、剩下的几个都是对egs的处理,函数名就能知道大概的意思,直接贴上--help信息。
     ./nnet-ctc-subset-egs

Creates a random subset of the input examples, of a specified size.
Uses no more memory than the size of the subset.

Usage: nnet-ctc-subset-egs [options] <egs-rspecifier> [<egs-wspecifier2> ...]

e.g.
nnet-ctc-subset-egs [args] ark:- | nnet-subset-egs --n=1000 ark:- ark:subset.egs

Options:
--n : Number of examples to output (int, default = 1000)
--sort-order : If true, sort the order of the output by mat.NumRows() (bool, default = false)
--srand : Seed for random number generator (int, default = 0)

Standard options:
--config : Configuration file to read (this option may be repeated) (string, default = "")
--help : Print out usage message (bool, default = false)
--print-args : Print the command line arguments (to stderr) (bool, default = true)
--verbose : Verbose level (higher->more logging) (int, default = 0)

12、./nnet-ctc-sort-egs

Copy examples (typically single frames) for neural network training,
from the input to output, but sort the order. This program will keep
all of the examples in memory at once, unless you use the --buffer-size option

Usage: nnet-ctc-sort-egs [options] <egs-rspecifier> <egs-wspecifier>

nnet-ctc-sort-egs --srand=1 ark:train.egs ark:sortd.egs

Options:
--buffer-size : If >0, size of a buffer we use to do limited-memory partial sort. Otherwise, do full sort. (int, default = 0)
--srand : Seed for random number generator (int, default = 0)

Standard options:
--config : Configuration file to read (this option may be repeated) (string, default = "")
--help : Print out usage message (bool, default = false)
--print-args : Print the command line arguments (to stderr) (bool, default = true)
--verbose : Verbose level (higher->more logging) (int, default = 0)

13、./nnet-ctc-shuffle-egs

Copy examples (typically single frames) for neural network training,
from the input to output, but randomly shuffle the order. This program will keep
all of the examples in memory at once, unless you use the --buffer-size option

Usage: nnet-ctc-shuffle-egs [options] <egs-rspecifier> <egs-wspecifier>

nnet-ctc-shuffle-egs --srand=1 ark:train.egs ark:shuffled.egs

Options:
--buffer-size : If >0, size of a buffer we use to do limited-memory partial randomization. Otherwise, do full randomization. (int, default = 0)
--frame-shift : Allows you to shift time values in the supervision data (excluding iVector data) - useful in augmenting data. Note, the outputs will remain at the closest exact multiples of the frame subsampling factor (int, default = 0)
--frame-subsampling-factor : the frame subsampling factor (int, default = 0)
--srand : Seed for random number generator (int, default = 0)

Standard options:
--config : Configuration file to read (this option may be repeated) (string, default = "")
--help : Print out usage message (bool, default = false)
--print-args : Print the command line arguments (to stderr) (bool, default = true)
--verbose : Verbose level (higher->more logging) (int, default = 0)

14、./nnet-ctc-relabel-egs

Relabel neural network egs with the read pdf-id/ctc alignments, zero-based..
Usage: nnet-ctc-relabel-egs [options] <pdf-aligment-rspecifier> <egs_rspecifier1> ... <egs_rspecifierN> <egs_wspecifier1> ... <egs_wspecifierN>
e.g.:
 nnet-ctc-relabel-egs ark:1.ali egs_in/egs.1.ark egs_in/egs.2.ark egs_out/egs.1.ark egs_out/egs.2.ark
See also: nnet-ctc-get-egs, nnet-ctc-copy-egs, steps/nnet2/relabel_egs.sh

Standard options:
  --config                    : Configuration file to read (this option may be repeated) (string, default = "")
  --help                      : Print out usage message (bool, default = false)
  --print-args                : Print the command line arguments (to stderr) (bool, default = true)
  --verbose                   : Verbose level (higher->more logging) (int, default = 0)