本文整理了Java中org.nd4j.linalg.factory.Nd4j.getShapeInfoProvider()
方法的一些代码示例,展示了Nd4j.getShapeInfoProvider()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Nd4j.getShapeInfoProvider()
方法的具体详情如下:
包路径:org.nd4j.linalg.factory.Nd4j
类名称:Nd4j
方法名:getShapeInfoProvider
暂无
代码示例来源:origin: deeplearning4j/nd4j
@Override
public void setShapeAndStride(int[] shape, int[] stride) {
setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape, stride, 0, -1, ordering()));
}
代码示例来源:origin: deeplearning4j/nd4j
public BaseNDArray(float[] data, long[] shape, long[] stride, long offset, char ordering) {
setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape, stride, offset,
Shape.elementWiseStride(shape, stride, ordering == 'f'), ordering));
if (data != null && data.length > 0) {
this.data = Nd4j.createBuffer(data, offset);
if (offset >= data.length)
throw new IllegalArgumentException("invalid offset: must be < data.length");
}
init(shape, stride);
}
代码示例来源:origin: deeplearning4j/nd4j
public BaseNDArray(double[] data, long[] shape, long[] stride, long offset, char ordering) {
setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape, stride, offset,
Shape.elementWiseStride(shape, stride, ordering == 'f'), ordering));
if (data != null && data.length > 0) {
this.data = Nd4j.createBuffer(data, offset);
if (offset >= data.length)
throw new IllegalArgumentException("invalid offset: must be < data.length");
}
init(shape, stride);
}
代码示例来源:origin: deeplearning4j/nd4j
private static DataBuffer getIm2ColShape(INDArray img, int kernelHeight, int kernelWidth, int outHeight, int outWidth) {
//number of images
long n = img.size(0);
//number of channels (depth)
long c = img.size(1);
return Nd4j.getShapeInfoProvider().createShapeInformation(new long[] {n, c, kernelHeight, kernelWidth, outHeight, outWidth}, 'c').getFirst();
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public void setShape(long[] shape) {
setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape, stride(), 0, elementWiseStride(), ordering()));
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public void setOrder(char order) {
setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape(), stride(), 0,
elementWiseStride(), order));
}
代码示例来源:origin: deeplearning4j/nd4j
/**
*
* @param buffer
*/
public BaseNDArray(DataBuffer buffer) {
this.data = buffer;
if (buffer.length() >= Integer.MAX_VALUE)
throw new IllegalArgumentException("Length of buffer can not be >= Integer.MAX_VALUE");
int[] shape = {1, (int) buffer.length()};
int[] stride = Nd4j.getStrides(shape);
setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape, stride, 0, 1, Nd4j.order()));
init(shape, stride);
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public void setStride(long[] stride) {
setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape(), stride, 0, elementWiseStride(), ordering()));
}
代码示例来源:origin: deeplearning4j/nd4j
public BaseNDArray(long newRows, long newColumns, char ordering) {
this.data = Nd4j.createBuffer((long) newRows * newColumns);
long[] shape = new long[] {newRows, newColumns};
long[] stride = Nd4j.getStrides(shape, ordering);
setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape, stride, 0,
Shape.elementWiseStride(shape, stride, ordering == 'f'), ordering));
init(shape, stride);
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* This method creates compressed INDArray from Java double array, skipping usual INDArray instantiation routines
*
* @param data
* @param shape
* @param order
* @return
*/
@Override
public INDArray compress(double[] data, int[] shape, char order) {
DoublePointer pointer = new DoublePointer(data);
DataBuffer shapeInfo = Nd4j.getShapeInfoProvider().createShapeInformation(shape, order).getFirst();
DataBuffer buffer = compressPointer(DataBuffer.TypeEx.DOUBLE, pointer, data.length, 8);
return Nd4j.createArrayFromShapeBuffer(buffer, shapeInfo);
}
代码示例来源:origin: deeplearning4j/nd4j
public BaseSparseNDArrayCOO(DataBuffer values, DataBuffer indices, DataBuffer sparseInformation, int[] shape) {
this.values = Nd4j.createBuffer(values, 0, values.length());
this.indices = indices;
setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape));
init(shape);
this.sparseInformation = sparseInformation;
this.length = countNNZ();
}
代码示例来源:origin: deeplearning4j/nd4j
public BaseNDArray(DataBuffer buffer, long[] shape, long[] stride, long offset, char ordering) {
this.data = offset > 0 ? Nd4j.createBuffer(buffer, offset, ArrayUtil.prodLong(shape)) : buffer;
setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape, stride, offset,
Shape.elementWiseStride(shape, stride, ordering == 'f'), ordering));
init(shape, stride);
// Shape.setElementWiseStride(this.shapeInfo(),Shape.elementWiseStride(shape, stride, ordering == 'f'));
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public void setStride(int[] stride) {
setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape(), ArrayUtil.toLongArray(stride), 0, elementWiseStride(), ordering()));
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public void setShape(int[] shape) {
setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(ArrayUtil.toLongArray(shape), stride(), 0, elementWiseStride(), ordering()));
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Creates a new <i>n</i> times <i>m</i> <tt>DoubleMatrix</tt>.
*
* @param newRows the number of rows (<i>n</i>) of the new matrix.
* @param newColumns the number of columns (<i>m</i>) of the new matrix.
*/
public BaseNDArray(int newRows, int newColumns, char ordering) {
this.data = Nd4j.createBuffer((long) newRows * newColumns);
int[] shape = new int[] {newRows, newColumns};
int[] stride = Nd4j.getStrides(shape, ordering);
setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape, stride, 0,
Shape.elementWiseStride(shape, stride, ordering == 'f'), ordering));
init(shape, stride);
}
代码示例来源:origin: deeplearning4j/nd4j
/**
*
* @param buffer
* @param shape
* @param stride
* @param offset
* @param ordering
*/
public BaseNDArray(DataBuffer buffer, int[] shape, int[] stride, long offset, char ordering) {
this.data = offset > 0 ? Nd4j.createBuffer(buffer, offset, ArrayUtil.prodLong(shape)) : buffer;
setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape, stride, offset,
Shape.elementWiseStride(shape, stride, ordering == 'f'), ordering));
init(shape, stride);
// Shape.setElementWiseStride(this.shapeInfo(),Shape.elementWiseStride(shape, stride, ordering == 'f'));
}
代码示例来源:origin: deeplearning4j/nd4j
/**
*
* @param data
* @param shape
* @param stride
* @param offset
*/
public BaseNDArray(DataBuffer data, int[] shape, int[] stride, long offset) {
this.data = Nd4j.createBuffer(data, offset, ArrayUtil.prodLong(shape));
setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape, stride, offset, Shape.elementWiseStride(shape, stride, Nd4j.order() == 'f'), Nd4j.order()));
init(shape, stride);
// Shape.setElementWiseStride(this.shapeInfo(),Shape.elementWiseStride(shape, stride, Nd4j.order() == 'f'));
}
代码示例来源:origin: deeplearning4j/nd4j
public BaseSparseNDArrayCOO(float[] values, int[][] indices, int[] shape) {
checkArgument(values.length == indices.length);
checkArgument(values.length == 0 || indices[0].length == shape.length);
this.values = Nd4j.createBuffer(values);
this.indices = Nd4j.createBuffer(ArrayUtil.flatten(indices));
setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape));
init(shape);
this.length = values.length;
int[] flags = new int[rank()];
long[] sparseOffsets = new long[rank()];
int[] hiddenDimension = new int[] {-1};
this.sparseInformation = Nd4j.getSparseInfoProvider().createSparseInformation(flags, sparseOffsets,
hiddenDimension, rank());
}
代码示例来源:origin: deeplearning4j/nd4j
public BaseSparseNDArrayCOO(DataBuffer values, DataBuffer indices, int[] shape) {
checkArgument(values.length() * shape.length == indices.length());
this.values = Nd4j.createBuffer(values, 0, values.length());
this.indices = indices;
setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape));
init(shape);
this.length = values.length();
int[] flags = new int[rank()];
long[] sparseOffsets = new long[rank()];
int[] hiddenDimension = new int[] {-1};
this.sparseInformation = Nd4j.getSparseInfoProvider().createSparseInformation(flags, sparseOffsets,
hiddenDimension, rank());
}
代码示例来源:origin: deeplearning4j/nd4j
public BaseSparseNDArrayCSR(DataBuffer data, int[] columnsPointers, int[] pointerB, int[] pointerE, int[] shape) {
checkArgument(pointerB.length == pointerE.length);
setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape));
init(shape);
this.values = data;
this.columnsPointers = Nd4j.getDataBufferFactory().createInt(data.length());
this.columnsPointers.setData(columnsPointers);
this.length = columnsPointers.length;
// The size of these pointers are constant
int pointersSpace = rows;
this.pointerB = Nd4j.getDataBufferFactory().createInt(pointersSpace);
this.pointerB.setData(pointerB);
this.pointerE = Nd4j.getDataBufferFactory().createInt(pointersSpace);
this.pointerE.setData(pointerE);
}
内容来源于网络,如有侵权,请联系作者删除!