Ejemplo n.º 1
0
 public DoubleVectorVector(DoubleVectorVector other) : this(CNTKLibPINVOKE.new_DoubleVectorVector__SWIG_1(DoubleVectorVector.getCPtr(other)), true)
 {
     if (CNTKLibPINVOKE.SWIGPendingException.Pending)
     {
         throw CNTKLibPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Ejemplo n.º 2
0
 public DoubleVectorVectorEnumerator(DoubleVectorVector collection)
 {
     collectionRef = collection;
     currentIndex  = -1;
     currentObject = null;
     currentSize   = collectionRef.Count;
 }
Ejemplo n.º 3
0
        // Create Value object from dense input as batch of sequences data with sequenceStartFlags.
        public static Value Create <T>(NDShape sampleShape,
                                       System.Collections.Generic.IEnumerable <System.Collections.Generic.IEnumerable <T> > sequences,
                                       System.Collections.Generic.IEnumerable <bool> sequenceStartFlags,
                                       DeviceDescriptor device,
                                       bool readOnly = false)
        {
            var seqFlags = Helper.AsBoolVector(sequenceStartFlags);

            if (typeof(T).Equals(typeof(float)))
            {
                var inputAsSequencesVector = new FloatVectorVector();
                foreach (var seq in sequences)
                {
                    var seqVector = Helper.AsFloatVector(seq);
                    // The seqVector is copied when adding to inputAsSequencesVector.
                    inputAsSequencesVector.Add(seqVector);
                }
                return(Value._CreateDenseFloat(sampleShape, inputAsSequencesVector, seqFlags, device, readOnly));
            }
            else if (typeof(T).Equals(typeof(double)))
            {
                var inputAsSequencesVector = new DoubleVectorVector();
                foreach (var seq in sequences)
                {
                    var seqVector = Helper.AsDoubleVector(seq);
                    inputAsSequencesVector.Add(seqVector);
                }
                return(Value._CreateDenseDouble(sampleShape, inputAsSequencesVector, 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.");
            }
        }
Ejemplo n.º 4
0
 public void SetRange(int index, DoubleVectorVector values)
 {
     CNTKLibPINVOKE.DoubleVectorVector_SetRange(swigCPtr, index, DoubleVectorVector.getCPtr(values));
     if (CNTKLibPINVOKE.SWIGPendingException.Pending)
     {
         throw CNTKLibPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Ejemplo n.º 5
0
 private void _CopyVariableValueToDouble(Variable outputVariable, DoubleVectorVector sequences)
 {
     CNTKLibPINVOKE.Value__CopyVariableValueToDouble__SWIG_0(swigCPtr, Variable.getCPtr(outputVariable), DoubleVectorVector.getCPtr(sequences));
     if (CNTKLibPINVOKE.SWIGPendingException.Pending)
     {
         throw CNTKLibPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Ejemplo n.º 6
0
        public static DoubleVectorVector Repeat(DoubleVector value, int count)
        {
            global::System.IntPtr cPtr = CNTKLibPINVOKE.DoubleVectorVector_Repeat(DoubleVector.getCPtr(value), count);
            DoubleVectorVector    ret  = (cPtr == global::System.IntPtr.Zero) ? null : new DoubleVectorVector(cPtr, true);

            if (CNTKLibPINVOKE.SWIGPendingException.Pending)
            {
                throw CNTKLibPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 7
0
        public DoubleVectorVector GetRange(int index, int count)
        {
            global::System.IntPtr cPtr = CNTKLibPINVOKE.DoubleVectorVector_GetRange(swigCPtr, index, count);
            DoubleVectorVector    ret  = (cPtr == global::System.IntPtr.Zero) ? null : new DoubleVectorVector(cPtr, true);

            if (CNTKLibPINVOKE.SWIGPendingException.Pending)
            {
                throw CNTKLibPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 8
0
        private static Value _CreateDenseDouble(NDShape sampleShape, DoubleVectorVector sequences, BoolVector sequenceStartFlags, DeviceDescriptor device)
        {
            global::System.IntPtr cPtr = CNTKLibPINVOKE.Value__CreateDenseDouble__SWIG_3(NDShape.getCPtr(sampleShape), DoubleVectorVector.getCPtr(sequences), 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);
        }
Ejemplo n.º 9
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 IList<T>, contains a variable number of samples.
        // Each sample consits of a fixed number of elements with type of 'T'. The number of elements is determined by the variable shape.
        // The number of samples = (the count of elements in IList<T>)/(the count of elements of the sample)
        // The shape of the variable should match the shape of the Value object.
        //
        public System.Collections.Generic.IList <System.Collections.Generic.IList <T> > GetDenseData <T>(Variable outputVariable)
        {
            var sequences = new System.Collections.Generic.List <System.Collections.Generic.IList <T> >();

            if (typeof(T).Equals(typeof(float)))
            {
                if (_GetDataType() != DataType.Float)
                {
                    throw new System.ArgumentException("The value type does not match the list type.");
                }

                var seqVec = new FloatVectorVector();
                _CopyVariableValueToFloat(outputVariable, seqVec);

                foreach (var seq in seqVec)
                {
                    var seqList = seq as System.Collections.Generic.IList <T>;
                    if (seqList == null)
                    {
                        throw new System.TypeAccessException("Cannot convert to the value type.");
                    }
                    // It is required to create a new List from seq, since seq is dependent on the life cycle of seqVec.
                    sequences.Add(new System.Collections.Generic.List <T>(seqList));
                }
            }
            else if (typeof(T).Equals(typeof(double)))
            {
                if (_GetDataType() != DataType.Double)
                {
                    throw new System.ArgumentException("The value type does not match the list type.");
                }

                var seqVec = new DoubleVectorVector();
                _CopyVariableValueToDouble(outputVariable, seqVec);
                foreach (var seq in seqVec)
                {
                    var seqList = seq as System.Collections.Generic.IList <T>;
                    if (seqList == null)
                    {
                        throw new System.TypeAccessException("Cannot convert to the value type.");
                    }
                    // It is required to create a new List from seq, since seq is dependent on the life cycle of seqVec.
                    sequences.Add(new System.Collections.Generic.List <T>(seqList));
                }
            }
            else
            {
                throw new System.ArgumentException("The value type does not match the list type.");
            }
            return(sequences);
        }
Ejemplo n.º 10
0
        public void CopyVariableValueTo <T>(Variable outputVariable, System.Collections.Generic.List <System.Collections.Generic.List <T> > sequences)
        {
            sequences.Clear();
            if (typeof(T).Equals(typeof(float)))
            {
                if (_GetDataType() != DataType.Float)
                {
                    throw new System.ArgumentException("The value type does not match the list type.");
                }

                var seqVec = new FloatVectorVector();
                _CopyVariableValueToFloat(outputVariable, seqVec);

                foreach (var seq in seqVec)
                {
                    var seqList = seq as System.Collections.Generic.IList <T>;
                    if (seqList == null)
                    {
                        throw new System.TypeAccessException("Cannot convert to the value type.");
                    }
                    sequences.Add(new System.Collections.Generic.List <T>(seqList));
                }
            }
            else if (typeof(T).Equals(typeof(double)))
            {
                if (_GetDataType() != DataType.Double)
                {
                    throw new System.ArgumentException("The value type does not match the list type.");
                }

                var seqVec = new DoubleVectorVector();
                _CopyVariableValueToDouble(outputVariable, seqVec);
                foreach (var seq in seqVec)
                {
                    var seqList = seq as System.Collections.Generic.IList <T>;
                    if (seqList == null)
                    {
                        throw new System.TypeAccessException("Cannot convert to the value type.");
                    }
                    sequences.Add(new System.Collections.Generic.List <T>(seqList));
                }
            }
            else
            {
                throw new System.ArgumentException("The value type does not match the list type.");
            }
        }
Ejemplo n.º 11
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(DoubleVectorVector obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }