本文整理了Java中org.nd4j.linalg.factory.Nd4j.create()
方法的一些代码示例,展示了Nd4j.create()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Nd4j.create()
方法的具体详情如下:
包路径:org.nd4j.linalg.factory.Nd4j
类名称:Nd4j
方法名:create
[英]Creates a row vector with the specified number of columns
[中]创建具有指定列数的行向量
代码示例来源:origin: deeplearning4j/nd4j
protected INDArray create(DataBuffer data, int[] shape, long offset) {
if (this instanceof IComplexNDArray)
return Nd4j.createComplex(data, shape, offset);
else
return Nd4j.create(data, shape, offset);
}
代码示例来源:origin: deeplearning4j/nd4j
/**
*
* @param shape
* @param stride
* @param ordering
* @return
*/
public static INDArray zeros(int[] shape, int[] stride, char ordering) {
return create(shape, stride, ordering);
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Creates a row vector with the specified number of columns
*
* @param columns the columns of the ndarray
* @return the created ndarray
*/
public static INDArray create(int columns) {
return create(columns, order());
}
代码示例来源:origin: deeplearning4j/nd4j
protected INDArray create(DataBuffer data, int[] newShape, int[] newStrides, long offset, char ordering) {
if (this instanceof IComplexNDArray)
return Nd4j.createComplex(data, newShape, newStrides, offset, ordering);
else
return Nd4j.create(data, newShape, newStrides, offset, ordering);
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Creates an ndarray with the specified shape
*
* @param rows the rows of the ndarray
* @param columns the columns of the ndarray
* @param stride the stride for the ndarray
* @return the instance
*/
public static INDArray create(int rows, int columns, int[] stride) {
return create(rows, columns, stride, order());
}
代码示例来源:origin: deeplearning4j/nd4j
protected INDArray create(DataBuffer data, int[] newShape, int[] newStrides, long offset) {
if (this instanceof IComplexNDArray)
return Nd4j.createComplex(data, newShape, newStrides, offset);
else
return Nd4j.create(data, newShape, newStrides, offset);
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Creates an ndarray with the specified shape
*
* @param rows the rows of the ndarray
* @param columns the columns of the ndarray
* @return the instance
*/
public static INDArray create(int rows, int columns) {
return create(rows, columns, order());
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Computes the eigenvalues of a general matrix.
*/
public static IComplexNDArray eigenvalues(INDArray A) {
assert A.rows() == A.columns();
INDArray WR = Nd4j.create(A.rows(), A.rows());
INDArray WI = WR.dup();
Nd4j.getBlasWrapper().geev('N', 'N', A.dup(), WR, WI, dummy, dummy);
return Nd4j.createComplex(WR, WI);
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public INDArray sample(long[] shape) {
INDArray ret = Nd4j.create(shape);
return sample(ret);
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Creates a row vector with the data
*
* @param data the columns of the ndarray
* @return the created ndarray
*/
public static INDArray create(float[] data) {
return create(data, order());
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Creates a row vector with the data
*
* @param data the columns of the ndarray
* @return the created ndarray
*/
public static INDArray create(double[] data) {
return create(data, order());
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Creates an ndarray with the specified shape
*
* @param shape the shape of the ndarray
* @return the instance
*/
public static INDArray create(long... shape) {
return create(shape, order());
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public INDArray sample(int[] shape) {
INDArray ret = Nd4j.create(shape);
return sample(ret);
}
代码示例来源:origin: deeplearning4j/nd4j
public static INDArray toNDArray(int[][] nums) {
if (Nd4j.dataType() == DataBuffer.Type.DOUBLE) {
double[] doubles = ArrayUtil.toDoubles(nums);
INDArray create = Nd4j.create(doubles, new int[] {nums[0].length, nums.length});
return create;
} else {
float[] doubles = ArrayUtil.toFloats(nums);
INDArray create = Nd4j.create(doubles, new int[] {nums[0].length, nums.length});
return create;
}
}
代码示例来源:origin: deeplearning4j/nd4j
private void growCapacity(int idx) {
if(container == null) {
container = Nd4j.create(10);
}
else if(idx >= container.length()) {
val max = Math.max(container.length() * 2,idx);
INDArray newContainer = Nd4j.create(max);
newContainer.put(new INDArrayIndex[]{NDArrayIndex.interval(0,container.length())},container);
container = newContainer;
}
}
代码示例来源:origin: deeplearning4j/nd4j
protected INDArray createScalarForIndex(long i, boolean applyOffset) {
if(isVector())
return getScalar(i);
return Nd4j.create(data(), new long[] {1, 1}, new long[] {1, 1}, i);
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public INDArray nextFloat(char order, long[] shape) {
long length = ArrayUtil.prodLong(shape);
INDArray ret = Nd4j.create(shape, order);
DataBuffer data = ret.data();
for (long i = 0; i < length; i++) {
data.put(i, nextFloat());
}
return ret;
}
代码示例来源:origin: deeplearning4j/nd4j
public static INDArray convertFromApacheMatrix(RealMatrix matrix) {
int[] shape = new int[] {matrix.getRowDimension(), matrix.getColumnDimension()};
INDArray out = Nd4j.create(shape);
for (int i = 0; i < shape[0]; i++) {
for (int j = 0; j < shape[1]; j++) {
double value = matrix.getEntry(i, j);
out.putScalar(new int[] {i, j}, value);
}
}
return out;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public INDArray getReal() {
INDArray result = Nd4j.create(shape());
IComplexNDArray linearView = linearView();
INDArray linearRet = result.linearView();
for (int i = 0; i < linearView.length(); i++) {
linearRet.putScalar(i, linearView.getReal(i));
}
return result;
}
代码示例来源:origin: deeplearning4j/nd4j
public static INDArray im2col(INDArray img, int kh, int kw, int sy, int sx, int ph, int pw, int dh, int dw, boolean isSameMode) {
Nd4j.getCompressor().autoDecompress(img);
//Input: NCHW format
// FIXME: int cast
int outH = outputSize((int) img.size(2), kh, sy, ph, dh, isSameMode);
int outW = outputSize((int) img.size(3), kw, sx, pw, dw, isSameMode);
//[miniBatch,depth,kH,kW,outH,outW]
INDArray out = Nd4j.create(new long[]{img.size(0), img.size(1), kh, kw, outH, outW}, 'c');
return im2col(img, kh, kw, sy, sx, ph, pw, dh, dw, isSameMode, out);
}
内容来源于网络,如有侵权,请联系作者删除!