def CTFDeserializer(filename, streams): ''' Configures the CNTK text-format reader that reads text-based files with lines of the form:: [Sequence_Id] (Sample)+ where:: Sample=|Input_Name (Value )* Args: filename (str): file name containing the text input streams: any dictionary-like object that contains a mapping from stream names to :class:`StreamDef` objects. Each StreamDef object configures an input stream. See also: :cntkwiki:`CNTKTextReader format <BrainScript-CNTKTextFormat-Reader>` ''' for k, s in streams.items(): if s.stream_alias is None: raise ValueError("CTFDeserializer: stream name for key %s must be " "specified" % k) sc = [ cntk_py.StreamConfiguration(k, s.dim, s.is_sparse, s.stream_alias, s['defines_mb_size']) for k, s in streams.items() ] return cntk_py.ctf_deserializer(filename, sc)
def CBFDeserializer(filename, streams = {}): ''' Configures the CNTK binary-format deserializer. Args: filename (str): file name containing the binary data streams: any dictionary-like object that contains a mapping from stream names to :class:`StreamDef` objects. Each StreamDef object configures an input stream. See also: :cntkwiki:`CNTKBinaryReader format <BrainScript-CNTKBinary-Reader>` ''' sc = [cntk_py.StreamConfiguration( k, s.dim, s.is_sparse, s.stream_alias) for k, s in streams.items()] return cntk_py.cbf_deserializer(filename, sc)