本文整理了Java中org.nd4j.linalg.factory.Nd4j.setDataType()
方法的一些代码示例,展示了Nd4j.setDataType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Nd4j.setDataType()
方法的具体详情如下:
包路径:org.nd4j.linalg.factory.Nd4j
类名称:Nd4j
方法名:setDataType
[英]This method sets dataType for the current JVM runtime
[中]此方法为当前JVM运行时设置数据类型
代码示例来源:origin: deeplearning4j/dl4j-examples
public static void main(String[] args) {
Nd4j.setDataType(DataBuffer.Type.DOUBLE);
INDArray arr = Nd4j.create(300);
double numTimes = 10000000;
double total = 0;
for(int i = 0; i < numTimes; i++) {
long start = System.nanoTime();
Nd4j.getBlasWrapper().axpy(new Integer(1), arr,arr);
long after = System.nanoTime();
long add = Math.abs(after - start);
System.out.println("Took " + add);
total += Math.abs(after - start);
}
System.out.println("Avg time " + (total / numTimes));
}
}
代码示例来源:origin: deeplearning4j/dl4j-examples
public static void main(String[] args) throws Exception {
Nd4j.setDataType(DataBuffer.Type.HALF);
代码示例来源:origin: deeplearning4j/dl4j-examples
public static void main(String[] args) throws Exception {
Nd4j.setDataType(DataBuffer.Type.HALF);
代码示例来源:origin: deeplearning4j/dl4j-examples
public static void main(String[] args) throws Exception {
Nd4j.setDataType(DataBuffer.Type.HALF);
代码示例来源:origin: improbable-research/keanu
private INDArray doubleNextDouble(long[] shape) {
Nd4j.setDataType(bufferType);
return nd4jRandom.nextDouble(shape);
}
代码示例来源:origin: improbable-research/keanu
public static INDArray vector(double[] vectorValues, DataBuffer.Type bufferType) {
Nd4j.setDataType(bufferType);
return Nd4j.trueVector(vectorValues);
}
代码示例来源:origin: improbable-research/keanu
private INDArray doubleNextInt(long[] shape) {
Nd4j.setDataType(bufferType);
return nd4jRandom.nextInt(shape);
}
代码示例来源:origin: improbable-research/keanu
private INDArray doubleNextGaussian(long[] shape) {
Nd4j.setDataType(bufferType);
return nd4jRandom.nextGaussian(shape);
}
代码示例来源:origin: improbable-research/keanu
public static INDArray scalar(double scalarValue, DataBuffer.Type bufferType) {
Nd4j.setDataType(bufferType);
return Nd4j.trueScalar(scalarValue);
}
代码示例来源:origin: improbable-research/keanu
public static INDArray zeros(long[] shape, DataBuffer.Type bufferType) {
Nd4j.setDataType(bufferType);
return Nd4j.zeros(shape);
}
代码示例来源:origin: improbable-research/keanu
public static INDArray eye(long n, DataBuffer.Type bufferType) {
Nd4j.setDataType(bufferType);
if (n == 0) {
return scalar(1.0, bufferType);
}
return Nd4j.eye(n);
}
代码示例来源:origin: improbable-research/keanu
public static INDArray arange(double start, double end, DataBuffer.Type bufferType) {
Nd4j.setDataType(bufferType);
return reshapeToVector(Nd4j.arange(start, end));
}
代码示例来源:origin: improbable-research/keanu
public static INDArray valueArrayOf(long[] shape, double value, DataBuffer.Type bufferType) {
Nd4j.setDataType(bufferType);
switch (shape.length) {
case 0:
return scalar(value, bufferType);
case 1:
return reshapeToVector(Nd4j.valueArrayOf(shape, value));
default:
return Nd4j.valueArrayOf(shape, value);
}
}
代码示例来源:origin: improbable-research/keanu
public static INDArray ones(long[] shape, DataBuffer.Type bufferType) {
Nd4j.setDataType(bufferType);
switch (shape.length) {
case 0:
return scalar(1.0, bufferType);
case 1:
return reshapeToVector(Nd4j.ones(shape));
default:
return Nd4j.ones(shape);
}
}
代码示例来源:origin: improbable-research/keanu
public static INDArray create(double[] data, long[] shape, DataBuffer.Type bufferType) {
Nd4j.setDataType(bufferType);
switch (shape.length) {
case 0:
Preconditions.checkArgument(data.length == 1, "Scalar shape must have only one data element.");
return scalar(data[0], bufferType);
case 1:
return vector(data, bufferType);
default:
DataBuffer buffer = Nd4j.getDataBufferFactory().createDouble(data);
return Nd4j.create(buffer, shape);
}
}
代码示例来源:origin: improbable-research/keanu
public static INDArray linspace(double start, double end, int numberOfPoints, DataBuffer.Type bufferType) {
Nd4j.setDataType(bufferType);
return Nd4j.getExecutioner().exec(
new Linspace(Nd4j.createUninitialized(new long[]{numberOfPoints}, Nd4j.order()), start, end)
);
}
代码示例来源:origin: sjsdfg/dl4j-tutorials
public static void main(String[] args) {
DataTypeUtil.setDTypeForContext(DataBuffer.Type.DOUBLE);
Nd4j.setDataType(DataBuffer.Type.DOUBLE);
内容来源于网络,如有侵权,请联系作者删除!