Search in sources :

Example 1 with JsonIgnore

use of org.nd4j.shade.jackson.annotation.JsonIgnore in project deeplearning4j by deeplearning4j.

the class HistogramBin method calcHistogram.

@JsonIgnore
private synchronized void calcHistogram() {
    max = sourceArray.maxNumber().doubleValue();
    min = sourceArray.minNumber().doubleValue();
    // TODO: there's probably better way to get around of possible NaNs in max/min
    if (Double.isInfinite(max))
        max = Float.MAX_VALUE;
    if (Double.isNaN(max))
        max = Float.MIN_VALUE;
    if (Double.isInfinite(min))
        min = Float.MAX_VALUE;
    if (Double.isNaN(min))
        min = Float.MIN_VALUE;
    bins = Nd4j.create(numberOfBins);
    final double binSize = (max - min) / (numberOfBins - 1);
    data = new LinkedHashMap<>();
    BigDecimal[] keys = new BigDecimal[numberOfBins];
    for (int x = 0; x < numberOfBins; x++) {
        BigDecimal pos = new BigDecimal((min + (x * binSize))).setScale(rounds, BigDecimal.ROUND_CEILING);
        data.put(pos, new AtomicInteger(0));
        keys[x] = pos;
    }
    for (int x = 0; x < sourceArray.length(); x++) {
        double d = sourceArray.getDouble(x);
        int bin = (int) ((d - min) / binSize);
        if (bin < 0) {
            bins.putScalar(0, bins.getDouble(0) + 1);
            data.get(keys[0]).incrementAndGet();
        } else if (bin >= numberOfBins) {
            bins.putScalar(numberOfBins - 1, bins.getDouble(numberOfBins - 1) + 1);
            data.get(keys[numberOfBins - 1]).incrementAndGet();
        } else {
            bins.putScalar(bin, bins.getDouble(bin) + 1);
            data.get(keys[bin]).incrementAndGet();
        }
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BigDecimal(java.math.BigDecimal) JsonIgnore(org.nd4j.shade.jackson.annotation.JsonIgnore)

Example 2 with JsonIgnore

use of org.nd4j.shade.jackson.annotation.JsonIgnore in project nd4j by deeplearning4j.

the class DifferentialFunction method getZ.

@JsonIgnore
private INDArray getZ() {
    if (isInPlace())
        return getX();
    SDVariable opId = outputVariables()[0];
    INDArray ret = opId.getArr();
    return ret;
}
Also used : SDVariable(org.nd4j.autodiff.samediff.SDVariable) INDArray(org.nd4j.linalg.api.ndarray.INDArray) JsonIgnore(org.nd4j.shade.jackson.annotation.JsonIgnore)

Aggregations

JsonIgnore (org.nd4j.shade.jackson.annotation.JsonIgnore)2 BigDecimal (java.math.BigDecimal)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 SDVariable (org.nd4j.autodiff.samediff.SDVariable)1 INDArray (org.nd4j.linalg.api.ndarray.INDArray)1