Exemple #1
0
        /// <summary>
        /// Reshape the layer.
        /// </summary>
        /// <param name="colBottom">Specifies the collection of bottom (input) Blobs.</param>
        /// <param name="colTop">Specifies the collection of top (output) Blobs.</param>
        public override void Reshape(BlobCollection <T> colBottom, BlobCollection <T> colTop)
        {
            base.Reshape(colBottom, colTop);

            m_blobSigmoidInput.ReshapeLike(colBottom[0]);
            m_sigmoidLayer.Reshape(m_colSigmoidBottom, m_colSigmoidTop);
        }
        /// <summary>
        /// Reshape the bottom (input) and top (output) blobs.
        /// </summary>
        /// <param name="colBottom">Specifies the collection of bottom (input) Blobs.</param>
        /// <param name="colTop">Specifies the collection of top (output) Blobs.</param>
        public override void Reshape(BlobCollection <T> colBottom, BlobCollection <T> colTop)
        {
            base.Reshape(colBottom, colTop);
            m_nOuterNum = colBottom[0].shape(0); // batch size
            m_nInnerNum = colBottom[0].count(1); // instance size: |output| == |target|

            if (colBottom[0].count() != colBottom[1].count())
            {
                if (colBottom[1].count() != colBottom[0].num)
                {
                    m_log.FAIL("SIGMOID_CROSS_ENTROPY_LOSS layer inputs must have the same count, or the target must have 'num' items of indexes.");
                }

                // Set the label at the target index = 1.0
                if (m_blobTarget == null)
                {
                    m_blobTarget      = new Blob <T>(m_cuda, m_log);
                    m_blobTarget.Name = "full_label";
                }

                m_blobTarget.ReshapeLike(colBottom[0]);
            }

            m_sigmoidLayer.Reshape(m_colSigmoidBottomVec, m_colSigmoidTopVec);
            m_blobLoss.ReshapeLike(colBottom[0]);
        }
 /// <summary>
 /// Reshape the bottom (input) and top (output) blobs.
 /// </summary>
 /// <param name="colBottom">Specifies the collection of bottom (input) Blobs.</param>
 /// <param name="colTop">Specifies the collection of top (output) Blobs.</param>
 public override void Reshape(BlobCollection <T> colBottom, BlobCollection <T> colTop)
 {
     base.Reshape(colBottom, colTop);
     m_nOuterNum = colBottom[0].shape(0); // batch size
     m_nInnerNum = colBottom[0].count(1); // instance size: |output| == |target|
     m_log.CHECK_EQ(colBottom[0].count(), colBottom[1].count(), "SIGMOID_CROSS_ENTROPY_LOSS layer inputs must have the same count.");
     m_sigmoidLayer.Reshape(m_colSigmoidBottomVec, m_colSigmoidTopVec);
 }