Beispiel #1
0
 public SizeTVectorVector(SizeTVectorVector other) : this(CNTKLibPINVOKE.new_SizeTVectorVector__SWIG_1(SizeTVectorVector.getCPtr(other)), true)
 {
     if (CNTKLibPINVOKE.SWIGPendingException.Pending)
     {
         throw CNTKLibPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Beispiel #2
0
 public SizeTVectorVectorEnumerator(SizeTVectorVector collection)
 {
     collectionRef = collection;
     currentIndex  = -1;
     currentObject = null;
     currentSize   = collectionRef.Count;
 }
Beispiel #3
0
        // Create Value object from OneHotVector input as batch of sequences data with sequenceStratFlags, for 1D tensor only.
        public static Value Create <T>(int dimension,
                                       System.Collections.Generic.IEnumerable <System.Collections.Generic.IEnumerable <int> > sequences,
                                       System.Collections.Generic.IEnumerable <bool> sequenceStartFlags,
                                       DeviceDescriptor device,
                                       bool readOnly = false)
        {
            var seqFlags       = Helper.AsBoolVector(sequenceStartFlags);
            var inputSeqVector = new SizeTVectorVector();

            foreach (var seq in sequences)
            {
                var s = Helper.AsSizeTVector(seq);
                inputSeqVector.Add(s);
            }
            if (typeof(T).Equals(typeof(float)))
            {
                return(Value._CreateOneHotFloat((uint)dimension, inputSeqVector, seqFlags, device, readOnly));
            }
            else if (typeof(T).Equals(typeof(double)))
            {
                return(Value._CreateOneHotDouble((uint)dimension, inputSeqVector, seqFlags, device, readOnly));
            }
            else
            {
                throw new System.ArgumentException("The data type " + typeof(T).ToString() + " is not supported. Only float or double is supported by CNTK.");
            }
        }
Beispiel #4
0
 private void _CopyVariableValueTo(Variable outputVariable, SizeTVectorVector sequences)
 {
     CNTKLibPINVOKE.Value__CopyVariableValueTo(swigCPtr, Variable.getCPtr(outputVariable), SizeTVectorVector.getCPtr(sequences));
     if (CNTKLibPINVOKE.SWIGPendingException.Pending)
     {
         throw CNTKLibPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Beispiel #5
0
 public void SetRange(int index, SizeTVectorVector values)
 {
     CNTKLibPINVOKE.SizeTVectorVector_SetRange(swigCPtr, index, SizeTVectorVector.getCPtr(values));
     if (CNTKLibPINVOKE.SWIGPendingException.Pending)
     {
         throw CNTKLibPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Beispiel #6
0
        private static Value _CreateOneHotDouble(uint dimension, SizeTVectorVector oneHotSequences, BoolVector sequenceStartFlags, DeviceDescriptor device)
        {
            global::System.IntPtr cPtr = CNTKLibPINVOKE.Value__CreateOneHotDouble__SWIG_7(dimension, SizeTVectorVector.getCPtr(oneHotSequences), BoolVector.getCPtr(sequenceStartFlags), DeviceDescriptor.getCPtr(device));
            Value ret = (cPtr == global::System.IntPtr.Zero) ? null : new Value(cPtr, true);

            if (CNTKLibPINVOKE.SWIGPendingException.Pending)
            {
                throw CNTKLibPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Beispiel #7
0
        private static Value _CreateOneHotFloat(uint dimension, SizeTVectorVector oneHotSequences, DeviceDescriptor device, bool readOnly)
        {
            global::System.IntPtr cPtr = CNTKLibPINVOKE.Value__CreateOneHotFloat__SWIG_4(dimension, SizeTVectorVector.getCPtr(oneHotSequences), DeviceDescriptor.getCPtr(device), readOnly);
            Value ret = (cPtr == global::System.IntPtr.Zero) ? null : new Value(cPtr, true);

            if (CNTKLibPINVOKE.SWIGPendingException.Pending)
            {
                throw CNTKLibPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Beispiel #8
0
        private static Value _CreateOneHotFloat(NDShape sampleShape, SizeTVectorVector oneHotSequences, BoolVector sequenceStartFlags, DeviceDescriptor device, bool readOnly)
        {
            global::System.IntPtr cPtr = CNTKLibPINVOKE.Value__CreateOneHotFloat__SWIG_2(NDShape.getCPtr(sampleShape), SizeTVectorVector.getCPtr(oneHotSequences), BoolVector.getCPtr(sequenceStartFlags), DeviceDescriptor.getCPtr(device), readOnly);
            Value ret = (cPtr == global::System.IntPtr.Zero) ? null : new Value(cPtr, true);

            if (CNTKLibPINVOKE.SWIGPendingException.Pending)
            {
                throw CNTKLibPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Beispiel #9
0
        private static Value _CreateOneHotDouble(NDShape sampleShape, SizeTVectorVector oneHotSequences, DeviceDescriptor device)
        {
            global::System.IntPtr cPtr = CNTKLibPINVOKE.Value__CreateOneHotDouble__SWIG_1(NDShape.getCPtr(sampleShape), SizeTVectorVector.getCPtr(oneHotSequences), DeviceDescriptor.getCPtr(device));
            Value ret = (cPtr == global::System.IntPtr.Zero) ? null : new Value(cPtr, true);

            if (CNTKLibPINVOKE.SWIGPendingException.Pending)
            {
                throw CNTKLibPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Beispiel #10
0
        public static SizeTVectorVector Repeat(SizeTVector value, int count)
        {
            global::System.IntPtr cPtr = CNTKLibPINVOKE.SizeTVectorVector_Repeat(SizeTVector.getCPtr(value), count);
            SizeTVectorVector     ret  = (cPtr == global::System.IntPtr.Zero) ? null : new SizeTVectorVector(cPtr, true);

            if (CNTKLibPINVOKE.SWIGPendingException.Pending)
            {
                throw CNTKLibPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Beispiel #11
0
        public SizeTVectorVector GetRange(int index, int count)
        {
            global::System.IntPtr cPtr = CNTKLibPINVOKE.SizeTVectorVector_GetRange(swigCPtr, index, count);
            SizeTVectorVector     ret  = (cPtr == global::System.IntPtr.Zero) ? null : new SizeTVectorVector(cPtr, true);

            if (CNTKLibPINVOKE.SWIGPendingException.Pending)
            {
                throw CNTKLibPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Beispiel #12
0
        //
        // Return the data of the Value object as a list of sequences with variable length.
        // This method returns an IList<IList<T>>. Each element of the outer list represents a sequence.
        // Each sequence, represented by List<int>, contains a variable number of samples.
        // Each sample is represented by an index of the OneHot vector. The size of the OneHot vector should match that defined in the variable.
        // The number of samples = the count of elements in List<int>.
        //
        public System.Collections.Generic.IList <System.Collections.Generic.IList <int> > GetOneHotData(Variable outputVariable)
        {
            var sequences = new System.Collections.Generic.List <System.Collections.Generic.IList <int> >();
            var seqVec    = new SizeTVectorVector();

            _CopyVariableValueTo(outputVariable, seqVec);
            foreach (var seq in seqVec)
            {
                var seqList = new System.Collections.Generic.List <int>(seq.Count);
                foreach (var element in seq)
                {
                    seqList.Add((int)element);
                }
                sequences.Add(seqList);
            }
            return(sequences);
        }
Beispiel #13
0
        public void CopyVariableValueTo(Variable outputVariable, System.Collections.Generic.List <System.Collections.Generic.List <int> > sequences)
        {
            var seqVec = new SizeTVectorVector();

            _CopyVariableValueTo(outputVariable, seqVec);

            sequences.Clear();
            foreach (var seq in seqVec)
            {
                var seqList = new System.Collections.Generic.List <int>(seq.Count);
                foreach (var element in seq)
                {
                    seqList.Add((int)element);
                }
                sequences.Add(seqList);
            }
            return;
        }
Beispiel #14
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SizeTVectorVector obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }