Ejemplo n.º 1
0
        public override NDArray Call(NDArray w)
        {
            var norms   = NDArray.Sqrt(NDArray.Square(w));
            var desired = NDArray.Clip(norms, 0, MaxValue);

            w *= (desired / (norms + float.Epsilon));
            return(w);
        }
Ejemplo n.º 2
0
        public override NDArray Call(NDArray w)
        {
            var norms   = NDArray.Sqrt(NDArray.Sum(NDArray.Square(w), new Shape(Axis), true));
            var desired = (NDArray.Clip(norms, MinValue, MaxValue) * Rate) + (norms * (1 - Rate));

            w *= desired / (norms + float.Epsilon);
            return(w);
        }
Ejemplo n.º 3
0
        public override void Update(NDArray labels, NDArray preds)
        {
            CheckLabelShapes(labels, preds, true);

            preds = preds.Clip(0, 1);
            var label = labels.Ravel();

            preds = preds.Ravel() > Threshold;

            var num_correct = nd.Equal(preds, label).AsType(DType.Float32).Sum();

            sum_metric        += num_correct;
            global_sum_metric += num_correct;
            num_inst          += preds.Shape.Size;
            global_num_inst   += preds.Shape.Size;
        }