CNTK icon indicating copy to clipboard operation
CNTK copied to clipboard

HOW to use kaldi's decoder???!!!

Open JJMEI opened this issue 9 years ago • 2 comments

here the log file:

/home/m/CNTK_V2.0_Fianl/CNTK/build/release/bin/cntk configFile=cntk_config/CNTK2_write.cntk DeviceNumber=-1 modelName=/home/m/CNTK_V2.0_Fianl/CNTK/Examples/Speech/BYLW/timit/cntk_timit.dnn labelDim=1947 featDim=473 action=write ExpDir=/home/m/CNTK_V2.0_Fianl/CNTK/Examples/Speech/BYLW/timit inputCounts=/home/m/kaldi-master/egs/timit/s5/data-fbank/test/split8/1/cntk_dev.counts inputFeats=/home/m/kaldi-master/egs/timit/s5/data-fbank/test/split8/1/cntkOutput.scp | latgen-faster-mapped --min-active=200 --max-active=7000 --max-mem=50000000 --beam=13.0 --lattice-beam=8.0 --acoustic-scale=0.0833 --allow-partial=true --word-symbol-table=/home/m/kaldi-master/egs/timit/s5/exp/tri3/graph/words.txt /home/m/CNTK_V2.0_Fianl/CNTK/Examples/Speech/BYLW/timit/final.mdl /home/m/kaldi-master/egs/timit/s5/exp/tri3/graph/HCLG.fst ark:- "ark:|gzip -c > /home/m/CNTK_V2.0_Fianl/CNTK/Examples/Speech/BYLW/timit/decode/lat.1.gz"

Started at Thu Apr 13 19:15:57 CST 2017

latgen-faster-mapped --min-active=200 --max-active=7000 --max-mem=50000000 --beam=13.0 --lattice-beam=8.0 --acoustic-scale=0.0833 --allow-partial=true --word-symbol-table=/home/m/kaldi-master/egs/timit/s5/exp/tri3/graph/words.txt /home/m/CNTK_V2.0_Fianl/CNTK/Examples/Speech/BYLW/timit/final.mdl /home/m/kaldi-master/egs/timit/s5/exp/tri3/graph/HCLG.fst ark:- 'ark:|gzip -c > /home/m/CNTK_V2.0_Fianl/CNTK/Examples/Speech/BYLW/timit/decode/lat.1.gz' CNTK 2.0rc1+ (master e1f48f, Apr 10 2017 20:33:48) on m-P55-US3L at 2017/04/13 19:15:58

/home/m/CNTK_V2.0_Fianl/CNTK/build/release/bin/cntk configFile=cntk_config/CNTK2_write.cntk DeviceNumber=-1 modelName=/home/m/CNTK_V2.0_Fianl/CNTK/Examples/Speech/BYLW/timit/cntk_timit.dnn labelDim=1947 featDim=473 action=write ExpDir=/home/m/CNTK_V2.0_Fianl/CNTK/Examples/Speech/BYLW/timit inputCounts=/home/m/kaldi-master/egs/timit/s5/data-fbank/test/split8/1/cntk_dev.counts inputFeats=/home/m/kaldi-master/egs/timit/s5/data-fbank/test/split8/1/cntkOutput.scp

Build info:

	Built time: Apr 10 2017 20:25:21
	Last modified date: Mon Apr 10 13:09:37 2017
	Build type: release
	Build target: GPU
	With 1bit-SGD: no
	With ASGD: no
	Math lib: mkl
	CUDA_PATH: /usr/local/cuda-7.5
	CUB_PATH: /home/m/cub-1.4.1
	CUDNN_PATH: /usr/local/cudnn-5.1
	Build Branch: master
	Build SHA1: e1f48f4c145ed8b7e34d064758d449a8e7cc46b5 (modified)
	Built by Source/CNTK/buildinfo.h$$0 on m-P55-US3L
	Build Path: /home/m/CNTK_V2.0_Fianl/CNTK
	MPI distribution: Open MPI
	MPI version: 1.10.3


GPU info:

	Device[0]: cores = 1536; computeCapability = 5.2; type = "GeForce GTX 960"; total memory = 4092 MB; free memory = 3991 MB

##############################################################################

write command (write action)

##############################################################################

reading script file /home/m/kaldi-master/egs/timit/s5/data-fbank/test/split8/1/cntk_dev.counts ... 24 entries PatchOutputNodes: No node named 'ScaledLogLikelihood'; skipping

Post-processing network...

2 roots: ce = CrossEntropyWithSoftmax() errs = ClassificationError()

Validating network. 32 nodes to process in pass 1.

Validating --> labels = InputValue() : -> [1947 x *] Validating --> model.arrayOfFunctions[9].arrayOfFunctions[0].W = LearnableParameter() : -> [1947 x 1024] Validating --> model.arrayOfFunctions[7].arrayOfFunctions[0].W = LearnableParameter() : -> [1024 x 1024] Validating --> model.arrayOfFunctions[5].arrayOfFunctions[0].W = LearnableParameter() : -> [1024 x 5 x 1 x 256] Validating --> model.arrayOfFunctions[3].W = LearnableParameter() : -> [4 x 3 x 128 x 256] Validating --> model.arrayOfFunctions[0].W = LearnableParameter() : -> [9 x 9 x 1 x 128] Validating --> features = InputValue() : -> [43 x 11 x 1 x *] Validating --> ol.x..x..x..x.x..c = Convolution (model.arrayOfFunctions[0].W, features) : [9 x 9 x 1 x 128], [43 x 11 x 1 x *] -> [35 x 3 x 128 x *] Validating --> model.arrayOfFunctions[0].b = LearnableParameter() : -> [1 x 1 x 128] Validating --> ol.x..x..x..x.x..res.x = Plus (ol.x..x..x..x.x..c, model.arrayOfFunctions[0].b) : [35 x 3 x 128 x *], [1 x 1 x 128] -> [35 x 3 x 128 x *] Validating --> ol.x..x..x..x.x = RectifiedLinear (ol.x..x..x..x.x..res.x) : [35 x 3 x 128 x *] -> [35 x 3 x 128 x *] Validating --> ol.x..x..x..x = Pooling (ol.x..x..x..x.x) : [35 x 3 x 128 x *] -> [8 x 3 x 128 x *] Validating --> ol.x..x..x..c = Convolution (model.arrayOfFunctions[3].W, ol.x..x..x..x) : [4 x 3 x 128 x 256], [8 x 3 x 128 x *] -> [5 x 1 x 256 x *] Validating --> model.arrayOfFunctions[3].b = LearnableParameter() : -> [1 x 1 x 256] Validating --> ol.x..x..x..res.x = Plus (ol.x..x..x..c, model.arrayOfFunctions[3].b) : [5 x 1 x 256 x *], [1 x 1 x 256] -> [5 x 1 x 256 x *] Validating --> ol.x..x..x = RectifiedLinear (ol.x..x..x..res.x) : [5 x 1 x 256 x *] -> [5 x 1 x 256 x *] Validating --> ol.x..x...PlusArgs[0] = Times (model.arrayOfFunctions[5].arrayOfFunctions[0].W, ol.x..x..x) : [1024 x 5 x 1 x 256], [5 x 1 x 256 x *] -> [1024 x *] Validating --> model.arrayOfFunctions[5].arrayOfFunctions[0].b = LearnableParameter() : -> [1024] Validating --> ol.x..x.. = Plus (ol.x..x...PlusArgs[0], model.arrayOfFunctions[5].arrayOfFunctions[0].b) : [1024 x *], [1024] -> [1024 x *] Validating --> ol.x..x._ = RectifiedLinear (ol.x..x..) : [1024 x *] -> [1024 x *] Validating --> ol.x..x = Dropout (ol.x..x.) : [1024 x *] -> [1024 x *] Validating --> ol.x...PlusArgs[0] = Times (model.arrayOfFunctions[7].arrayOfFunctions[0].W, ol.x..x) : [1024 x 1024], [1024 x *] -> [1024 x *] Validating --> model.arrayOfFunctions[7].arrayOfFunctions[0].b = LearnableParameter() : -> [1024] Validating --> ol.x.._ = Plus (ol.x...PlusArgs[0], model.arrayOfFunctions[7].arrayOfFunctions[0].b) : [1024 x *], [1024] -> [1024 x *] Validating --> ol.x._ = RectifiedLinear (ol.x..) : [1024 x *] -> [1024 x *] Validating --> ol.x = Dropout (ol.x._) : [1024 x *] -> [1024 x *] Validating --> ol.z.PlusArgs[0] = Times (model.arrayOfFunctions[9].arrayOfFunctions[0].W, ol.x) : [1947 x 1024], [1024 x *] -> [1947 x *] Validating --> model.arrayOfFunctions[9].arrayOfFunctions[0].b = LearnableParameter() : -> [1947] Validating --> ol.z = Plus (ol.z.PlusArgs[0], model.arrayOfFunctions[9].arrayOfFunctions[0].b) : [1947 x *], [1947] -> [1947 x *] Validating --> ol = Softmax (ol.z) : [1947 x *] -> [1947 x *] Validating --> ce = CrossEntropyWithSoftmax (labels, ol) : [1947 x *], [1947 x *] -> [1] Validating --> errs = ClassificationError (labels, ol) : [1947 x *], [1947 x *] -> [1]

Validating network. 20 nodes to process in pass 2.

Validating network, final pass.

Post-processing network complete.

HTKMLFWriter::Init: reading output script file /home/m/kaldi-master/egs/timit/s5/data-fbank/test/split8/1/cntk_dev.counts ... 24 entries OutputNodeNames are not specified, using the default outputnodes. Closed Kaldi writer LOG (latgen-faster-mapped:main():latgen-faster-mapped.cc:163) Time taken 0.392046s: real-time factor assuming 100 frames/sec is inf LOG (latgen-faster-mapped:main():latgen-faster-mapped.cc:166) Done 0 utterances, failed for 0 LOG (latgen-faster-mapped:main():latgen-faster-mapped.cc:168) Overall log-likelihood per frame is -nan over 0 frames.

Accounting: time=1 threads=1

Ended (code 1) at Thu Apr 13 19:15:58 CST 2017, elapsed time 1 seconds

#!/bin/bash

This is the 2nd version of CNTK recipe for AMI corpus.

In this recipe, CNTK directly read Kaldi features and labels,

which makes the whole pipline much simpler. Here, we only

train the standard hybrid DNN model. To train LSTM and PAC-RNN

models, you have to change the ndl file. -Liang (1/5/2015)

. ./path.sh #expdir=/home/m/CNTK/Examples/Speech/BYLW #工作目录 expdir=/home/m/CNTK_V2.0_Fianl/CNTK/Examples/Speech/BYLW/timit #工作目录 datadir=/home/m/kaldi-master/egs/timit/s5/data-fbank #特征数据/home/m/kald-new/egs/BYLW/s5/data-spectrogram alidir=/home/m/kaldi-master/egs/timit/s5/exp/tri3_ali #对齐文件夹/home/m/kald-new/egs/BYLW/s5/exp/tri4b_ali

labelDim=1947 #标签维度 featDim=473 #特征维度 stage=2 #运行状态

cn_gpu=/home/m/CNTK_V2.0_Fianl/CNTK/build/release/bin/cntk #cntk可执行文件所在目录

feats_tr="scp:$datadir/train_tr90/feats.scp" #90%训练特征文件所在路径 feats_cv="scp:$datadir/train_cv10/feats.scp" #10%测试特征文件所在路径 labels_tr="ark:ali-to-pdf $alidir/final.mdl "ark:gunzip -c $alidir/ali..gz |" ark:- | ali-to-post ark:- ark:- |" #训练及集标签数目 labels_cv="ark:ali-to-pdf $alidir/final.mdl "ark:gunzip -c $alidir_cv/ali..gz |" ark:- | ali-to-post ark:- ark:- |"

mkdir -p $expdir

if [ $stage -le 0 ] ; then (feat-to-len "$feats_tr" ark,t:- > $expdir/cntk_train.counts) || exit 1; echo "$feats_tr" > $expdir/cntk_train.feats echo "$labels_tr" > $expdir/cntk_train.labels

(feat-to-len "$feats_cv" ark,t:- > $expdir/cntk_valid.counts) || exit 1; echo "$feats_cv" > $expdir/cntk_valid.feats echo "$labels_tr" > $expdir/cntk_valid.labels

for (( c=0; c<labelDim; c++)) ; do echo $c done >$expdir/cntk_label.mapping

fi

if [ $stage -le 1 ] ; then

setup the configuration files for training CNTK models

tee $expdir/Base.config <<EOF ExpDir=$expdir logFile=train_cntk_timit modelName=cntk_timit.dnn

labelDim=${labelDim} featDim=${featDim} labelMapping=${expdir}/cntk_label.mapping featureTransform=NO_FEATURE_TRANSFORM

inputCounts=${expdir}/cntk_train.counts inputFeats=${expdir}/cntk_train.feats inputLabels=${expdir}/cntk_train.labels

cvInputCounts=${expdir}/cntk_valid.counts cvInputFeats=${expdir}/cntk_valid.feats cvInputLabels=${expdir}/cntk_valid.labels EOF

training command

$cn_gpu configFile=${expdir}/Base.config configFile=/home/m/CNTK_V2.0_Fianl/CNTK/Examples/Speech/BYLW/cntk_config/CNTK_timit.cntk #echo "$0 successfuly finished.. $dir"

fi

#解码部分的配置 if [ $stage -le 2 ] ; then

config_write=cntk_config/CNTK2_write.cntk cnmodel=$expdir/cntk_timit.dnn

action=write graphdir=/home/m/kaldi-master/egs/timit/s5/exp/tri3/graph cp $alidir/final.mdl $expdir

#$cn_gpu configFile=$config_write DeviceNumber=0 modelName=$cnmodel labelDim=$labelDim featDim=$featDim action=$action ExpDir=$expdir cntk_string="$cn_gpu configFile=$config_write DeviceNumber=-1 modelName=$cnmodel labelDim=$labelDim featDim=$featDim action=$action ExpDir=$expdir" scripts/decode_cntk2.sh --nj 8 --cmd run.pl --acwt 0.0833 $graphdir $datadir/test $expdir/decode "$cntk_string" || exit 1;

fi

Note: This sample uses the deprecated NdlNetworkBuilder.

An updated version using BrainScript is coming soon.

Please find updated samples on Github, https://github.com/Microsoft/CNTK/tree/master/Examples /...

command=trainNetwork Truncated=false precision=float deviceId=0 stderr=$ExpDir$/log/$logFile$ traceLevel=2 modelPath=$ExpDir$/$modelName$

TRAINING CONFIG

trainNetwork = {

action = "train"

BrainScriptNetworkBuilder = {
                                # number of distinct labels



    model = Sequential (

    ConvolutionalLayer {128, (9:9), stride = (1:1), pad = false} : ReLU :
    MaxPoolingLayer    {(4:1), stride=(4:1)} :
    ConvolutionalLayer {256, (4:3), stride = (1:1), pad = false} : ReLU :










    DenseLayer         {1024, activation=ReLU} : Dropout :
    DenseLayer         {1024, activation=ReLU} : Dropout :
    DenseLayer         {1947, activation=Softmax}

)

# inputs
features = Input {(43:11:1)}
labels = Input {1947}


    # apply model to features
    ol = model (features)

    # loss and error computation
    ce   = CrossEntropyWithSoftmax (labels, ol)
    errs = ClassificationError (labels, ol)

    # declare special nodes
    featureNodes    = (features)
    labelNodes      = (labels)
    criterionNodes  = (ce)
    evaluationNodes = (errs)
    outputNodes     = (ol)
}

SGD={
    epochSize=0
    minibatchSize=256
    #learningRatesPerMB=0.1:1
    learningRatesPerMB=0.0008:0.001
    momentumPerMB=0:0.009
    dropoutRate=0.0
    maxEpochs=1
    numMBsToShowResult=100


    #settings for Auto Adjust Learning Rate
    AutoAdjust={
        reduceLearnRateIfImproveLessThan=0
        loadBestModel=true
        increaseLearnRateIfImproveMoreThan=1000000000
        learnRateDecreaseFactor=0.5
        autoAdjustLR=AdjustAfterEpoch
        learnRateAdjustInterval=1
    }

    gradientClippingWithTruncation=true
    clippingThresholdPerSample=1#INF

}
# Parameter values for the readerstride = 1
reader={
    # reader to use
    readerType=Kaldi2Reader
    readMethod=blockRandomize
    frameMode=true
    Truncated=false
    nbruttsineachrecurrentiter=1
    miniBatchMode=Partial
    randomize=1000000
    verbosity=0
    features={
        dim=$featDim$
        scpFile=$inputCounts$
        rx=$inputFeats$
        featureTransform=$featureTransform$
    }

    labels={
        mlfFile=$inputLabels$
        labelDim=$labelDim$
        labelMappingFile=$labelMapping$
    }
}


cvReader={
    # reader to use
    readerType=Kaldi2Reader
    readMethod=blockRandomize
    frameMode=true
    miniBatchMode=Partial
    randomize=Auto
    verbosity=0
    features={
        dim=$featDim$
        scpFile=$cvInputCounts$
        rx=$cvInputFeats$
        featureTransform=$featureTransform$
    }

    labels={
        mlfFile=$cvInputLabels$
        labelDim=$labelDim$
        labelMappingFile=$labelMapping$
    }
}

}

Note: This sample uses the deprecated NdlNetworkBuilder.

An updated version using BrainScript is coming soon.

Please find updated samples on Github, https://github.com/Microsoft/CNTK/tree/master/Examples /...

command=trainNetwork Truncated=false precision=float deviceId=0 stderr=$ExpDir$/log/$logFile$ traceLevel=2 modelPath=$ExpDir$/$modelName$

TRAINING CONFIG

trainNetwork = {

action = "train"

BrainScriptNetworkBuilder = {
                                # number of distinct labels



    model = Sequential (

    ConvolutionalLayer {128, (9:9), stride = (1:1), pad = false} : ReLU :
    MaxPoolingLayer    {(4:1), stride=(4:1)} :
    ConvolutionalLayer {256, (4:3), stride = (1:1), pad = false} : ReLU :










    DenseLayer         {1024, activation=ReLU} : Dropout :
    DenseLayer         {1024, activation=ReLU} : Dropout :
    DenseLayer         {1947, activation=Softmax}

)

# inputs
features = Input {(43:11:1)}
labels = Input {1947}


    # apply model to features
    ol = model (features)

    # loss and error computation
    ce   = CrossEntropyWithSoftmax (labels, ol)
    errs = ClassificationError (labels, ol)

    # declare special nodes
    featureNodes    = (features)
    labelNodes      = (labels)
    criterionNodes  = (ce)
    evaluationNodes = (errs)
    outputNodes     = (ol)
}

SGD={
    epochSize=0
    minibatchSize=256
    #learningRatesPerMB=0.1:1
    learningRatesPerMB=0.0008:0.001
    momentumPerMB=0:0.009
    dropoutRate=0.0
    maxEpochs=1
    numMBsToShowResult=100


    #settings for Auto Adjust Learning Rate
    AutoAdjust={
        reduceLearnRateIfImproveLessThan=0
        loadBestModel=true
        increaseLearnRateIfImproveMoreThan=1000000000
        learnRateDecreaseFactor=0.5
        autoAdjustLR=AdjustAfterEpoch
        learnRateAdjustInterval=1
    }

    gradientClippingWithTruncation=true
    clippingThresholdPerSample=1#INF

}
# Parameter values for the readerstride = 1
reader={
    # reader to use
    readerType=Kaldi2Reader
    readMethod=blockRandomize
    frameMode=true
    Truncated=false
    nbruttsineachrecurrentiter=1
    miniBatchMode=Partial
    randomize=1000000
    verbosity=0
    features={
        dim=$featDim$
        scpFile=$inputCounts$
        rx=$inputFeats$
        featureTransform=$featureTransform$
    }

    labels={
        mlfFile=$inputLabels$
        labelDim=$labelDim$
        labelMappingFile=$labelMapping$
    }
}


cvReader={
    # reader to use
    readerType=Kaldi2Reader
    readMethod=blockRandomize
    frameMode=true
    miniBatchMode=Partial
    randomize=Auto
    verbosity=0
    features={
        dim=$featDim$
        scpFile=$cvInputCounts$
        rx=$cvInputFeats$
        featureTransform=$featureTransform$
    }

    labels={
        mlfFile=$cvInputLabels$
        labelDim=$labelDim$
        labelMappingFile=$labelMapping$
    }
}

}

JJMEI avatar Apr 13 '17 11:04 JJMEI

who can help me?

JJMEI avatar Apr 13 '17 11:04 JJMEI

@JJMEI Please summarize what you are doing and details of where an issue has occurred. Attach log file(s) as needed.

liqunfu avatar Jul 14 '17 16:07 liqunfu