@Override public int outcome() { return Nd4j.getBlasWrapper().iamax(getLabels()); }
@Override public Map<Integer, Double> labelCounts() { Map<Integer, Double> ret = new HashMap<>(); if (labels == null) return ret; long nTensors = labels.tensorssAlongDimension(1); for (int i = 0; i < nTensors; i++) { INDArray row = labels.tensorAlongDimension(i, 1); INDArray javaRow = labels.javaTensorAlongDimension(i, 1); int maxIdx = Nd4j.getBlasWrapper().iamax(row); int maxIdxJava = Nd4j.getBlasWrapper().iamax(javaRow); if (maxIdx < 0) throw new IllegalStateException("Please check the iamax implementation for " + Nd4j.getBlasWrapper().getClass().getName()); if (ret.get(maxIdx) == null) ret.put(maxIdx, 1.0); else ret.put(maxIdx, ret.get(maxIdx) + 1.0); } return ret; }
@Override public int outcome() { return Nd4j.getBlasWrapper().iamax(getLabels()); }
@Override public Map<Integer, Double> labelCounts() { Map<Integer, Double> ret = new HashMap<>(); if (labels == null) return ret; int nTensors = labels.tensorssAlongDimension(1); for (int i = 0; i < nTensors; i++) { INDArray row = labels.tensorAlongDimension(i, 1); INDArray javaRow = labels.javaTensorAlongDimension(i, 1); int maxIdx = Nd4j.getBlasWrapper().iamax(row); int maxIdxJava = Nd4j.getBlasWrapper().iamax(javaRow); if (maxIdx < 0) throw new IllegalStateException("Please check the iamax implementation for " + Nd4j.getBlasWrapper().getClass().getName()); if (ret.get(maxIdx) == null) ret.put(maxIdx, 1.0); else ret.put(maxIdx, ret.get(maxIdx) + 1.0); } return ret; }
/** * Returns the predictions for each example in the dataset * * @param d the matrix to predict * @return the prediction for the dataset */ @Override public int[] predict(INDArray d) { INDArray output = output(d, Layer.TrainingMode.TEST); int[] ret = new int[d.size(0)]; if (d.isRowVector()) ret[0] = Nd4j.getBlasWrapper().iamax(output); else { for (int i = 0; i < ret.length; i++) ret[i] = Nd4j.getBlasWrapper().iamax(output.getRow(i)); } return ret; }
/** * Returns the predictions for each example in the dataset * @param input the matrix to predict * @return the prediction for the dataset */ @Override public int[] predict(INDArray input) { INDArray output = output(input); int[] ret = new int[input.rows()]; for (int i = 0; i < ret.length; i++) ret[i] = Nd4j.getBlasWrapper().iamax(output.getRow(i)); return ret; }
/** * Returns the predictions for each example in the dataset * @param input the matrix to predict * @return the prediction for the dataset */ @Override public int[] predict(INDArray input) { INDArray output = output(input); int[] ret = new int[input.rows()]; for (int i = 0; i < ret.length; i++) ret[i] = Nd4j.getBlasWrapper().iamax(output.getRow(i)); return ret; }
System.out.println(Nd4j.getBlasWrapper().iamax(output));
private INDArray toOutcomesFromBinaryLabelMatrix(INDArray outcomes) { INDArray ret = Nd4j.create(outcomes.rows(), 1); for (int i = 0; i < outcomes.rows(); i++) ret.put(i, 0, Nd4j.getBlasWrapper().iamax(outcomes.getRow(i))); return ret; }
for (int k = 0; k < states; k++) { INDArray rowLogProduct = rowOfLogTransitionMatrix(k).add(V.getRow(t - 1)); int maxVal = Nd4j.getBlasWrapper().iamax(rowLogProduct); double argMax = rowLogProduct.max(Integer.MAX_VALUE).getDouble(0); V.put(t, k, argMax);