本文整理了Java中org.nd4j.linalg.factory.Nd4j.getStrides()
方法的一些代码示例,展示了Nd4j.getStrides()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Nd4j.getStrides()
方法的具体详情如下:
包路径:org.nd4j.linalg.factory.Nd4j
类名称:Nd4j
方法名:getStrides
[英]Get the strides based on the shape and NDArrays.order()
[中]根据形状和路线获得步幅。订单()
代码示例来源:origin: deeplearning4j/nd4j
/**
* @param data the data to use
* @param shape the shape of the ndarray
* @param offset the desired offset
* @param ordering the ordering of the ndarray
*/
public BaseNDArray(float[] data, int[] shape, long offset, char ordering) {
this(data, shape, Nd4j.getStrides(shape, ordering), offset);
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Constructor for stride and offset
*
* @param buffer
* @param shape
* @param offset
* @param ordering
*/
public BaseNDArray(DataBuffer buffer, int[] shape, long offset, char ordering) {
this(buffer, shape, Nd4j.getStrides(shape, ordering), offset, ordering);
}
代码示例来源:origin: deeplearning4j/nd4j
/**
*
* @param shape
* @param offset
* @param ordering
*/
public BaseNDArray(int[] shape, long offset, char ordering) {
this(shape, Nd4j.getStrides(shape, ordering), offset, ordering);
}
代码示例来源:origin: deeplearning4j/nd4j
/**
*
* @param shape
* @param offset
*/
public BaseNDArray(int[] shape, long offset) {
this(shape, Nd4j.getStrides(shape), offset);
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Create an ndarray from the specified slices.
* This will go through and merge all of the
* data from each slice in to one ndarray
* which will then take the specified shape
*
* @param slices the slices to merge
* @param shape the shape of the ndarray
*/
public BaseNDArray(List<INDArray> slices, int[] shape, char ordering) {
this(slices, shape, Nd4j.getStrides(shape, ordering), ordering);
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Create an ndrray with the specified shape
*
* @param data the data to use with tne ndarray
* @param shape the shape of the ndarray
* @return the created ndarray
*/
@Override
public INDArray create(double[] data, int[] shape) {
return create(data, shape, Nd4j.getStrides(shape), 0);
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public INDArray create(float[] data, long[] shape) {
//ensure shapes that wind up being scalar end up with the write shape
if (shape.length == 1 && shape[0] == 0) {
shape = new long[] {1, 1};
}
return create(data, shape, Nd4j.getStrides(shape), 0);
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public INDArray create(double[] data, long[] shape) {
//ensure shapes that wind up being scalar end up with the write shape
if (shape.length == 1 && shape[0] == 0) {
shape = new long[] {1, 1};
}
return create(data, shape, Nd4j.getStrides(shape), 0);
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Create with the specified shape and buffer
*
* @param shape the shape
* @param buffer the buffer
*/
public BaseNDArray(int[] shape, DataBuffer buffer) {
this.data = buffer;
init(shape, Nd4j.getStrides(shape));
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Get the strides based on the shape
* and NDArrays.order()
*
* @param shape the shape of the ndarray
* @return the strides for the given shape
* and order specified by NDArrays.order()
*/
public static int[] getStrides(int[] shape) {
return getStrides(shape, Nd4j.order());
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Get the strides based on the shape
* and NDArrays.order()
*
* @param shape the shape of the ndarray
* @return the strides for the given shape
* and order specified by NDArrays.order()
*/
public static long[] getStrides(long[] shape) {
return getStrides(shape, Nd4j.order());
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Calculate the strides based on the given indices
*
* @param ordering the ordering to calculate strides for
* @param indexes the indices to calculate stride for
* @return the strides for the given indices
*/
public static int[] strides(char ordering, NDArrayIndex... indexes) {
return Nd4j.getStrides(shape(indexes), ordering);
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public INDArray create(double[] data, char order) {
return create(data, new int[] {1, data.length}, Nd4j.getStrides(new int[] {1, data.length}, order), order, 0);
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Creates an ndarray with the specified shape
*
* @param shape the shape of the ndarray
* @return the instance
*/
@Override
public INDArray create(long[] shape) {
//ensure shapes that wind up being scalar end up with the write shape
return create(shape, Nd4j.getStrides(shape), 0L);
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public INDArray create(float[] data, char order) {
int[] shape = new int[] {1, data.length};
return create(Nd4j.createBuffer(data), shape, Nd4j.getStrides(shape, order), order, 0);
}
代码示例来源:origin: deeplearning4j/nd4j
/**
*
* @param data
* @param shape
*/
public BaseNDArray(DataBuffer data, int[] shape) {
this(data, shape, Nd4j.getStrides(shape, Nd4j.order()), 0, Nd4j.order());
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public INDArray create(float[] data, int[] shape, char ordering) {
//ensure shapes that wind up being scalar end up with the write shape
if (shape.length == 1 && shape[0] == 0) {
shape = new int[] {1, 1};
}
return create(Nd4j.createBuffer(data), shape, Nd4j.getStrides(shape, ordering), 0, ordering);
}
代码示例来源:origin: deeplearning4j/nd4j
/**
*
* @param floatBuffer
* @param order
*/
public BaseNDArray(DataBuffer floatBuffer, char order) {
this(floatBuffer, new int[] {(int) floatBuffer.length()},
Nd4j.getStrides(new int[] {(int) floatBuffer.length()}, order), 0, order);
if (floatBuffer.length() >= Integer.MAX_VALUE)
throw new IllegalArgumentException("Length of buffer can not be >= Integer.MAX_VALUE");
}
代码示例来源:origin: deeplearning4j/nd4j
/**
*
* @param buffer
* @param shape
* @param offset
*/
public BaseNDArray(DataBuffer buffer, int[] shape, long offset) {
this(Nd4j.createBuffer(buffer, offset, ArrayUtil.prodLong(shape)), shape, Nd4j.getStrides(shape), offset,
Nd4j.order());
}
代码示例来源: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);
}
内容来源于网络,如有侵权,请联系作者删除!