Computes the first derivative of the HuberLoss loss

@param pred the predicted value
@param y the true value
@param c the threshold value
@return the first derivative of the HuberLoss loss
556260
public static double deriv(double pred, double y, double c)
    {
        double x = pred-y;

        if (Math.abs(x) <= c)
            return x;
        else
            return c * Math.signum(x);
    }
523813
public SVGPath relativeSmoothCubicTo(double c2x, double c2y, double x, double y) {
    return append(PATH_SMOOTH_CUBIC_TO_RELATIVE).append(c2x).append(c2y).append(x).append(y);
  }
1089705
public SDVariable huberLoss(String name, @NonNull SDVariable label, @NonNull SDVariable predictions, double delta) {
        return huberLoss(name, label, predictions, null, LossReduce.MEAN_BY_NONZERO_WEIGHT_COUNT, delta);
    }
75433
def cor(y_true, y_pred):
    
    y_true, y_pred = _mask_nan(y_true, y_pred)
    return np.corrcoef(y_true, y_pred)[0, 1]
316337
protected static double subtractedMagnitudeSqrd(DoubleVector c,
                                                   DoubleVector v) {
        if (v instanceof SparseDoubleVector) {
            SparseDoubleVector sv = (SparseDoubleVector) v;
            int[] nonZeros = sv.getNonZeroIndices();

            double magnitude = Math.pow(c.magnitude(), 2);
            for (int i : nonZeros) {
                double value = c.get(i);
                magnitude -= Math.pow(value, 2);
                magnitude += Math.pow(value - v.get(i), 2);
            }
            return magnitude;
        } else {
            double magnitude = 0;
            for (int i = 0; i < c.length(); ++i)
                magnitude += Math.pow(c.get(i) - v.get(i), 2);
            return magnitude;
        }
    }
211442
def cnst_A0T(self, Y0):
        
        """

        # This calculation involves non-negligible computational cost. It
        # should be possible to disable relevant diagnostic information
        # (dual residual) to avoid this cost.
        Y0f = sl.rfftn(Y0, None, self.cri.axisN)
        return sl.irfftn(sl.inner(np.conj(self.Zf), Y0f,
                                  axis=self.cri.axisK), self.cri.Nv,
                         self.cri.axisN)
505958
int getTertiaryBefore(long p, int s, int t) {
        assert((t & ~Collation.ONLY_TERTIARY_MASK) == 0);
        int index;
        int previousTer;
        long secTer;
        if(p == 0) {
            if(s == 0) {
                index = (int)elements[IX_FIRST_TERTIARY_INDEX];
                // Gap at the beginning of the tertiary CE range.
                previousTer = 0;
            } else {
                index = (int)elements[IX_FIRST_SECONDARY_INDEX];
                previousTer = Collation.BEFORE_WEIGHT16;
            }
            secTer = elements[index] & ~SEC_TER_DELTA_FLAG;
        } else {
            index = findPrimary(p) + 1;
            previousTer = Collation.BEFORE_WEIGHT16;
            secTer = getFirstSecTerForPrimary(index);
        }
        long st = ((long)s << 16) | t;
        while(st > secTer) {
            if((int)(secTer >> 16) == s) { previousTer = (int)secTer; }
            assert((elements[index] & SEC_TER_DELTA_FLAG) != 0);
            secTer = elements[index++] & ~SEC_TER_DELTA_FLAG;
        }
        assert(secTer == st);
        return previousTer & 0xffff;
    }
1196098
public static void ycbcrToRgb( int y , int cb , int cr , byte rgb[] ) {
		// multiply coefficients in book by 1024, which is 2^10
		y = 1191*(y - 16);
		if( y < 0 ) y = 0;
		cb -= 128;
		cr -= 128;

		int r = (y + 1836*cr) >> 10;
		int g = (y - 547*cr - 218*cb) >> 10;
		int b = (y + 2165*cb) >> 10;

		if( r < 0 ) r = 0;
		else if( r > 255 ) r = 255;
		if( g < 0 ) g = 0;
		else if( g > 255 ) g = 255;
		if( b < 0 ) b = 0;
		else if( b > 255 ) b = 255;

		rgb[0] = (byte)r;
		rgb[1] = (byte)g;
		rgb[2] = (byte)b;
	}
293633
def _huber_loss(x, delta=1.0):
    """"""
    return tf.where(
        tf.abs(x) < delta,
        tf.square(x) * 0.5, delta * (tf.abs(x) - 0.5 * delta))
977837
def fbeta(y_pred:Tensor, y_true:Tensor, thresh:float=0.2, beta:float=2, eps:float=1e-9, sigmoid:bool=True)->Rank0Tensor:
    ""
    beta2 = beta ** 2
    if sigmoid: y_pred = y_pred.sigmoid()
    y_pred = (y_pred>thresh).float()
    y_true = y_true.float()
    TP = (y_pred*y_true).sum(dim=1)
    prec = TP/(y_pred.sum(dim=1)+eps)
    rec = TP/(y_true.sum(dim=1)+eps)
    res = (prec*rec)/(prec*beta2+rec+eps)*(1+beta2)
    return res.mean()
284388
public static void multAdd_zeros(final int blockLength ,
                                     final DSubmatrixD1 Y , final DSubmatrixD1 B ,
                                     final DSubmatrixD1 C )
    {
        int widthY = Y.col1 - Y.col0;

        for( int i = Y.row0; i < Y.row1; i += blockLength ) {
            int heightY = Math.min( blockLength , Y.row1 - i );

            for( int j = B.col0; j < B.col1; j += blockLength ) {
                int widthB = Math.min( blockLength , B.col1 - j );

                int indexC = (i-Y.row0+C.row0)*C.original.numCols + (j-B.col0+C.col0)*heightY;

                for( int k = Y.col0; k < Y.col1; k += blockLength ) {
                    int indexY = i*Y.original.numCols + k*heightY;
                    int indexB = (k-Y.col0+B.row0)*B.original.numCols + j*widthY;

                    if( i == Y.row0 ) {
                        multBlockAdd_zerosone(Y.original.data,B.original.data,C.original.data,
                            indexY,indexB,indexC,heightY,widthY,widthB);
                    } else {
                        InnerMultiplication_DDRB.blockMultPlus(Y.original.data,B.original.data,C.original.data,
                                indexY,indexB,indexC,heightY,widthY,widthB);
                    }
                }
            }
        }
    }
418685
def tpr(y_true, y_pred, round=True):
    
    y_true, y_pred = _mask_value_nan(y_true, y_pred)
    if round:
        y_true = np.round(y_true)
        y_pred = np.round(y_pred)
    return skm.recall_score(y_true, y_pred)
805469
def cnst_A0T(self, Y0):
        
        """

        # This calculation involves non-negligible computational cost. It
        # should be possible to disable relevant diagnostic information
        # (dual residual) to avoid this cost.
        Y0f = sl.rfftn(Y0, None, self.cri.axisN)
        return sl.irfftn(
            sl.dot(self.B.T, np.conj(self.Df) * Y0f, axis=self.cri.axisC),
                   self.cri.Nv, self.cri.axisN)
726052
public double gradient(double[] expected)
    {
        if (x_.isEmpty())
        {
            return 0.0;
        }
        buildLattice();
        forwardbackward();
        double s = 0.0;

        for (int i = 0; i < x_.size(); i++)
        {
            for (int j = 0; j < ysize_; j++)
            {
                node_.get(i).get(j).calcExpectation(expected, Z_, ysize_);
            }
        }
        for (int i = 0; i < x_.size(); i++)
        {
            List<Integer> fvector = node_.get(i).get(answer_.get(i)).fVector;
            for (int j = 0; fvector.get(j) != -1; j++)
            {
                int idx = fvector.get(j) + answer_.get(i);
                expected[idx]--;
            }
            s += node_.get(i).get(answer_.get(i)).cost; //UNIGRAM COST
            List<Path> lpath = node_.get(i).get(answer_.get(i)).lpath;
            for (Path p : lpath)
            {
                if (p.lnode.y == answer_.get(p.lnode.x))
                {
                    for (int k = 0; p.fvector.get(k) != -1; k++)
                    {
                        int idx = p.fvector.get(k) + p.lnode.y * ysize_ + p.rnode.y;
                        expected[idx]--;
                    }
                    s += p.cost;  // BIGRAM COST
                    break;
                }
            }
        }

        viterbi();
        return Z_ - s;
    }
725458
def cnst_A0T(self, Y0):
        
        """

        # This calculation involves non-negligible computational cost. It
        # should be possible to disable relevant diagnostic information
        # (dual residual) to avoid this cost.
        Y0f = sl.rfftn(Y0, None, self.cri.axisN)
        if self.cri.Cd == 1:
            return sl.irfftn(np.conj(self.Df) * Y0f, self.cri.Nv,
                             self.cri.axisN)
        else:
            return sl.irfftn(sl.inner(
                np.conj(self.Df), Y0f, axis=self.cri.axisC),
                self.cri.Nv, self.cri.axisN)
726272
public double computePredictedReduction( DMatrixRMaj p ) {
		return -CommonOps_DDRM.dot(gradient,p) - 0.5*hessian.innerVectorHessian(p);
	}
2706
private void calcRmsd(Point3d[] x, Point3d[] y) {
		if (centered) {
			innerProduct(y, x);
		} else {
			// translate to origin
			xref = CalcPoint.clonePoint3dArray(x);
			xtrans = CalcPoint.centroid(xref);
			logger.debug("x centroid: " + xtrans);
			xtrans.negate();
			CalcPoint.translate(new Vector3d(xtrans), xref);

			yref = CalcPoint.clonePoint3dArray(y);
			ytrans = CalcPoint.centroid(yref);
			logger.debug("y centroid: " + ytrans);
			ytrans.negate();
			CalcPoint.translate(new Vector3d(ytrans), yref);
			innerProduct(yref, xref);
		}
		calcRmsd(wsum);
	}