/** * Creates an output label matrix * * @param outcomeLabel the outcome label to use * @return a binary vector where 1 is transform to the * index specified by outcomeLabel */ protected INDArray createOutputVector(int outcomeLabel) { return FeatureUtil.toOutcomeVector(outcomeLabel, numOutcomes); }
/** * Divides the input data transform * by the max number in each row */ @Override public void scale() { FeatureUtil.scaleByMax(getFeatures()); }
@Override public void scaleMinAndMax(double min, double max) { FeatureUtil.scaleMinMax(min, max, getFeatureMatrix()); }
/** * Fit the model * * @param examples the examples to classify (one example in each row) * @param labels the labels for each example (the number of labels must match */ @Override public void fit(INDArray examples, int[] labels) { INDArray outcomeMatrix = FeatureUtil.toOutcomeMatrix(labels, numLabels()); fit(examples, outcomeMatrix); }
/** * Fit the model * * @param examples the examples to classify (one example in each row) * @param labels the labels for each example (the number of labels must match */ @Override public void fit(INDArray examples, int[] labels) { INDArray outcomeMatrix = FeatureUtil.toOutcomeMatrix(labels, numLabels()); fit(examples, outcomeMatrix); }
/** * Sets the outcome of a particular example * * @param example the example to transform * @param label the label of the outcome */ @Override public void setOutcome(int example, int label) { if (example > numExamples()) throw new IllegalArgumentException("No example at " + example); if (label > numOutcomes() || label < 0) throw new IllegalArgumentException("Illegal label"); INDArray outcome = FeatureUtil.toOutcomeVector(label, numOutcomes()); getLabels().putRow(example, outcome); }
/** * Fit the model * * @param examples the examples to classify (one example in each row) * @param labels the labels for each example (the number of labels must match */ @Override public void fit(INDArray examples, int[] labels) { org.deeplearning4j.nn.conf.layers.OutputLayer layerConf = (org.deeplearning4j.nn.conf.layers.OutputLayer) getOutputLayer().conf().getLayer(); fit(examples, FeatureUtil.toOutcomeMatrix(labels, layerConf.getNOut())); }
/** * Divides the input data transform * by the max number in each row */ @Override public void scale() { FeatureUtil.scaleByMax(getFeatures()); }
@Override public void scaleMinAndMax(double min, double max) { FeatureUtil.scaleMinMax(min, max, getFeatureMatrix()); }
if (i2 == null) throw new IllegalStateException("Label not found on row " + i); INDArray newRow = FeatureUtil.toOutcomeVector(i2, labels.length); newLabelMatrix.putRow(i, newRow);
/** * Creates an output label matrix * * @param outcomeLabel the outcome label to use * @return a binary vector where 1 is transform to the * index specified by outcomeLabel */ protected INDArray createOutputVector(int outcomeLabel) { return FeatureUtil.toOutcomeVector(outcomeLabel, numOutcomes); }
/** * Creates an output label matrix * @param outcomeLabel the outcome label to use * @return a binary vector where 1 is transform to the * index specified by outcomeLabel */ protected INDArray createOutputVector(int outcomeLabel) { return FeatureUtil.toOutcomeVector(outcomeLabel, numOutcomes); }
/** * Creates an output label matrix * @param outcomeLabel the outcome label to use * @return a binary vector where 1 is applyTransformToDestination to the * index specified by outcomeLabel */ protected INDArray createOutputVector(int outcomeLabel) { return FeatureUtil.toOutcomeVector(outcomeLabel, numOutcomes); }
public Pair<INDArray, opencv_core.Mat> convertMat(byte[] byteFeature) { INDArray label = FeatureUtil.toOutcomeVector(byteFeature[0], NUM_LABELS);; // first value in the 3073 byte array opencv_core.Mat image = new opencv_core.Mat(HEIGHT, WIDTH, CV_8UC(CHANNELS)); // feature are 3072 ByteBuffer imageData = image.createBuffer(); for (int i = 0; i < HEIGHT * WIDTH; i++) { imageData.put(3 * i, byteFeature[i + 1 + 2 * HEIGHT * WIDTH]); // blue imageData.put(3 * i + 1, byteFeature[i + 1 + HEIGHT * WIDTH]); // green imageData.put(3 * i + 2, byteFeature[i + 1]); // red } // if (useSpecialPreProcessCifar) { // image = convertCifar(image); // } return new Pair<>(label, image); }
/** * Sets the outcome of a particular example * * @param example the example to transform * @param label the label of the outcome */ @Override public void setOutcome(int example, int label) { if (example > numExamples()) throw new IllegalArgumentException("No example at " + example); if (label > numOutcomes() || label < 0) throw new IllegalArgumentException("Illegal label"); INDArray outcome = FeatureUtil.toOutcomeVector(label, numOutcomes()); getLabels().putRow(example, outcome); }
vectorBatch.add( new DataSet( tmpPair.getFirst(), FeatureUtil.toOutcomeVector(tmpPair.getSecond().getInt(0),numOutcomes)));
if (i2 == null) throw new IllegalStateException("Label not found on row " + i); INDArray newRow = FeatureUtil.toOutcomeVector(i2, labels.length); newLabelMatrix.putRow(i, newRow);