Search code examples
c#cntk

CNTK C# Library 2.0beta11 (CNTK.CPUOnly): sequence of sparse vectors


Perhaps I'm missing something in the documentation, but how can I create an input which is a sequence of sparse vectors in the new CNTK.CPUOnly NuGet package in C#? (https://github.com/Microsoft/CNTK/wiki/CNTK-Library-Evaluation-Overview)

All I see in the available API is support for sequence of dense vectors.

I was able to do it using the EvalDLL API (from the Microsoft.Research.CNTK.CpuEval-mkl NuGet package), but I'm having some thread-safety issues, which prompted me to try out the newer API.


Solution

  • Currently the C# API supports to create one-hot vector for sequence and/or batch. For example, to create a sequence using:

    public static Value CreateSequence<T>(uint dimension, List<uint> sequence, bool seqStartFlag, DeviceDescriptor device, bool readOnly = false)
    

    or create a batch of sequence:

    public static Value CreateBatchOfSequences<T>(uint dimension, List<List<uint>> batchOfSequences, List<bool> seqStartFlags, DeviceDescriptor device, bool readOnly = false
    

    The API description is here, and the examples are here. Support for general sparse format will be added in the next few weeks.

    Thanks