Exemplo n.º 1
0
        /// <summary>
        /// Copy the collection and return it as a new collection.
        /// </summary>
        /// <returns>The new collection is returned.</returns>
        public BlobCollection <T> Clone()
        {
            BlobCollection <T> col = new BlobCollection <T>();

            foreach (Blob <T> b in m_rgBlobs)
            {
                col.Add(b.Clone());
            }

            return(col);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads a new collection from a binary reader.
        /// </summary>
        /// <param name="cuda">Specifies the instance of CudaDnn to use for the Cuda connection.</param>
        /// <param name="log">Specifies the Log to use for output.</param>
        /// <param name="br">Specifies the binary reader.</param>
        /// <param name="bData">Specifies whether or not to read the data.</param>
        /// <param name="bDiff">Specifies whether or not to read the diff.</param>
        /// <returns></returns>
        public static BlobCollection <T> Load(CudaDnn <T> cuda, Log log, BinaryReader br, bool bData, bool bDiff)
        {
            BlobCollection <T> col = new BlobCollection <T>();
            int nCount             = br.ReadInt32();

            for (int i = 0; i < nCount; i++)
            {
                col.Add(Blob <T> .Load(cuda, log, br, bData, bDiff));
            }

            return(col);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Find all Blobs in the collection that contain (in part or in whole) the name of a given Blob.
        /// </summary>
        /// <param name="b">Specifies the Blob to look for.</param>
        /// <returns>A new collection of all Blobs that match are returned.</returns>
        public BlobCollection <T> FindRelatedBlobs(Blob <T> b)
        {
            BlobCollection <T> rg = new BlobCollection <T>();

            foreach (Blob <T> b1 in m_rgBlobs)
            {
                if (b1 != null && b1.Name.Contains(b.Name))
                {
                    rg.Add(b1);
                }
            }

            return(rg);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create a new collection of cloned Blobs created by calling MathDif to divide the Blobs in this collection with a scalar.
        /// </summary>
        /// <param name="dfVal">Specifies the divisor.</param>
        /// <param name="bSkipFirstItem">Specifies whether or not to skip the first item.</param>
        /// <returns></returns>
        public BlobCollection <T> MathDiv(double dfVal, bool bSkipFirstItem)
        {
            BlobCollection <T> colOut = new BlobCollection <T>();
            T fVal = (T)Convert.ChangeType(dfVal, typeof(T));

            for (int i = 0; i < m_rgBlobs.Count; i++)
            {
                if (i > 0 || !bSkipFirstItem)
                {
                    colOut.Add(m_rgBlobs[i].MathDiv(fVal));
                }
            }

            return(colOut);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Create a new collection of cloned Blobs created by calling MathSub to subtract the Blobs in this collection from another collection.
        /// </summary>
        /// <remarks>
        /// Calculation: Y = Clone(colA) - this
        /// </remarks>
        /// <param name="col">Specifies the collection that this collection will be subtracted from.</param>
        /// <param name="bSkipFirstItem">Specifies whether or not to skip the first item.</param>
        /// <returns></returns>
        public BlobCollection <T> MathSub(BlobCollection <T> col, bool bSkipFirstItem)
        {
            if (col.Count != m_rgBlobs.Count)
            {
                throw new Exception("The input blob collection must have the same count at this blob collection!");
            }

            BlobCollection <T> colOut = new BlobCollection <T>();

            for (int i = 0; i < m_rgBlobs.Count; i++)
            {
                if (i > 0 || !bSkipFirstItem)
                {
                    colOut.Add(m_rgBlobs[i].MathSub(col[i]));
                }
            }

            return(colOut);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Create a new collection of cloned Blobs created by calling MathAdd to add the Blobs in this collection to another collection.
        /// </summary>
        /// <remarks>
        /// Calculation: Y = Clone(colA) * dfScale + this
        /// </remarks>
        /// <param name="colA">Specifies the collection that will be cloned.</param>
        /// <param name="dfScale">Specifies the scale that will be applied to the clone of this collection</param>
        /// <param name="bSkipFirstItem">Specifies whether or not to skip the first item.</param>
        /// <returns></returns>
        public BlobCollection <T> MathAdd(BlobCollection <T> colA, double dfScale, bool bSkipFirstItem)
        {
            if (colA.Count != m_rgBlobs.Count)
            {
                throw new Exception("The input blob collection must have the same count at this blob collection!");
            }

            BlobCollection <T> colOut = new BlobCollection <T>();
            T fScale = (T)Convert.ChangeType(dfScale, typeof(T));

            for (int i = 0; i < m_rgBlobs.Count; i++)
            {
                if (i > 0 || !bSkipFirstItem)
                {
                    colOut.Add(m_rgBlobs[i].MathAdd(colA[i], fScale));
                }
            }

            return(colOut);
        }