code
stringlengths 11
173k
| docstring
stringlengths 2
593k
| func_name
stringlengths 2
189
| language
stringclasses 1
value | repo
stringclasses 844
values | path
stringlengths 11
294
| url
stringlengths 60
339
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
public ROC(int thresholdSteps, boolean rocRemoveRedundantPts, int exactAllocBlockSize) {
if (thresholdSteps > 0) {
this.thresholdSteps = thresholdSteps;
double step = 1.0 / thresholdSteps;
for (int i = 0; i <= thresholdSteps; i++) {
double currThreshold = i * step;
counts.put(currThreshold, new CountsForThreshold(currThreshold));
}
isExact = false;
} else {
//Exact
isExact = true;
}
this.rocRemoveRedundantPts = rocRemoveRedundantPts;
this.exactAllocBlockSize = exactAllocBlockSize;
} |
@param thresholdSteps Number of threshold steps to use for the ROC calculation. If set to 0: use exact calculation
@param rocRemoveRedundantPts Usually set to true. If true, remove any redundant points from ROC and P-R curves
@param exactAllocBlockSize if using exact mode, the block size relocation. Users can likely use the default
setting in almost all cases
| Metric::ROC | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROC.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROC.java | Apache-2.0 |
public Evaluation(int numClasses) {
this(numClasses, (numClasses == 2 ? 1 : null));
} |
The number of classes to account for in the evaluation
@param numClasses the number of classes to account for in the evaluation
| JsonDeserialize::Evaluation | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public Evaluation(int numClasses, Integer binaryPositiveClass){
this(createLabels(numClasses), 1);
if(binaryPositiveClass != null){
Preconditions.checkArgument(binaryPositiveClass == 0 || binaryPositiveClass == 1,
"Only 0 and 1 are valid inputs for binaryPositiveClass; got " + binaryPositiveClass);
Preconditions.checkArgument(numClasses == 2, "Cannot set binaryPositiveClass argument " +
"when number of classes is not equal to 2 (got: numClasses=" + numClasses + ")");
}
this.binaryPositiveClass = binaryPositiveClass;
} |
Constructor for specifying the number of classes, and optionally the positive class for binary classification.
See Evaluation javadoc for more details on evaluation in the binary case
@param numClasses The number of classes for the evaluation. Must be 2, if binaryPositiveClass is non-null
@param binaryPositiveClass If non-null, the positive class (0 or 1).
| JsonDeserialize::Evaluation | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public Evaluation(List<String> labels) {
this(labels, 1);
} |
The labels to include with the evaluation.
This constructor can be used for
generating labeled output rather than just
numbers for the labels
@param labels the labels to use
for the output
| JsonDeserialize::Evaluation | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public Evaluation(Map<Integer, String> labels) {
this(createLabelsFromMap(labels), 1);
} |
Use a map to generate labels
Pass in a label index with the actual label
you want to use for output
@param labels a map of label index to label value
| JsonDeserialize::Evaluation | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public Evaluation(List<String> labels, int topN) {
this.labelsList = labels;
if (labels != null) {
createConfusion(labels.size());
}
this.topN = topN;
if(labels != null && labels.size() == 2){
this.binaryPositiveClass = 1;
}
} |
Constructor to use for top N accuracy
@param labels Labels for the classes (may be null)
@param topN Value to use for top N accuracy calculation (<=1: standard accuracy). Note that with top N
accuracy, an example is considered 'correct' if the probability for the true class is one of the
highest N values
| JsonDeserialize::Evaluation | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public Evaluation(double binaryDecisionThreshold) {
this(binaryDecisionThreshold, 1);
} |
Create an evaluation instance with a custom binary decision threshold. Note that binary decision thresholds can
only be used with binary classifiers.<br>
Defaults to class 1 for the positive class - see class javadoc, and use {@link #Evaluation(double, Integer)} to
change this.
@param binaryDecisionThreshold Decision threshold to use for binary predictions
| JsonDeserialize::Evaluation | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public Evaluation(double binaryDecisionThreshold, @NonNull Integer binaryPositiveClass) {
if(binaryPositiveClass != null){
Preconditions.checkArgument(binaryPositiveClass == 0 || binaryPositiveClass == 1,
"Only 0 and 1 are valid inputs for binaryPositiveClass; got " + binaryPositiveClass);
}
this.binaryDecisionThreshold = binaryDecisionThreshold;
this.topN = 1;
this.binaryPositiveClass = binaryPositiveClass;
} |
Create an evaluation instance with a custom binary decision threshold. Note that binary decision thresholds can
only be used with binary classifiers.<br>
This constructor also allows the user to specify the positive class for binary classification. See class javadoc
for more details.
@param binaryDecisionThreshold Decision threshold to use for binary predictions
| JsonDeserialize::Evaluation | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public Evaluation(INDArray costArray) {
this(null, costArray);
} |
Created evaluation instance with the specified cost array. A cost array can be used to bias the multi class
predictions towards or away from certain classes. The predicted class is determined using argMax(cost * probability)
instead of argMax(probability) when no cost array is present.
@param costArray Row vector cost array. May be null
| JsonDeserialize::Evaluation | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public Evaluation(List<String> labels, INDArray costArray) {
if (costArray != null && !costArray.isRowVectorOrScalar()) {
throw new IllegalArgumentException("Invalid cost array: must be a row vector (got shape: "
+ Arrays.toString(costArray.shape()) + ")");
}
if (costArray != null && costArray.minNumber().doubleValue() < 0.0) {
throw new IllegalArgumentException("Invalid cost array: Cost array values must be positive");
}
this.labelsList = labels;
this.costArray = costArray == null ? null : costArray.castTo(DataType.FLOAT);
this.topN = 1;
} |
Created evaluation instance with the specified cost array. A cost array can be used to bias the multi class
predictions towards or away from certain classes. The predicted class is determined using argMax(cost * probability)
instead of argMax(probability) when no cost array is present.
@param labels Labels for the output classes. May be null
@param costArray Row vector cost array. May be null
| JsonDeserialize::Evaluation | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public void setAxis(int axis){
this.axis = axis;
} |
Set the axis for evaluation - this is the dimension along which the probability (and label classes) are present.<br>
For DL4J, this can be left as the default setting (axis = 1).<br>
Axis should be set as follows:<br>
For 2D (OutputLayer), shape [minibatch, numClasses] - axis = 1<br>
For 3D, RNNs/CNN1D (DL4J RnnOutputLayer), NCW format, shape [minibatch, numClasses, sequenceLength] - axis = 1<br>
For 3D, RNNs/CNN1D (DL4J RnnOutputLayer), NWC format, shape [minibatch, sequenceLength, numClasses] - axis = 2<br>
For 4D, CNN2D (DL4J CnnLossLayer), NCHW format, shape [minibatch, channels, height, width] - axis = 1<br>
For 4D, CNN2D, NHWC format, shape [minibatch, height, width, channels] - axis = 3<br>
@param axis Axis to use for evaluation
| JsonDeserialize::setAxis | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public int getAxis(){
return axis;
} |
Get the axis - see {@link #setAxis(int)} for details
| JsonDeserialize::getAxis | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public void eval(INDArray realOutcomes, INDArray guesses) {
eval(realOutcomes, guesses, (List<Serializable>) null);
} |
Collects statistics on the real outcomes vs the
guesses. This is for logistic outcome matrices.
<p>
Note that an IllegalArgumentException is thrown if the two passed in
matrices aren't the same length.
@param realOutcomes the real outcomes (labels - usually binary)
@param guesses the guesses/prediction (usually a probability vector)
| JsonDeserialize::eval | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public void eval(int predictedIdx, int actualIdx) {
// Add the number of rows to numRowCounter
numRowCounter++;
// If confusion is null, then Evaluation is instantiated without providing the classes
if (confusion == null) {
throw new UnsupportedOperationException(
"Cannot evaluate single example without initializing confusion matrix first");
}
addToConfusion(actualIdx, predictedIdx);
// If they are equal
if (predictedIdx == actualIdx) {
// Then add 1 to True Positive
// (For a particular label)
incrementTruePositives(predictedIdx);
// And add 1 for each negative class that is accurately predicted (True Negative)
//(For a particular label)
for (Integer clazz : confusion().getClasses()) {
if (clazz != predictedIdx)
trueNegatives.incrementCount(clazz, 1.0f);
}
} else {
// Otherwise the real label is predicted as negative (False Negative)
incrementFalseNegatives(actualIdx);
// Otherwise the prediction is predicted as falsely positive (False Positive)
incrementFalsePositives(predictedIdx);
// Otherwise true negatives
for (Integer clazz : confusion().getClasses()) {
if (clazz != predictedIdx && clazz != actualIdx)
trueNegatives.incrementCount(clazz, 1.0f);
}
}
} |
Evaluate a single prediction (one prediction at a time)
@param predictedIdx Index of class predicted by the network
@param actualIdx Index of actual class
| JsonDeserialize::eval | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public String stats() {
return stats(false);
} |
Report the classification statistics as a String
@return Classification statistics as a String
| JsonDeserialize::stats | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public String stats(boolean suppressWarnings) {
return stats(suppressWarnings, numClasses() <= CONFUSION_PRINT_MAX_CLASSES, numClasses() > CONFUSION_PRINT_MAX_CLASSES);
} |
Method to obtain the classification report as a String
@param suppressWarnings whether or not to output warnings related to the evaluation results
@return A (multi-line) String with accuracy, precision, recall, f1 score etc
| JsonDeserialize::stats | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public String stats(boolean suppressWarnings, boolean includeConfusion){
return stats(suppressWarnings, includeConfusion, false);
} |
Method to obtain the classification report as a String
@param suppressWarnings whether or not to output warnings related to the evaluation results
@param includeConfusion whether the confusion matrix should be included it the returned stats or not
@return A (multi-line) String with accuracy, precision, recall, f1 score etc
| JsonDeserialize::stats | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public String confusionMatrix(){
int nClasses = numClasses();
if(confusion == null){
return "Confusion matrix: <no data>";
}
//First: work out the maximum count
List<Integer> classes = confusion.getClasses();
int maxCount = 1;
for (Integer i : classes) {
for (Integer j : classes) {
int count = confusion().getCount(i, j);
maxCount = Math.max(maxCount, count);
}
}
maxCount = Math.max(maxCount, nClasses); //Include this as header might be bigger than actual values
int numDigits = (int)Math.ceil(Math.log10(maxCount));
if(numDigits < 1)
numDigits = 1;
String digitFormat = "%" + (numDigits+1) + "d";
StringBuilder sb = new StringBuilder();
//Build header:
for( int i=0; i<nClasses; i++ ){
sb.append(String.format(digitFormat, i));
}
sb.append("\n");
int numDividerChars = (numDigits+1) * nClasses + 1;
for( int i=0; i<numDividerChars; i++ ){
sb.append("-");
}
sb.append("\n");
//Build each row:
for( int actual=0; actual<nClasses; actual++){
String actualName = resolveLabelForClass(actual);
for( int predicted=0; predicted<nClasses; predicted++){
int count = confusion.getCount(actual, predicted);
sb.append(String.format(digitFormat, count));
}
sb.append(" | ").append(actual).append(" = ").append(actualName).append("\n");
}
sb.append("\nConfusion matrix format: Actual (rowClass) predicted as (columnClass) N times");
return sb.toString();
} |
Get the confusion matrix as a String
@return Confusion matrix as a String
| JsonDeserialize::confusionMatrix | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double precision(Integer classLabel) {
return precision(classLabel, DEFAULT_EDGE_VALUE);
} |
Returns the precision for a given class label
@param classLabel the label
@return the precision for the label
| JsonDeserialize::precision | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double precision(Integer classLabel, double edgeCase) {
Preconditions.checkState(numRowCounter > 0, "Cannot get precision: no evaluation has been performed");
double tpCount = truePositives.getCount(classLabel);
double fpCount = falsePositives.getCount(classLabel);
return EvaluationUtils.precision((long) tpCount, (long) fpCount, edgeCase);
} |
Returns the precision for a given label
@param classLabel the label
@param edgeCase What to output in case of 0/0
@return the precision for the label
| JsonDeserialize::precision | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double precision() {
if(binaryPositiveClass != null && numClasses() == 2){
return precision(binaryPositiveClass);
}
return precision(EvaluationAveraging.Macro);
} |
Precision based on guesses so far.<br>
Note: value returned will differ depending on number of classes and settings.<br>
1. For binary classification, if the positive class is set (via default value of 1, via constructor,
or via {@link #setBinaryPositiveClass(Integer)}), the returned value will be for the specified positive class
only.<br>
2. For the multi-class case, or when {@link #getBinaryPositiveClass()} is null, the returned value is macro-averaged
across all classes. i.e., is macro-averaged precision, equivalent to {@code precision(EvaluationAveraging.Macro)}<br>
@return the total precision based on guesses so far
| JsonDeserialize::precision | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double precision(EvaluationAveraging averaging) {
Preconditions.checkState(numRowCounter > 0, "Cannot get precision: no evaluation has been performed");
int nClasses = confusion().getClasses().size();
if (averaging == EvaluationAveraging.Macro) {
double macroPrecision = 0.0;
int count = 0;
for (int i = 0; i < nClasses; i++) {
double thisClassPrec = precision(i, -1);
if (thisClassPrec != -1) {
macroPrecision += thisClassPrec;
count++;
}
}
macroPrecision /= count;
return macroPrecision;
} else if (averaging == EvaluationAveraging.Micro) {
long tpCount = 0;
long fpCount = 0;
for (int i = 0; i < nClasses; i++) {
tpCount += truePositives.getCount(i);
fpCount += falsePositives.getCount(i);
}
return EvaluationUtils.precision(tpCount, fpCount, DEFAULT_EDGE_VALUE);
} else {
throw new UnsupportedOperationException("Unknown averaging approach: " + averaging);
}
} |
Calculate the average precision for all classes. Can specify whether macro or micro averaging should be used
NOTE: if any classes have tp=0 and fp=0, (precision=0/0) these are excluded from the average
@param averaging Averaging method - macro or micro
@return Average precision
| JsonDeserialize::precision | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public int averagePrecisionNumClassesExcluded() {
return numClassesExcluded("precision");
} |
When calculating the (macro) average precision, how many classes are excluded from the average due to
no predictions - i.e., precision would be the edge case of 0/0
@return Number of classes excluded from the average precision
| JsonDeserialize::averagePrecisionNumClassesExcluded | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public int averageRecallNumClassesExcluded() {
return numClassesExcluded("recall");
} |
When calculating the (macro) average Recall, how many classes are excluded from the average due to
no predictions - i.e., recall would be the edge case of 0/0
@return Number of classes excluded from the average recall
| JsonDeserialize::averageRecallNumClassesExcluded | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public int averageF1NumClassesExcluded() {
return numClassesExcluded("f1");
} |
When calculating the (macro) average F1, how many classes are excluded from the average due to
no predictions - i.e., F1 would be calculated from a precision or recall of 0/0
@return Number of classes excluded from the average F1
| JsonDeserialize::averageF1NumClassesExcluded | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public int averageFBetaNumClassesExcluded() {
return numClassesExcluded("fbeta");
} |
When calculating the (macro) average FBeta, how many classes are excluded from the average due to
no predictions - i.e., FBeta would be calculated from a precision or recall of 0/0
@return Number of classes excluded from the average FBeta
| JsonDeserialize::averageFBetaNumClassesExcluded | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double recall(int classLabel) {
return recall(classLabel, DEFAULT_EDGE_VALUE);
} |
Returns the recall for a given label
@param classLabel the label
@return Recall rate as a double
| JsonDeserialize::recall | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double recall(int classLabel, double edgeCase) {
Preconditions.checkState(numRowCounter > 0, "Cannot get recall: no evaluation has been performed");
double tpCount = truePositives.getCount(classLabel);
double fnCount = falseNegatives.getCount(classLabel);
return EvaluationUtils.recall((long) tpCount, (long) fnCount, edgeCase);
} |
Returns the recall for a given label
@param classLabel the label
@param edgeCase What to output in case of 0/0
@return Recall rate as a double
| JsonDeserialize::recall | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double recall() {
if(binaryPositiveClass != null && numClasses() == 2){
return recall(binaryPositiveClass);
}
return recall(EvaluationAveraging.Macro);
} |
Recall based on guesses so far<br>
Note: value returned will differ depending on number of classes and settings.<br>
1. For binary classification, if the positive class is set (via default value of 1, via constructor,
or via {@link #setBinaryPositiveClass(Integer)}), the returned value will be for the specified positive class
only.<br>
2. For the multi-class case, or when {@link #getBinaryPositiveClass()} is null, the returned value is macro-averaged
across all classes. i.e., is macro-averaged recall, equivalent to {@code recall(EvaluationAveraging.Macro)}<br>
@return the recall for the outcomes
| JsonDeserialize::recall | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double recall(EvaluationAveraging averaging) {
Preconditions.checkState(numRowCounter > 0, "Cannot get recall: no evaluation has been performed");
int nClasses = confusion().getClasses().size();
if (averaging == EvaluationAveraging.Macro) {
double macroRecall = 0.0;
int count = 0;
for (int i = 0; i < nClasses; i++) {
double thisClassRecall = recall(i, -1);
if (thisClassRecall != -1) {
macroRecall += thisClassRecall;
count++;
}
}
macroRecall /= count;
return macroRecall;
} else if (averaging == EvaluationAveraging.Micro) {
long tpCount = 0;
long fnCount = 0;
for (int i = 0; i < nClasses; i++) {
tpCount += truePositives.getCount(i);
fnCount += falseNegatives.getCount(i);
}
return EvaluationUtils.recall(tpCount, fnCount, DEFAULT_EDGE_VALUE);
} else {
throw new UnsupportedOperationException("Unknown averaging approach: " + averaging);
}
} |
Calculate the average recall for all classes - can specify whether macro or micro averaging should be used
NOTE: if any classes have tp=0 and fn=0, (recall=0/0) these are excluded from the average
@param averaging Averaging method - macro or micro
@return Average recall
| JsonDeserialize::recall | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double falsePositiveRate(int classLabel) {
return falsePositiveRate(classLabel, DEFAULT_EDGE_VALUE);
} |
Returns the false positive rate for a given label
@param classLabel the label
@return fpr as a double
| JsonDeserialize::falsePositiveRate | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double falsePositiveRate(int classLabel, double edgeCase) {
Preconditions.checkState(numRowCounter > 0, "Cannot get false positive rate: no evaluation has been performed");
double fpCount = falsePositives.getCount(classLabel);
double tnCount = trueNegatives.getCount(classLabel);
return EvaluationUtils.falsePositiveRate((long) fpCount, (long) tnCount, edgeCase);
} |
Returns the false positive rate for a given label
@param classLabel the label
@param edgeCase What to output in case of 0/0
@return fpr as a double
| JsonDeserialize::falsePositiveRate | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double falsePositiveRate() {
if(binaryPositiveClass != null && numClasses() == 2){
return falsePositiveRate(binaryPositiveClass);
}
return falsePositiveRate(EvaluationAveraging.Macro);
} |
False positive rate based on guesses so far<br>
Note: value returned will differ depending on number of classes and settings.<br>
1. For binary classification, if the positive class is set (via default value of 1, via constructor,
or via {@link #setBinaryPositiveClass(Integer)}), the returned value will be for the specified positive class
only.<br>
2. For the multi-class case, or when {@link #getBinaryPositiveClass()} is null, the returned value is macro-averaged
across all classes. i.e., is macro-averaged false positive rate, equivalent to
{@code falsePositiveRate(EvaluationAveraging.Macro)}<br>
@return the fpr for the outcomes
| JsonDeserialize::falsePositiveRate | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double falsePositiveRate(EvaluationAveraging averaging) {
Preconditions.checkState(numRowCounter > 0, "Cannot get false positive rate: no evaluation has been performed");
int nClasses = confusion().getClasses().size();
if (averaging == EvaluationAveraging.Macro) {
double macroFPR = 0.0;
for (int i = 0; i < nClasses; i++) {
macroFPR += falsePositiveRate(i);
}
macroFPR /= nClasses;
return macroFPR;
} else if (averaging == EvaluationAveraging.Micro) {
long fpCount = 0;
long tnCount = 0;
for (int i = 0; i < nClasses; i++) {
fpCount += falsePositives.getCount(i);
tnCount += trueNegatives.getCount(i);
}
return EvaluationUtils.falsePositiveRate(fpCount, tnCount, DEFAULT_EDGE_VALUE);
} else {
throw new UnsupportedOperationException("Unknown averaging approach: " + averaging);
}
} |
Calculate the average false positive rate across all classes. Can specify whether macro or micro averaging should be used
@param averaging Averaging method - macro or micro
@return Average false positive rate
| JsonDeserialize::falsePositiveRate | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double falseNegativeRate(Integer classLabel) {
return falseNegativeRate(classLabel, DEFAULT_EDGE_VALUE);
} |
Returns the false negative rate for a given label
@param classLabel the label
@return fnr as a double
| JsonDeserialize::falseNegativeRate | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double falseNegativeRate(Integer classLabel, double edgeCase) {
Preconditions.checkState(numRowCounter > 0, "Cannot get false negative rate: no evaluation has been performed");
double fnCount = falseNegatives.getCount(classLabel);
double tpCount = truePositives.getCount(classLabel);
return EvaluationUtils.falseNegativeRate((long) fnCount, (long) tpCount, edgeCase);
} |
Returns the false negative rate for a given label
@param classLabel the label
@param edgeCase What to output in case of 0/0
@return fnr as a double
| JsonDeserialize::falseNegativeRate | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double falseNegativeRate() {
if(binaryPositiveClass != null && numClasses() == 2){
return falseNegativeRate(binaryPositiveClass);
}
return falseNegativeRate(EvaluationAveraging.Macro);
} |
False negative rate based on guesses so far
Note: value returned will differ depending on number of classes and settings.<br>
1. For binary classification, if the positive class is set (via default value of 1, via constructor,
or via {@link #setBinaryPositiveClass(Integer)}), the returned value will be for the specified positive class
only.<br>
2. For the multi-class case, or when {@link #getBinaryPositiveClass()} is null, the returned value is macro-averaged
across all classes. i.e., is macro-averaged false negative rate, equivalent to
{@code falseNegativeRate(EvaluationAveraging.Macro)}<br>
@return the fnr for the outcomes
| JsonDeserialize::falseNegativeRate | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double falseNegativeRate(EvaluationAveraging averaging) {
Preconditions.checkState(numRowCounter > 0, "Cannot get false negative rate: no evaluation has been performed");
int nClasses = confusion().getClasses().size();
if (averaging == EvaluationAveraging.Macro) {
double macroFNR = 0.0;
for (int i = 0; i < nClasses; i++) {
macroFNR += falseNegativeRate(i);
}
macroFNR /= nClasses;
return macroFNR;
} else if (averaging == EvaluationAveraging.Micro) {
long fnCount = 0;
long tnCount = 0;
for (int i = 0; i < nClasses; i++) {
fnCount += falseNegatives.getCount(i);
tnCount += trueNegatives.getCount(i);
}
return EvaluationUtils.falseNegativeRate(fnCount, tnCount, DEFAULT_EDGE_VALUE);
} else {
throw new UnsupportedOperationException("Unknown averaging approach: " + averaging);
}
} |
Calculate the average false negative rate for all classes - can specify whether macro or micro averaging should be used
@param averaging Averaging method - macro or micro
@return Average false negative rate
| JsonDeserialize::falseNegativeRate | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double falseAlarmRate() {
if(binaryPositiveClass != null && numClasses() == 2){
return (falsePositiveRate(binaryPositiveClass) + falseNegativeRate(binaryPositiveClass)) / 2.0;
}
return (falsePositiveRate() + falseNegativeRate()) / 2.0;
} |
False Alarm Rate (FAR) reflects rate of misclassified to classified records
<a href="http://ro.ecu.edu.au/cgi/viewcontent.cgi?article=1058&context=isw">http://ro.ecu.edu.au/cgi/viewcontent.cgi?article=1058&context=isw</a><br>
Note: value returned will differ depending on number of classes and settings.<br>
1. For binary classification, if the positive class is set (via default value of 1, via constructor,
or via {@link #setBinaryPositiveClass(Integer)}), the returned value will be for the specified positive class
only.<br>
2. For the multi-class case, or when {@link #getBinaryPositiveClass()} is null, the returned value is macro-averaged
across all classes. i.e., is macro-averaged false alarm rate)
@return the fpr for the outcomes
| JsonDeserialize::falseAlarmRate | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double f1(int classLabel) {
return fBeta(1.0, classLabel);
} |
Calculate f1 score for a given class
@param classLabel the label to calculate f1 for
@return the f1 score for the given label
| JsonDeserialize::f1 | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double fBeta(double beta, int classLabel) {
return fBeta(beta, classLabel, 0.0);
} |
Calculate the f_beta for a given class, where f_beta is defined as:<br>
(1+beta^2) * (precision * recall) / (beta^2 * precision + recall).<br>
F1 is a special case of f_beta, with beta=1.0
@param beta Beta value to use
@param classLabel Class label
@return F_beta
| JsonDeserialize::fBeta | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double fBeta(double beta, int classLabel, double defaultValue) {
Preconditions.checkState(numRowCounter > 0, "Cannot get fBeta score: no evaluation has been performed");
double precision = precision(classLabel, -1);
double recall = recall(classLabel, -1);
if (precision == -1 || recall == -1) {
return defaultValue;
}
return EvaluationUtils.fBeta(beta, precision, recall);
} |
Calculate the f_beta for a given class, where f_beta is defined as:<br>
(1+beta^2) * (precision * recall) / (beta^2 * precision + recall).<br>
F1 is a special case of f_beta, with beta=1.0
@param beta Beta value to use
@param classLabel Class label
@param defaultValue Default value to use when precision or recall is undefined (0/0 for prec. or recall)
@return F_beta
| JsonDeserialize::fBeta | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double f1() {
if(binaryPositiveClass != null && numClasses() == 2){
return f1(binaryPositiveClass);
}
return f1(EvaluationAveraging.Macro);
} |
Calculate the F1 score<br>
F1 score is defined as:<br>
TP: true positive<br>
FP: False Positive<br>
FN: False Negative<br>
F1 score: 2 * TP / (2TP + FP + FN)<br>
<br>
Note: value returned will differ depending on number of classes and settings.<br>
1. For binary classification, if the positive class is set (via default value of 1, via constructor,
or via {@link #setBinaryPositiveClass(Integer)}), the returned value will be for the specified positive class
only.<br>
2. For the multi-class case, or when {@link #getBinaryPositiveClass()} is null, the returned value is macro-averaged
across all classes. i.e., is macro-averaged f1, equivalent to {@code f1(EvaluationAveraging.Macro)}<br>
@return the f1 score or harmonic mean of precision and recall based on current guesses
| JsonDeserialize::f1 | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double f1(EvaluationAveraging averaging) {
return fBeta(1.0, averaging);
} |
Calculate the average F1 score across all classes, using macro or micro averaging
@param averaging Averaging method to use
| JsonDeserialize::f1 | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double fBeta(double beta, EvaluationAveraging averaging) {
Preconditions.checkState(numRowCounter > 0, "Cannot get fBeta score: no evaluation has been performed");
int nClasses = confusion().getClasses().size();
if (nClasses == 2) {
return EvaluationUtils.fBeta(beta, (long) truePositives.getCount(1), (long) falsePositives.getCount(1),
(long) falseNegatives.getCount(1));
}
if (averaging == EvaluationAveraging.Macro) {
double macroFBeta = 0.0;
int count = 0;
for (int i = 0; i < nClasses; i++) {
double thisFBeta = fBeta(beta, i, -1);
if (thisFBeta != -1) {
macroFBeta += thisFBeta;
count++;
}
}
macroFBeta /= count;
return macroFBeta;
} else if (averaging == EvaluationAveraging.Micro) {
long tpCount = 0;
long fpCount = 0;
long fnCount = 0;
for (int i = 0; i < nClasses; i++) {
tpCount += truePositives.getCount(i);
fpCount += falsePositives.getCount(i);
fnCount += falseNegatives.getCount(i);
}
return EvaluationUtils.fBeta(beta, tpCount, fpCount, fnCount);
} else {
throw new UnsupportedOperationException("Unknown averaging approach: " + averaging);
}
} |
Calculate the average F_beta score across all classes, using macro or micro averaging
@param beta Beta value to use
@param averaging Averaging method to use
| JsonDeserialize::fBeta | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double gMeasure(int output) {
Preconditions.checkState(numRowCounter > 0, "Cannot get gMeasure: no evaluation has been performed");
double precision = precision(output);
double recall = recall(output);
return EvaluationUtils.gMeasure(precision, recall);
} |
Calculate the G-measure for the given output
@param output The specified output
@return The G-measure for the specified output
| JsonDeserialize::gMeasure | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double gMeasure(EvaluationAveraging averaging) {
Preconditions.checkState(numRowCounter > 0, "Cannot get gMeasure: no evaluation has been performed");
int nClasses = confusion().getClasses().size();
if (averaging == EvaluationAveraging.Macro) {
double macroGMeasure = 0.0;
for (int i = 0; i < nClasses; i++) {
macroGMeasure += gMeasure(i);
}
macroGMeasure /= nClasses;
return macroGMeasure;
} else if (averaging == EvaluationAveraging.Micro) {
long tpCount = 0;
long fpCount = 0;
long fnCount = 0;
for (int i = 0; i < nClasses; i++) {
tpCount += truePositives.getCount(i);
fpCount += falsePositives.getCount(i);
fnCount += falseNegatives.getCount(i);
}
double precision = EvaluationUtils.precision(tpCount, fpCount, DEFAULT_EDGE_VALUE);
double recall = EvaluationUtils.recall(tpCount, fnCount, DEFAULT_EDGE_VALUE);
return EvaluationUtils.gMeasure(precision, recall);
} else {
throw new UnsupportedOperationException("Unknown averaging approach: " + averaging);
}
} |
Calculates the average G measure for all outputs using micro or macro averaging
@param averaging Averaging method to use
@return Average G measure
| JsonDeserialize::gMeasure | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double accuracy() {
Preconditions.checkState(numRowCounter > 0, "Cannot get accuracy: no evaluation has been performed");
//Accuracy: sum the counts on the diagonal of the confusion matrix, divide by total
int nClasses = confusion().getClasses().size();
int countCorrect = 0;
for (int i = 0; i < nClasses; i++) {
countCorrect += confusion().getCount(i, i);
}
return countCorrect / (double) getNumRowCounter();
} |
Accuracy:
(TP + TN) / (P + N)
@return the accuracy of the guesses so far
| JsonDeserialize::accuracy | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double topNAccuracy() {
if (topN <= 1)
return accuracy();
if (topNTotalCount == 0)
return 0.0;
return topNCorrectCount / (double) topNTotalCount;
} |
Top N accuracy of the predictions so far. For top N = 1 (default), equivalent to {@link #accuracy()}
@return Top N accuracy
| JsonDeserialize::topNAccuracy | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double matthewsCorrelation(int classIdx) {
Preconditions.checkState(numRowCounter > 0, "Cannot get Matthews correlation: no evaluation has been performed");
return EvaluationUtils.matthewsCorrelation((long) truePositives.getCount(classIdx),
(long) falsePositives.getCount(classIdx), (long) falseNegatives.getCount(classIdx),
(long) trueNegatives.getCount(classIdx));
} |
Calculate the binary Mathews correlation coefficient, for the specified class.<br>
MCC = (TP*TN - FP*FN) / sqrt((TP+FP)(TP+FN)(TN+FP)(TN+FN))<br>
@param classIdx Class index to calculate Matthews correlation coefficient for
| JsonDeserialize::matthewsCorrelation | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double matthewsCorrelation(EvaluationAveraging averaging) {
Preconditions.checkState(numRowCounter > 0, "Cannot get Matthews correlation: no evaluation has been performed");
int nClasses = confusion().getClasses().size();
if (averaging == EvaluationAveraging.Macro) {
double macroMatthewsCorrelation = 0.0;
for (int i = 0; i < nClasses; i++) {
macroMatthewsCorrelation += matthewsCorrelation(i);
}
macroMatthewsCorrelation /= nClasses;
return macroMatthewsCorrelation;
} else if (averaging == EvaluationAveraging.Micro) {
long tpCount = 0;
long fpCount = 0;
long fnCount = 0;
long tnCount = 0;
for (int i = 0; i < nClasses; i++) {
tpCount += truePositives.getCount(i);
fpCount += falsePositives.getCount(i);
fnCount += falseNegatives.getCount(i);
tnCount += trueNegatives.getCount(i);
}
return EvaluationUtils.matthewsCorrelation(tpCount, fpCount, fnCount, tnCount);
} else {
throw new UnsupportedOperationException("Unknown averaging approach: " + averaging);
}
} |
Calculate the average binary Mathews correlation coefficient, using macro or micro averaging.<br>
MCC = (TP*TN - FP*FN) / sqrt((TP+FP)(TP+FN)(TN+FP)(TN+FN))<br>
Note: This is NOT the same as the multi-class Matthews correlation coefficient
@param averaging Averaging approach
@return Average
| JsonDeserialize::matthewsCorrelation | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public Map<Integer, Integer> truePositives() {
return convertToMap(truePositives, confusion().getClasses().size());
} |
True positives: correctly rejected
@return the total true positives so far
| JsonDeserialize::truePositives | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public Map<Integer, Integer> trueNegatives() {
return convertToMap(trueNegatives, confusion().getClasses().size());
} |
True negatives: correctly rejected
@return the total true negatives so far
| JsonDeserialize::trueNegatives | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public Map<Integer, Integer> falsePositives() {
return convertToMap(falsePositives, confusion().getClasses().size());
} |
False positive: wrong guess
@return the count of the false positives
| JsonDeserialize::falsePositives | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public Map<Integer, Integer> falseNegatives() {
return convertToMap(falseNegatives, confusion().getClasses().size());
} |
False negatives: correctly rejected
@return the total false negatives so far
| JsonDeserialize::falseNegatives | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public Map<Integer, Integer> negative() {
return addMapsByKey(trueNegatives(), falsePositives());
} |
Total negatives true negatives + false negatives
@return the overall negative count
| JsonDeserialize::negative | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public Map<Integer, Integer> positive() {
return addMapsByKey(truePositives(), falseNegatives());
} |
Returns all of the positive guesses:
true positive + false negative
| JsonDeserialize::positive | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public void addToConfusion(Integer real, Integer guess) {
confusion().add(real, guess);
} |
Adds to the confusion matrix
@param real the actual guess
@param guess the system guess
| JsonDeserialize::addToConfusion | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public int classCount(Integer clazz) {
return confusion().getActualTotal(clazz);
} |
Returns the number of times the given label
has actually occurred
@param clazz the label
@return the number of times the label
actually occurred
| JsonDeserialize::classCount | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public int getTopNCorrectCount() {
if (confusion == null)
return 0;
if (topN <= 1) {
int nClasses = confusion().getClasses().size();
int countCorrect = 0;
for (int i = 0; i < nClasses; i++) {
countCorrect += confusion().getCount(i, i);
}
return countCorrect;
}
return topNCorrectCount;
} |
Return the number of correct predictions according to top N value. For top N = 1 (default) this is equivalent to
the number of correct predictions
@return Number of correct top N predictions
| JsonDeserialize::getTopNCorrectCount | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public int getTopNTotalCount() {
if (topN <= 1) {
return getNumRowCounter();
}
return topNTotalCount;
} |
Return the total number of top N evaluations. Most of the time, this is exactly equal to {@link #getNumRowCounter()},
but may differ in the case of using {@link #eval(int, int)} as top N accuracy cannot be calculated in that case
(i.e., requires the full probability distribution, not just predicted/actual indices)
@return Total number of top N predictions
| JsonDeserialize::getTopNTotalCount | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public ConfusionMatrix<Integer> getConfusionMatrix() {
return confusion;
} |
Returns the confusion matrix variable
@return confusion matrix variable for this evaluation
| JsonDeserialize::getConfusionMatrix | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public String confusionToString() {
int nClasses = confusion().getClasses().size();
//First: work out the longest label size
int maxLabelSize = 0;
for (String s : labelsList) {
maxLabelSize = Math.max(maxLabelSize, s.length());
}
//Build the formatting for the rows:
int labelSize = Math.max(maxLabelSize + 5, 10);
StringBuilder sb = new StringBuilder();
sb.append("%-3d");
sb.append("%-");
sb.append(labelSize);
sb.append("s | ");
StringBuilder headerFormat = new StringBuilder();
headerFormat.append(" %-").append(labelSize).append("s ");
for (int i = 0; i < nClasses; i++) {
sb.append("%7d");
headerFormat.append("%7d");
}
String rowFormat = sb.toString();
StringBuilder out = new StringBuilder();
//First: header row
Object[] headerArgs = new Object[nClasses + 1];
headerArgs[0] = "Predicted:";
for (int i = 0; i < nClasses; i++)
headerArgs[i + 1] = i;
out.append(String.format(headerFormat.toString(), headerArgs)).append("\n");
//Second: divider rows
out.append(" Actual:\n");
//Finally: data rows
for (int i = 0; i < nClasses; i++) {
Object[] args = new Object[nClasses + 2];
args[0] = i;
args[1] = labelsList.get(i);
for (int j = 0; j < nClasses; j++) {
args[j + 2] = confusion().getCount(i, j);
}
out.append(String.format(rowFormat, args));
out.append("\n");
}
return out.toString();
} |
Get a String representation of the confusion matrix
| JsonDeserialize::confusionToString | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public List<Prediction> getPredictionErrors() {
if (this.confusionMatrixMetaData == null)
return null;
List<Prediction> list = new ArrayList<>();
List<Map.Entry<Pair<Integer, Integer>, List<Object>>> sorted =
new ArrayList<>(confusionMatrixMetaData.entrySet());
Collections.sort(sorted, new Comparator<Map.Entry<Pair<Integer, Integer>, List<Object>>>() {
@Override
public int compare(Map.Entry<Pair<Integer, Integer>, List<Object>> o1,
Map.Entry<Pair<Integer, Integer>, List<Object>> o2) {
Pair<Integer, Integer> p1 = o1.getKey();
Pair<Integer, Integer> p2 = o2.getKey();
int order = Integer.compare(p1.getFirst(), p2.getFirst());
if (order != 0)
return order;
order = Integer.compare(p1.getSecond(), p2.getSecond());
return order;
}
});
for (Map.Entry<Pair<Integer, Integer>, List<Object>> entry : sorted) {
Pair<Integer, Integer> p = entry.getKey();
if (p.getFirst().equals(p.getSecond())) {
//predicted = actual -> not an error -> skip
continue;
}
for (Object m : entry.getValue()) {
list.add(new Prediction(p.getFirst(), p.getSecond(), m));
}
}
return list;
} |
Get a list of prediction errors, on a per-record basis<br>
<p>
<b>Note</b>: Prediction errors are ONLY available if the "evaluate with metadata" method is used: {@link #eval(INDArray, INDArray, List)}
Otherwise (if the metadata hasn't been recorded via that previously mentioned eval method), there is no value in
splitting each prediction out into a separate Prediction object - instead, use the confusion matrix to get the counts,
via {@link #getConfusionMatrix()}
@return A list of prediction errors, or null if no metadata has been recorded
| JsonDeserialize::getPredictionErrors | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public List<Prediction> getPredictionsByActualClass(int actualClass) {
if (confusionMatrixMetaData == null)
return null;
List<Prediction> out = new ArrayList<>();
for (Map.Entry<Pair<Integer, Integer>, List<Object>> entry : confusionMatrixMetaData.entrySet()) { //Entry Pair: (Actual,Predicted)
if (entry.getKey().getFirst() == actualClass) {
int actual = entry.getKey().getFirst();
int predicted = entry.getKey().getSecond();
for (Object m : entry.getValue()) {
out.add(new Prediction(actual, predicted, m));
}
}
}
return out;
} |
Get a list of predictions, for all data with the specified <i>actual</i> class, regardless of the predicted
class.
<p>
<b>Note</b>: Prediction errors are ONLY available if the "evaluate with metadata" method is used: {@link #eval(INDArray, INDArray, List)}
Otherwise (if the metadata hasn't been recorded via that previously mentioned eval method), there is no value in
splitting each prediction out into a separate Prediction object - instead, use the confusion matrix to get the counts,
via {@link #getConfusionMatrix()}
@param actualClass Actual class to get predictions for
@return List of predictions, or null if the "evaluate with metadata" method was not used
| JsonDeserialize::getPredictionsByActualClass | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public List<Prediction> getPredictionByPredictedClass(int predictedClass) {
if (confusionMatrixMetaData == null)
return null;
List<Prediction> out = new ArrayList<>();
for (Map.Entry<Pair<Integer, Integer>, List<Object>> entry : confusionMatrixMetaData.entrySet()) { //Entry Pair: (Actual,Predicted)
if (entry.getKey().getSecond() == predictedClass) {
int actual = entry.getKey().getFirst();
int predicted = entry.getKey().getSecond();
for (Object m : entry.getValue()) {
out.add(new Prediction(actual, predicted, m));
}
}
}
return out;
} |
Get a list of predictions, for all data with the specified <i>predicted</i> class, regardless of the actual data
class.
<p>
<b>Note</b>: Prediction errors are ONLY available if the "evaluate with metadata" method is used: {@link #eval(INDArray, INDArray, List)}
Otherwise (if the metadata hasn't been recorded via that previously mentioned eval method), there is no value in
splitting each prediction out into a separate Prediction object - instead, use the confusion matrix to get the counts,
via {@link #getConfusionMatrix()}
@param predictedClass Actual class to get predictions for
@return List of predictions, or null if the "evaluate with metadata" method was not used
| JsonDeserialize::getPredictionByPredictedClass | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public List<Prediction> getPredictions(int actualClass, int predictedClass) {
if (confusionMatrixMetaData == null)
return null;
List<Prediction> out = new ArrayList<>();
List<Object> list = confusionMatrixMetaData.get(new Pair<>(actualClass, predictedClass));
if (list == null)
return out;
for (Object meta : list) {
out.add(new Prediction(actualClass, predictedClass, meta));
}
return out;
} |
Get a list of predictions in the specified confusion matrix entry (i.e., for the given actua/predicted class pair)
@param actualClass Actual class
@param predictedClass Predicted class
@return List of predictions that match the specified actual/predicted classes, or null if the "evaluate with metadata" method was not used
| JsonDeserialize::getPredictions | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public static <R> MergeLambda<R> mergeConcatenate(){
return new MergeLambda<R>() {
@Override
public List<R> merge(List<R> a, List<R> b) {
List<R> res = Lists.newArrayList(a);
res.addAll(b);
return res;
}
};
} |
A MergeLambda that merges by concatenating the two lists
| Metric::mergeConcatenate | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/custom/CustomEvaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/custom/CustomEvaluation.java | Apache-2.0 |
public void updateProperties(InputStream inputStream) {
try {
conf.load(inputStream);
conf.putAll(System.getProperties());
} catch (IOException e) {
log.warn("Error loading system properties from input stream", e);
}
} |
Load the additional properties from an input stream and load all system properties
@param inputStream
| Nd4jContext::updateProperties | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/context/Nd4jContext.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/context/Nd4jContext.java | Apache-2.0 |
public Properties getConf() {
return conf;
} |
Get the configuration for nd4j
@return
| Nd4jContext::getConf | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/context/Nd4jContext.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/context/Nd4jContext.java | Apache-2.0 |
public OpaqueNDArray(Pointer p) { super(p); } |
Constructs an OpaqueNDArray from a given Pointer.
@param p The Pointer object representing the native memory address.
| OpaqueNDArray::OpaqueNDArray | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | Apache-2.0 |
public static OpaqueNDArray create(
OpaqueDataBuffer shapeInfo,
OpaqueDataBuffer buffer,
OpaqueDataBuffer specialBuffer,
long offset) {
return Nd4j.getNativeOps().create(shapeInfo, buffer, specialBuffer, offset);
} |
Creates an OpaqueNDArray with given buffers and offset.
This method delegates the creation to {@link Nd4j#getNativeOps()}.
@param shapeInfo The shape information buffer.
@param buffer The primary data buffer.
@param specialBuffer The special buffer (e.g., for GPU data).
@param offset The offset in the buffer.
@return A new OpaqueNDArray.
| OpaqueNDArray::create | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | Apache-2.0 |
public DataType dataType() {
return ArrayOptionsHelper.dataType(extras());
} |
Gets the data type of the OpaqueNDArray.
This method uses {@link Nd4j#getNativeOps()} to retrieve the data type.
@return The DataType of the array.
| OpaqueNDArray::dataType | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | Apache-2.0 |
public long extras() {
return Shape.extras(shapeInfo());
} |
Gets the extra information of the OpaqueNDArray.
This method uses {@link Nd4j#getNativeOps()} to retrieve the extra information.
@return A long value representing the extra information.
| OpaqueNDArray::extras | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | Apache-2.0 |
public static long getOpaqueNDArrayOffset(OpaqueNDArray array) {
return Nd4j.getNativeOps().getOpaqueNDArrayOffset(array);
} |
Retrieves the offset of an OpaqueNDArray.
This method uses {@link Nd4j#getNativeOps()} to retrieve the offset.
@param array The OpaqueNDArray whose offset is to be retrieved.
@return The offset value.
| OpaqueNDArray::getOpaqueNDArrayOffset | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | Apache-2.0 |
public static long[] getOpaqueNDArrayShapeInfo(OpaqueNDArray array) {
LongPointer ret = Nd4j.getNativeOps().getOpaqueNDArrayShapeInfo(array);
long len = Nd4j.getNativeOps().getShapeInfoLength(array);
ret.capacity(len);
long[] retArr = new long[(int) len];
ret.get(retArr);
return retArr;
} |
Retrieves the shape information of an OpaqueNDArray.
This method uses {@link Nd4j#getNativeOps()} to retrieve the shape information.
@param array The OpaqueNDArray whose shape information is to be retrieved.
@return An array of long values representing the shape information.
| OpaqueNDArray::getOpaqueNDArrayShapeInfo | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | Apache-2.0 |
public static Pointer getOpaqueNDArrayBuffer(OpaqueNDArray array) {
return Nd4j.getNativeOps().getOpaqueNDArrayBuffer(array);
} |
Retrieves the primary buffer of an OpaqueNDArray.
This method uses {@link Nd4j#getNativeOps()} to retrieve the buffer.
@param array The OpaqueNDArray whose buffer is to be retrieved.
@return A Pointer to the buffer.
| OpaqueNDArray::getOpaqueNDArrayBuffer | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | Apache-2.0 |
public static Pointer getOpaqueNDArraySpecialBuffer(OpaqueNDArray array) {
return Nd4j.getNativeOps().getOpaqueNDArraySpecialBuffer(array);
} |
Retrieves the special buffer of an OpaqueNDArray.
This method uses {@link Nd4j#getNativeOps()} to retrieve the special buffer.
@param array The OpaqueNDArray whose special buffer is to be retrieved.
@return A Pointer to the special buffer.
| OpaqueNDArray::getOpaqueNDArraySpecialBuffer | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | Apache-2.0 |
public static long getOpaqueNDArrayLength(OpaqueNDArray array) {
return Nd4j.getNativeOps().getOpaqueNDArrayLength(array);
} |
Gets the length of the OpaqueNDArray.
This method uses {@link Nd4j#getNativeOps()} to retrieve the length.
@param array The OpaqueNDArray whose length is to be retrieved.
@return The length of the array.
| OpaqueNDArray::getOpaqueNDArrayLength | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | Apache-2.0 |
public static void deleteNDArray(OpaqueNDArray array) {
Nd4j.getNativeOps().deleteNDArray(array);
} |
Deletes an OpaqueNDArray.
This method uses {@link Nd4j#getNativeOps()} to delete the array.
@param array The OpaqueNDArray to delete.
| OpaqueNDArray::deleteNDArray | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | Apache-2.0 |
public static void delete(OpaqueNDArray array) {
if (array != null && !array.isNull()) {
deleteNDArray(array);
array.setNull();
}
} |
Deletes and nullifies an OpaqueNDArray.
This method uses {@link Nd4j#getNativeOps()} to delete the array.
@param array The OpaqueNDArray to delete.
| OpaqueNDArray::delete | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | Apache-2.0 |
public static OpaqueNDArray fromINDArrayUncached(INDArray array) {
if (array == null) {
return null;
}
DataBuffer buffer = array.data();
DataBuffer shapeInfo = array.shapeInfoDataBuffer();
return create(
shapeInfo.opaqueBuffer(),
array.isEmpty() ? null : buffer.opaqueBuffer(),
array.isEmpty() ? null :buffer.opaqueBuffer(),
array.offset()
);
} |
Converts an INDArray to an OpaqueNDArray.
This method uses {@link Nd4j#getNativeOps()} to create the OpaqueNDArray.
@param array The INDArray to convert.
@return The corresponding OpaqueNDArray.
| OpaqueNDArray::fromINDArrayUncached | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | Apache-2.0 |
public static OpaqueNDArray fromINDArray(INDArray array) {
if(array == null) {
return null;
}
return array.getOrCreateOpaqueNDArray();
} |
Converts an INDArray to an OpaqueNDArray.
This method uses {@link Nd4j#getNativeOps()} to create the OpaqueNDArray.
@param array The INDArray to convert.
@return The corresponding OpaqueNDArray.
| OpaqueNDArray::fromINDArray | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | Apache-2.0 |
public static INDArray toINDArray(OpaqueNDArray opaqueArray) {
if (opaqueArray == null || opaqueArray.isNull()) {
return null;
}
long offset = opaqueArray.getOffset();
long[] shapeInfoPtr = opaqueArray.shapeInfo();
Pointer bufferPtr = opaqueArray.buffer();
Pointer specialBufferPtr = opaqueArray.specialBuffer();
long length = opaqueArray.length();
// Extract shape information
long[] shape = Shape.shape(shapeInfoPtr);
long[] stride = Shape.stride(shapeInfoPtr);
char order = Shape.order(shapeInfoPtr);
long ews = Shape.elementWiseStride(shapeInfoPtr);
long extras = Shape.extras(shapeInfoPtr);
// Create LongShapeDescriptor
LongShapeDescriptor descriptor = LongShapeDescriptor.builder()
.shape(shape)
.stride(stride)
.offset(offset)
.ews(ews)
.order(order)
.extras(extras)
.build();
// Create DataBuffer from the OpaqueNDArray's buffer
DataType dataType = ArrayOptionsHelper.dataType(extras);
DataBuffer buffer = Nd4j.createBuffer(bufferPtr,specialBufferPtr,length,dataType);
// Create INDArray using the descriptor and buffer
return Nd4j.create(buffer, descriptor);
} |
Converts an OpaqueNDArray to an INDArray.
This method uses the data and shape information from {@link Nd4j#getNativeOps()} to create the INDArray.
@param opaqueArray The OpaqueNDArray to convert.
@return The corresponding INDArray.
| OpaqueNDArray::toINDArray | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | Apache-2.0 |
public long getOffset() {
return getOpaqueNDArrayOffset(this);
} |
Gets the offset of the current OpaqueNDArray.
@return The offset of the array.
| OpaqueNDArray::getOffset | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | Apache-2.0 |
public long[] shapeInfo() {
return getOpaqueNDArrayShapeInfo(this);
} |
Gets the shape information of the current OpaqueNDArray.
@return An array of long values representing the shape information.
| OpaqueNDArray::shapeInfo | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | Apache-2.0 |
public Pointer buffer() {
return getOpaqueNDArrayBuffer(this);
} |
Gets the primary buffer of the current OpaqueNDArray.
@return A Pointer to the buffer.
| OpaqueNDArray::buffer | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | Apache-2.0 |
public Pointer specialBuffer() {
return getOpaqueNDArraySpecialBuffer(this);
} |
Gets the special buffer of the current OpaqueNDArray.
@return A Pointer to the special buffer.
| OpaqueNDArray::specialBuffer | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | Apache-2.0 |
public long length() {
return getOpaqueNDArrayLength(this);
} |
Gets the length of the current OpaqueNDArray.
@return The length of the array.
| OpaqueNDArray::length | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueNDArray.java | Apache-2.0 |
public StringVector(Pointer p) { super(p); } | /*
******************************************************************************
*
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
*****************************************************************************
package org.nd4j.nativeblas;
import org.bytedeco.javacpp.BytePointer;
import org.bytedeco.javacpp.Loader;
import org.bytedeco.javacpp.Pointer;
import org.bytedeco.javacpp.annotation.*;
@Name("std::vector<std::string>") public class StringVector extends Pointer {
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. | StringVector::StringVector | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/StringVector.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/StringVector.java | Apache-2.0 |
public static OpaqueDataBuffer allocateDataBuffer(long numElements, @NonNull DataType dataType, boolean allocateBoth) {
OpaqueDataBuffer buffer = null;
int ec = 0;
String em = null;
for (int t = 0; t < MAX_TRIES; t++) {
try {
// try to allocate data buffer
buffer = Nd4j.getNativeOps().allocateDataBuffer(numElements, dataType.toInt(), allocateBoth);
//when using func trace we want to print allocation traces when deallocation is called. this is used to debug
//potential race condition and crashes. c++ prints the equivalent stack trace when func trace is enabled.
//This allows us to check where a deallocated buffer that caused an issue was allocated.
if(buffer != null && Nd4j.getNativeOps().isFuncTrace())
buffer.captureTrace();
// check error code
ec = Nd4j.getNativeOps().lastErrorCode();
if (ec != 0) {
em = Nd4j.getNativeOps().lastErrorMessage();
// if allocation failed it might be caused by casual OOM, so we'll try GC
System.gc();
// sleeping for 50ms
Thread.sleep(50);
} else {
// just return the buffer
return buffer;
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
// if MAX_TRIES is over, we'll just throw an exception
throw new RuntimeException("Allocation failed: [" + em + "] for amount of memory " + numElements * dataType.width() + " bytes");
} |
This method allocates new InteropDataBuffer and returns pointer to it
@param numElements
@param dataType
@param allocateBoth
@return
| OpaqueDataBuffer::allocateDataBuffer | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueDataBuffer.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueDataBuffer.java | Apache-2.0 |
public void expand(long numElements) {
int ec = 0;
String em = null;
for (int t = 0; t < MAX_TRIES; t++) {
try {
// try to expand the buffer
Nd4j.getNativeOps().dbExpand(this, numElements);
// check error code
ec =Nd4j.getNativeOps().lastErrorCode();
if (ec != 0) {
em =Nd4j.getNativeOps().lastErrorMessage();
// if expansion failed it might be caused by casual OOM, so we'll try GC
System.gc();
Thread.sleep(50);
} else {
// just return
return;
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
// if MAX_TRIES is over, we'll just throw an exception
throw new RuntimeException("DataBuffer expansion failed: [" + em + "]");
} |
This method expands buffer, and copies content to the new buffer
PLEASE NOTE: if InteropDataBuffer doesn't own actual buffers - original pointers won't be released
@param numElements
| OpaqueDataBuffer::expand | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueDataBuffer.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueDataBuffer.java | Apache-2.0 |
public OpaqueDataBuffer createView(long bytesLength) {
OpaqueDataBuffer buffer = null;
int ec = 0;
String em = null;
for (int t = 0; t < MAX_TRIES; t++) {
try {
buffer =Nd4j.getNativeOps().dbCreateView(this, bytesLength);
if(NativeOpsHolder.getInstance().getDeviceNativeOps().isFuncTrace())
buffer.captureTrace();
// check error code
ec =Nd4j.getNativeOps().lastErrorCode();
if (ec != 0) {
em =Nd4j.getNativeOps().lastErrorMessage();
// if view creation failed it might be caused by casual OOM, so we'll try GC
System.gc();
// sleeping to let gc kick in
Thread.sleep(50);
} else {
// just return
return buffer;
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
// if MAX_TRIES is over, we'll just throw an exception
throw new RuntimeException("DataBuffer expansion failed: [" + em + "]");
} |
This method creates a view out of this InteropDataBuffer
@param bytesLength
@return
| OpaqueDataBuffer::createView | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueDataBuffer.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueDataBuffer.java | Apache-2.0 |
public Pointer primaryBuffer() {
return Nd4j.getNativeOps().dbPrimaryBuffer(this);
} |
This method returns pointer to linear buffer, primary one.
@return
| OpaqueDataBuffer::primaryBuffer | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueDataBuffer.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueDataBuffer.java | Apache-2.0 |
public Pointer specialBuffer() {
return Nd4j.getNativeOps().
dbSpecialBuffer(this);
} |
This method returns pointer to special buffer, device one, if any.
@return
| OpaqueDataBuffer::specialBuffer | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueDataBuffer.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueDataBuffer.java | Apache-2.0 |
public int deviceId() {
return Nd4j.getNativeOps().dbDeviceId(this);
} |
This method returns deviceId of this DataBuffer
@return
| OpaqueDataBuffer::deviceId | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueDataBuffer.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueDataBuffer.java | Apache-2.0 |
public void setPrimaryBuffer(Pointer ptr, long numElements) {
//note we call print here because dbSetSpecialBuffer can deallocate on the c++ side
printAllocationTraceIfNeeded();
Nd4j.getNativeOps().dbSetPrimaryBuffer(this, ptr, numElements);
} |
This method allows to set external pointer as primary buffer.
PLEASE NOTE: if InteropDataBuffer owns current memory buffer, it will be released
@param ptr
@param numElements
| OpaqueDataBuffer::setPrimaryBuffer | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueDataBuffer.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueDataBuffer.java | Apache-2.0 |
public void setSpecialBuffer(Pointer ptr, long numElements) {
//note we call print here because dbSetSpecialBuffer can deallocate on the c++ side
printAllocationTraceIfNeeded();
Nd4j.getNativeOps().dbSetSpecialBuffer(this, ptr, numElements);
} |
This method allows to set external pointer as primary buffer.
PLEASE NOTE: if InteropDataBuffer owns current memory buffer, it will be released
@param ptr
@param numElements
| OpaqueDataBuffer::setSpecialBuffer | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueDataBuffer.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueDataBuffer.java | Apache-2.0 |
public void syncToSpecial() {
Nd4j.getNativeOps().dbSyncToSpecial(this);
} |
This method synchronizes device memory
| OpaqueDataBuffer::syncToSpecial | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueDataBuffer.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueDataBuffer.java | Apache-2.0 |
public void syncToPrimary() {
Nd4j.getNativeOps().dbSyncToPrimary(this);
} |
This method synchronizes host memory
| OpaqueDataBuffer::syncToPrimary | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueDataBuffer.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/nativeblas/OpaqueDataBuffer.java | Apache-2.0 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.