cn.centipede.numpy.Numpy.np.array()

Here are the examples of the java api cn.centipede.numpy.Numpy.np.array() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

18 Source : MNIST.java
with MIT License
from DRL-CASIA

/**
 * Asume image have same size
 * @param mnistMatrix
 * @return MNIST NDArray: data, target
 */
private static NDArray[] toNDArray(MnistMatrix[] mnistMatrix) {
    int[] labels = new int[mnistMatrix.length];
    int rows = mnistMatrix[0].getNumberOfRows();
    int cols = mnistMatrix[0].getNumberOfColumns();
    int[][][] dataBf = new int[mnistMatrix.length][rows][cols];
    for (int i = 0; i < mnistMatrix.length; i++) {
        int[][] data = mnistMatrix[i].getData();
        labels[i] = mnistMatrix[i].getLabel();
        dataBf[i] = data;
    }
    NDArray data = np.array(dataBf);
    NDArray target = np.array(labels);
    return new NDArray[] { data, target };
}

13 Source : NpyFile.java
with MIT License
from DRL-CASIA

public static NDArray read(Header header, ByteBuffer chunks) {
    int size = IntStream.of(header.shape).reduce(1, (a, b) -> a * b);
    chunks.order(header.order);
    DoubleBuffer db = chunks.asDoubleBuffer();
    double[] data = new double[size];
    int offset = 0;
    while (db.hasRemaining()) {
        size = db.remaining();
        db.get(data, offset, size);
        offset += size;
    }
    return np.array(data, header.shape);
}