Java Code Examples for org.nd4j.linalg.dataset.api.MultiDataSet#numFeatureArrays()

The following examples show how to use org.nd4j.linalg.dataset.api.MultiDataSet#numFeatureArrays() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractMultiDataSetNormalizer.java    From nd4j with Apache License 2.0 6 votes vote down vote up
private void fitPartial(MultiDataSet dataSet, List<S.Builder> featureStatsBuilders,
                List<S.Builder> labelStatsBuilders) {
    int numInputs = dataSet.numFeatureArrays();
    int numOutputs = dataSet.numLabelsArrays();

    ensureStatsBuilders(featureStatsBuilders, numInputs);
    ensureStatsBuilders(labelStatsBuilders, numOutputs);

    for (int i = 0; i < numInputs; i++) {
        featureStatsBuilders.get(i).add(dataSet.getFeatures(i), dataSet.getFeaturesMaskArray(i));
    }

    if (isFitLabel()) {
        for (int i = 0; i < numOutputs; i++) {
            labelStatsBuilders.get(i).add(dataSet.getLabels(i), dataSet.getLabelsMaskArray(i));
        }
    }
}
 
Example 2
Source File: AbstractMultiDataSetNormalizer.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
private void fitPartial(MultiDataSet dataSet, List<S.Builder> featureStatsBuilders,
                List<S.Builder> labelStatsBuilders) {
    int numInputs = dataSet.numFeatureArrays();
    int numOutputs = dataSet.numLabelsArrays();

    ensureStatsBuilders(featureStatsBuilders, numInputs);
    ensureStatsBuilders(labelStatsBuilders, numOutputs);

    for (int i = 0; i < numInputs; i++) {
        featureStatsBuilders.get(i).add(dataSet.getFeatures(i), dataSet.getFeaturesMaskArray(i));
    }

    if (isFitLabel()) {
        for (int i = 0; i < numOutputs; i++) {
            labelStatsBuilders.get(i).add(dataSet.getLabels(i), dataSet.getLabelsMaskArray(i));
        }
    }
}
 
Example 3
Source File: AbstractMultiDataSetNormalizer.java    From nd4j with Apache License 2.0 5 votes vote down vote up
/**
 * Pre process a MultiDataSet
 *
 * @param toPreProcess the data set to pre process
 */
@Override
public void preProcess(@NonNull MultiDataSet toPreProcess) {
    int numFeatures = toPreProcess.numFeatureArrays();
    int numLabels = toPreProcess.numLabelsArrays();

    for (int i = 0; i < numFeatures; i++) {
        strategy.preProcess(toPreProcess.getFeatures(i), toPreProcess.getFeaturesMaskArray(i), getFeatureStats(i));
    }
    if (isFitLabel()) {
        for (int i = 0; i < numLabels; i++) {
            strategy.preProcess(toPreProcess.getLabels(i), toPreProcess.getLabelsMaskArray(i), getLabelStats(i));
        }
    }
}
 
Example 4
Source File: AbstractMultiDataSetNormalizer.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
/**
 * Pre process a MultiDataSet
 *
 * @param toPreProcess the data set to pre process
 */
@Override
public void preProcess(@NonNull MultiDataSet toPreProcess) {
    int numFeatures = toPreProcess.numFeatureArrays();
    int numLabels = toPreProcess.numLabelsArrays();

    for (int i = 0; i < numFeatures; i++) {
        strategy.preProcess(toPreProcess.getFeatures(i), toPreProcess.getFeaturesMaskArray(i), getFeatureStats(i));
    }
    if (isFitLabel()) {
        for (int i = 0; i < numLabels; i++) {
            strategy.preProcess(toPreProcess.getLabels(i), toPreProcess.getLabelsMaskArray(i), getLabelStats(i));
        }
    }
}
 
Example 5
Source File: ScoreListener.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
@Override
public void iterationDone(SameDiff sd, At at, MultiDataSet dataSet, Loss loss) {
    iterTimeSumSinceLastReport += System.currentTimeMillis() - lastIterTime;
    epochBatchCount++;
    if (dataSet.numFeatureArrays() > 0 && dataSet.getFeatures(0) != null) {
        int n = (int) dataSet.getFeatures(0).size(0);
        examplesSinceLastReportIter += n;
        epochExampleCount += n;
    }

    if (at.iteration() > 0 && at.iteration() % frequency == 0) {
        double l = loss.totalLoss();
        String etl = "";
        if (etlTimeSumSinceLastReport > 0) {
            etl = "(" + formatDurationMs(etlTimeSumSinceLastReport) + " ETL";
            if (frequency == 1) {
                etl += ")";
            } else {
                etl += " in " + frequency + " iter)";
            }
        }

        if(!reportIterPerformance) {
            log.info("Loss at epoch {}, iteration {}: {}{}", at.epoch(), at.iteration(), format5dp(l), etl);
        } else {
            long time = System.currentTimeMillis();
            if(lastReportTime > 0){
                double batchPerSec = 1000 * frequency / (double)(time - lastReportTime);
                double exPerSec = 1000 * examplesSinceLastReportIter / (double)(time - lastReportTime);
                log.info("Loss at epoch {}, iteration {}: {}{}, batches/sec: {}, examples/sec: {}", at.epoch(), at.iteration(), format5dp(l),
                        etl, format5dp(batchPerSec), format5dp(exPerSec));
            } else {
                log.info("Loss at epoch {}, iteration {}: {}{}", at.epoch(), at.iteration(), format5dp(l), etl);
            }

            lastReportTime = time;
        }

        iterTimeSumSinceLastReport = 0;
        etlTimeSumSinceLastReport = 0;
        examplesSinceLastReportIter = 0;
    }
}