예제 #1
0
        /// <summary>
        /// 训练前的准备工作,检查并确定所需Tensor的结构并分配好内存
        /// </summary>
        /// <param name="y">样本标签</param>
        /// <param name="yHat">输出标签</param>
        public override void PrepareTrain(TensorOld y, TensorOld yHat)
        {
            TensorOld.CheckShape(y, yHat);

            ForwardOutput  = y.GetSameShape();
            BackwardOutput = y.GetSameShape();
        }
예제 #2
0
        public static TensorOld MeanSquareError(TensorOld y, TensorOld yHat)
        {
            TensorOld.CheckShape(y, yHat);

            var result = y.GetSameShape();

            MeanSquareError(y, yHat, result);
            return(result);
        }
예제 #3
0
        /// <summary>
        /// 训练前的准备工作,检查并确定所需Tensor的结构并分配好内存
        /// </summary>
        /// <param name="y">样本标签</param>
        /// <param name="yHat">输出标签</param>
        public override void PrepareTrain(TensorOld y, TensorOld yHat)
        {
            TensorOld.CheckShape(y, yHat);
            if (y.Rank != 2)
            {
                throw new TensorShapeException("y and yHat must Rank=2");
            }

            ForwardOutput  = new TensorOld(y.shape[0]);
            BackwardOutput = yHat.GetSameShape();
            yBuff          = new double[y.shape[1]];
            yHatBuff       = new double[y.shape[1]];
            derBuff        = new double[y.shape[1]];
            sampleNumber   = y.Shape[0];
        }