use of org.nd4j.linalg.api.buffer.DataBuffer in project deeplearning4j by deeplearning4j.
the class NDArrayHDF5Reader method readFromPath.
/**
* Reads an HDF5 file into an NDArray.
*
* @param inputFilePath Path of the HDF5 file
* @return NDArray with data and a correct shape
*/
public INDArray readFromPath(Path inputFilePath) {
try (hdf5.H5File h5File = new hdf5.H5File()) {
h5File.openFile(inputFilePath.toString(), H5F_ACC_RDONLY);
hdf5.DataSet dataSet = h5File.asCommonFG().openDataSet("data");
int[] shape = extractShape(dataSet);
long totalSize = ArrayUtil.prodLong(shape);
DataBuffer dataBuffer = readFromDataSet(dataSet, (int) totalSize);
INDArray input = Nd4j.create(shape);
input.setData(dataBuffer);
return input;
}
}
use of org.nd4j.linalg.api.buffer.DataBuffer in project nd4j by deeplearning4j.
the class DefaultRandom method nextGaussian.
@Override
public INDArray nextGaussian(char order, int[] shape) {
int length = ArrayUtil.prod(shape);
INDArray ret = Nd4j.create(shape, order);
DataBuffer data = ret.data();
for (int i = 0; i < length; i++) {
data.put(i, nextGaussian());
}
return ret;
}
use of org.nd4j.linalg.api.buffer.DataBuffer in project nd4j by deeplearning4j.
the class DefaultRandom method nextInt.
@Override
public INDArray nextInt(int[] shape) {
int length = ArrayUtil.prod(shape);
INDArray ret = Nd4j.create(shape);
DataBuffer data = ret.data();
for (int i = 0; i < length; i++) {
data.put(i, nextInt());
}
return ret;
}
use of org.nd4j.linalg.api.buffer.DataBuffer in project nd4j by deeplearning4j.
the class DefaultRandom method nextFloat.
@Override
public INDArray nextFloat(char order, int[] shape) {
int length = ArrayUtil.prod(shape);
INDArray ret = Nd4j.create(shape, order);
DataBuffer data = ret.data();
for (int i = 0; i < length; i++) {
data.put(i, nextFloat());
}
return ret;
}
use of org.nd4j.linalg.api.buffer.DataBuffer in project nd4j by deeplearning4j.
the class DefaultRandom method nextDouble.
@Override
public INDArray nextDouble(char order, int[] shape) {
int length = ArrayUtil.prod(shape);
INDArray ret = Nd4j.create(shape, order);
DataBuffer data = ret.data();
for (int i = 0; i < length; i++) {
data.put(i, nextDouble());
}
return ret;
}
Aggregations