示例#1
0
 public ConstantVector(ConstantVector other) : this(CNTKLibPINVOKE.new_ConstantVector__SWIG_1(ConstantVector.getCPtr(other)), true)
 {
     if (CNTKLibPINVOKE.SWIGPendingException.Pending)
     {
         throw CNTKLibPINVOKE.SWIGPendingException.Retrieve();
     }
 }
示例#2
0
 public ConstantVectorEnumerator(ConstantVector collection)
 {
     collectionRef = collection;
     currentIndex  = -1;
     currentObject = null;
     currentSize   = collectionRef.Count;
 }
示例#3
0
 public void SetRange(int index, ConstantVector values)
 {
     CNTKLibPINVOKE.ConstantVector_SetRange(swigCPtr, index, ConstantVector.getCPtr(values));
     if (CNTKLibPINVOKE.SWIGPendingException.Pending)
     {
         throw CNTKLibPINVOKE.SWIGPendingException.Retrieve();
     }
 }
示例#4
0
文件: Function.cs 项目: nietras/CNTK
        public ConstantVector Constants()
        {
            ConstantVector ret = new ConstantVector(CNTKLibPINVOKE.Function_Constants(swigCPtr), true);

            if (CNTKLibPINVOKE.SWIGPendingException.Pending)
            {
                throw CNTKLibPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#5
0
        public static ConstantVector Repeat(Constant value, int count)
        {
            global::System.IntPtr cPtr = CNTKLibPINVOKE.ConstantVector_Repeat(Constant.getCPtr(value), count);
            ConstantVector        ret  = (cPtr == global::System.IntPtr.Zero) ? null : new ConstantVector(cPtr, true);

            if (CNTKLibPINVOKE.SWIGPendingException.Pending)
            {
                throw CNTKLibPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#6
0
        public ConstantVector GetRange(int index, int count)
        {
            global::System.IntPtr cPtr = CNTKLibPINVOKE.ConstantVector_GetRange(swigCPtr, index, count);
            ConstantVector        ret  = (cPtr == global::System.IntPtr.Zero) ? null : new ConstantVector(cPtr, true);

            if (CNTKLibPINVOKE.SWIGPendingException.Pending)
            {
                throw CNTKLibPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#7
0
        /// <summary>
        /// Given a transition and the residual weight of its source state, adds weighted non-zero probability character segments
        /// associated with the transition to the list.
        /// </summary>
        /// <param name="transition">The transition.</param>
        /// <param name="sourceStateResidualWeight">The logarithm of the residual weight of the source state of the transition.</param>
        /// <param name="bounds">The list for storing numbered segment bounds.</param>
        private static void AddTransitionCharSegmentBounds(
            Transition transition, Weight sourceStateResidualWeight, List <Tuple <int, TransitionCharSegmentBound> > bounds)
        {
            var    probs            = (PiecewiseVector)transition.ElementDistribution.GetProbs();
            int    commonValueStart = char.MinValue;
            Weight commonValue      = Weight.FromValue(probs.CommonValue);
            Weight weightBase       = Weight.Product(transition.Weight, sourceStateResidualWeight);
            TransitionCharSegmentBound newSegmentBound;

            ////if (double.IsInfinity(weightBase.Value))
            ////{
            ////    Console.WriteLine("Weight base infinity");
            ////}

            for (int i = 0; i < probs.Pieces.Count; ++i)
            {
                ConstantVector piece = probs.Pieces[i];
                if (piece.Start > commonValueStart && !commonValue.IsZero)
                {
                    // Add endpoints for the common value
                    Weight segmentWeight = Weight.Product(commonValue, weightBase);
                    newSegmentBound = new TransitionCharSegmentBound(commonValueStart, transition.DestinationStateIndex, segmentWeight, true);
                    bounds.Add(new Tuple <int, TransitionCharSegmentBound>(bounds.Count, newSegmentBound));
                    newSegmentBound = new TransitionCharSegmentBound(piece.Start, transition.DestinationStateIndex, segmentWeight, false);
                    bounds.Add(new Tuple <int, TransitionCharSegmentBound>(bounds.Count, newSegmentBound));
                }

                // Add segment endpoints
                Weight pieceValue = Weight.FromValue(piece.Value);
                if (!pieceValue.IsZero)
                {
                    Weight segmentWeight = Weight.Product(pieceValue, weightBase);
                    newSegmentBound = new TransitionCharSegmentBound(piece.Start, transition.DestinationStateIndex, segmentWeight, true);
                    bounds.Add(new Tuple <int, TransitionCharSegmentBound>(bounds.Count, newSegmentBound));
                    newSegmentBound = new TransitionCharSegmentBound(piece.End + 1, transition.DestinationStateIndex, segmentWeight, false);
                    bounds.Add(new Tuple <int, TransitionCharSegmentBound>(bounds.Count, newSegmentBound));
                }

                commonValueStart = piece.End + 1;
            }

            if (!commonValue.IsZero && (probs.Pieces.Count == 0 || probs.Pieces[probs.Pieces.Count - 1].End != char.MaxValue))
            {
                // Add endpoints for the last common value segment
                Weight segmentWeight = Weight.Product(commonValue, weightBase);
                newSegmentBound = new TransitionCharSegmentBound(commonValueStart, transition.DestinationStateIndex, segmentWeight, true);
                bounds.Add(new Tuple <int, TransitionCharSegmentBound>(bounds.Count, newSegmentBound));
                newSegmentBound = new TransitionCharSegmentBound(char.MaxValue + 1, transition.DestinationStateIndex, segmentWeight, false);
                bounds.Add(new Tuple <int, TransitionCharSegmentBound>(bounds.Count, newSegmentBound));
            }
        }
示例#8
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ConstantVector obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }