CNTK icon indicating copy to clipboard operation
CNTK copied to clipboard

How to take HTK format datas as features and labels to train the networks?

Open Maokui-He opened this issue 9 years ago • 6 comments

I have knew the way to do this in brainscripts, but how to do this in python?The python API only recommends me the function 'HTKFeatureDeserializer(streams)'.I want know more about it.Is there a code for that?

Maokui-He avatar Sep 30 '17 09:09 Maokui-He

You can combine several HTKFeatureDeserializers in the same minibatch source, i.e. if you have both features and labels in htk format, just create a minibatch source like this: fd = HTKFeatureDeserializer(StreamDefs( features = StreamDef(shape=feature_dim, context=(context,context), scp=features_file))) ld = HTKFeatureDeserializer(StreamDefs( labels = StreamDef(shape=label_dim, scp=labels_file)))

mbSource = MinibatchSource([fd,ld], max_samples=total_number_of_samples)

Then next_minibatch will give you the data for features and labels. There are plenty of samples how to use deserializers in the tutorials, HTK one is not different.

I.e. you can have a look at https://github.com/Microsoft/CNTK/blob/master/Examples/Speech/AN4/Python/HTK_LSTM_Truncated_Distributed.py

eldakms avatar Oct 04 '17 07:10 eldakms

Thank you for your answer! It comes to a problem : every feature frame correspond to label frame between two htk files, seting feature's context (3,3) so when calling next_minibatch() firstly, we'll get first features(7 frames) and labels(1 frame), the problem is that I want the features(first 7 frames) correspond to labels(4th frames not the first frames), is there a way to do that?

Maokui-He avatar Oct 04 '17 15:10 Maokui-He

so you need the forth or the first four? can you get the first four (context (3, 0)) and drop the first three already inside the network, no?

eldakms avatar Oct 04 '17 15:10 eldakms

you can give a context to the second deserializer in a similar manner as to the first one.

eldakms avatar Oct 04 '17 15:10 eldakms

I just need the fourth!

Maokui-He avatar Oct 04 '17 15:10 Maokui-He

Maybe I've got it! Thank you very much!

Maokui-He avatar Oct 04 '17 16:10 Maokui-He