CNTK icon indicating copy to clipboard operation
CNTK copied to clipboard

BinaryReader is not explained in wiki

Open bulatGH opened this issue 10 years ago • 13 comments

I was just wondering, if there is any explanation of BinaryData format in wiki page? Binary files are very compact and faster to generate in comparison to text files.

bulatGH avatar Jun 08 '16 23:06 bulatGH

I would also appreciate an explanation for the binary reader. I am looking for examples for it now...

LowerySJ avatar Jun 09 '16 15:06 LowerySJ

We are moving away from the existing Reader architecture, so the BinaryReader is deprecated (or will be soon). A new binary reader for the new architecture is being written, but not ready. The other existing binary reader is the speech reader (HTKFeatureDeserializer), which works for single streams of dense feature vectors/tensors.

HTK feature archives are just column-major float32 matrices with a 12-byte header, and a descriptor text file. The format is described at the end of this page.

frankseide avatar Jun 09 '16 16:06 frankseide

That's wonderful to hear! I was trying to write my own custom Reader a while back and was completely lost. I'm glad to hear you're working on a new architecture.

Have a look at ITK's ImageIOBase. If there was an ITKImageReader, you could read almost any image format of any dimension without needing to write too much code. It'll even silently convert between pixel types. You could always load float/double data without needing to worry about whether the raw data is stored that way. https://itk.org/Doxygen/html/classitk_1_1ImageIOBase.html https://itk.org/Doxygen/html/classitk_1_1ImageIOFactory.html https://itk.org/Doxygen/html/classitk_1_1Image.html

Although, admittedly ITK is not too friendly if you're not using CMake. One would have to put the numerous dependencies in the Visual Studio prop sheets manually and this is very painful!

nslay avatar Jun 09 '16 19:06 nslay

@frankseide I am trying to write my image datasets into the binary format that can be read by BinaryReader into CNTK. I am wondering if there are some examples? Or it is not an easy task?

Thank you for your reply!

pinzhang10 avatar Jun 28 '16 04:06 pinzhang10

@LowerySJ Hi, did you find any example? Thank you!

pinzhang10 avatar Jun 28 '16 14:06 pinzhang10

@pinzhang10 , sorry I did not find any examples. Good luck with your work!

LowerySJ avatar Jun 28 '16 15:06 LowerySJ

The binary reader used Window only APIs and only works on Windows. It was designed as a cache to the UCIFastReader so that you only need to parse the text file once.

dongyu888 avatar Jun 28 '16 15:06 dongyu888

@LowerySJ Thank you very much for your reply. I think I may need to write our customized reader.

pinzhang10 avatar Jun 30 '16 01:06 pinzhang10

@dongyu888 Thank you for your comment. That means the BinaryReader is not used to read binary format input directly. If I want to use it in this way, I need to follow the code in UCIFastReader and write a customized reader by myself?

pinzhang10 avatar Jun 30 '16 01:06 pinzhang10

no, you just need to turn on the cache mode and the text fike will be converted to the binary mode automatically.

Thanks, Dong Yu (俞栋)Sent from my smart phone. Please forgive my typos.

-------- Original message --------
From: pinzhang10
Date: 6/29/16 18:54 (GMT-08:00)
To: Microsoft/CNTK
Cc: Dong Yu , Mention
Subject: Re: [Microsoft/CNTK] BinaryReader is not explained in wiki (#562)

@dongyu888 Thank you for your comment. That means the BinaryReader is not used to read binary format input directly. If I want to use it in this way, I need to follow the code in UCIFastReader and write a customized reader by myself?


You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/Microsoft/CNTK/issues/562#issuecomment-229539277

dongyu888 avatar Jun 30 '16 02:06 dongyu888

@dongyu888 My problem is: I won't be able to have a text file since it will be too big in our project. I have to convert the data in our format into binary format and read it in later using BinaryReader directly into CNTK. I am wondering if there is a simple way for me to do it or I need to write our customized writer and reader to do the whole procedure? Thank you!

pinzhang10 avatar Jul 01 '16 00:07 pinzhang10

i think you can just write your data to the binary format directly. if you can not find doc you may need to read the binary reader code to understand the format.

Thanks, Dong Yu (俞栋)Sent from my smart phone. Please forgive my typos.

-------- Original message --------
From: pinzhang10
Date: 6/30/16 17:40 (GMT-08:00)
To: Microsoft/CNTK
Cc: Dong Yu , Mention
Subject: Re: [Microsoft/CNTK] BinaryReader is not explained in wiki (#562)

@dongyu888 My problem is: I won't be able to have a text file since it will be too big in our project. I have to convert the data in our format into binary format and read it in later using BinaryReader directly into CNTK. I am wondering if there is a simple way for me to do it or I need to write our customized writer and reader to do the whole procedure? Thank you!


You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/Microsoft/CNTK/issues/562#issuecomment-229826517

dongyu888 avatar Jul 01 '16 01:07 dongyu888

@dongyu888 OK, got it. Thank you very much for your reply!

pinzhang10 avatar Jul 10 '16 22:07 pinzhang10