本文整理了Java中org.nd4j.linalg.factory.Nd4j.getNDArrayFactory()
方法的一些代码示例,展示了Nd4j.getNDArrayFactory()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Nd4j.getNDArrayFactory()
方法的具体详情如下:
包路径:org.nd4j.linalg.factory.Nd4j
类名称:Nd4j
方法名:getNDArrayFactory
暂无
代码示例来源:origin: deeplearning4j/nd4j
/**
* Sort an ndarray along a particular dimension<br>
* Note that the input array is modified in-place.
*
* @param ndarray the ndarray to sort
* @param dimension the dimension to sort
* @return the sorted ndarray
*/
public static INDArray sort(INDArray ndarray, int dimension, boolean ascending) {
return getNDArrayFactory().sort(ndarray, !ascending, dimension);
}
代码示例来源:origin: deeplearning4j/nd4j
public static INDArray sort(INDArray ndarray, boolean ascending) {
return getNDArrayFactory().sort(ndarray, !ascending);
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public DataBuffer compress(DataBuffer buffer) {
DataBuffer result = Nd4j.getNDArrayFactory().convertDataEx(getBufferTypeEx(buffer), buffer,
DataBuffer.TypeEx.FLOAT16);
return result;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public DataBuffer compress(DataBuffer buffer) {
DataBuffer result = Nd4j.getNDArrayFactory().convertDataEx(getBufferTypeEx(buffer), buffer,
DataBuffer.TypeEx.INT16);
return result;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public DataBuffer decompress(DataBuffer buffer) {
val type = getGlobalTypeEx();
DataBuffer result = Nd4j.getNDArrayFactory().convertDataEx(DataBuffer.TypeEx.FLOAT16, buffer, type);
return result;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public DataBuffer decompress(DataBuffer buffer) {
DataBuffer result = Nd4j.getNDArrayFactory().convertDataEx(DataBuffer.TypeEx.UINT8, buffer, getGlobalTypeEx());
return result;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public DataBuffer compress(DataBuffer buffer) {
DataBuffer result = Nd4j.getNDArrayFactory().convertDataEx(getBufferTypeEx(buffer), buffer,
DataBuffer.TypeEx.UINT8);
return result;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public DataBuffer compress(DataBuffer buffer) {
DataBuffer result = Nd4j.getNDArrayFactory().convertDataEx(getBufferTypeEx(buffer), buffer,
DataBuffer.TypeEx.FLOAT8);
return result;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public DataBuffer decompress(DataBuffer buffer) {
DataBuffer result = Nd4j.getNDArrayFactory().convertDataEx(DataBuffer.TypeEx.INT8, buffer, getGlobalTypeEx());
return result;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public DataBuffer decompress(DataBuffer buffer) {
DataBuffer result = Nd4j.getNDArrayFactory().convertDataEx(DataBuffer.TypeEx.FLOAT8, buffer, getGlobalTypeEx());
return result;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public DataBuffer compress(DataBuffer buffer) {
DataBuffer result =
Nd4j.getNDArrayFactory().convertDataEx(getBufferTypeEx(buffer), buffer, DataBuffer.TypeEx.INT8);
return result;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public DataBuffer decompress(DataBuffer buffer) {
DataBuffer result = Nd4j.getNDArrayFactory().convertDataEx(DataBuffer.TypeEx.INT16, buffer, getGlobalTypeEx());
return result;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public INDArray percentile(Number quantile, int... dimension) {
if (quantile.doubleValue() < 0 || quantile.doubleValue() > 100)
throw new ND4JIllegalStateException("Percentile value should be in 0...100 range");
if (isScalar())
return Nd4j.scalar(this.getDouble(0));
INDArray sorted = Nd4j.getNDArrayFactory().sort(this.dup(this.ordering()), false, dimension);
// there's no practical sense doing this on GPU, stride will be just size of TAD.
INDArray ret = Nd4j.createUninitialized(sorted.tensorssAlongDimension(dimension));
for (int i = 0; i < ret.length(); i++) {
ret.putScalar(i, getPercentile(quantile, sorted.tensorAlongDimension(i, dimension)));
}
return ret;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public INDArray percentile(Number quantile, int... dimension) {
if (quantile.doubleValue() < 0 || quantile.doubleValue() > 100)
throw new ND4JIllegalStateException("Percentile value should be in 0...100 range");
if (isScalar())
return Nd4j.scalar(this.getDouble(0));
INDArray sorted = Nd4j.getNDArrayFactory().sort(this.dup(this.ordering()), false, dimension);
// there's no practical sense doing this on GPU, stride will be just size of TAD.
INDArray ret = Nd4j.createUninitialized(sorted.tensorssAlongDimension(dimension));
for (int i = 0; i < ret.length(); i++) {
ret.putScalar(i, getPercentile(quantile, sorted.tensorAlongDimension(i, dimension)));
}
return ret;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public INDArray convertToDoubles() {
if (data.dataType() == DataBuffer.Type.DOUBLE)
return this;
val factory = Nd4j.getNDArrayFactory();
val buffer = Nd4j.createBuffer(new long[]{this.length()}, DataBuffer.Type.DOUBLE);
factory.convertDataEx(convertType(data.dataType()), this.data().addressPointer(), DataBuffer.TypeEx.DOUBLE, buffer.addressPointer(), buffer.length());
return Nd4j.createArrayFromShapeBuffer(buffer, this.shapeInformation);
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public INDArray convertToFloats() {
if (data.dataType() == DataBuffer.Type.FLOAT)
return this;
val factory = Nd4j.getNDArrayFactory();
val buffer = Nd4j.createBuffer(new long[]{this.length()}, DataBuffer.Type.FLOAT);
factory.convertDataEx(convertType(data.dataType()), this.data().addressPointer(), DataBuffer.TypeEx.FLOAT, buffer.addressPointer(), buffer.length());
return Nd4j.createArrayFromShapeBuffer(buffer, this.shapeInformation);
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
protected CompressedDataBuffer compressPointer(DataBuffer.TypeEx srcType, Pointer srcPointer, int length,
int elementSize) {
BytePointer ptr = new BytePointer(length);
CompressionDescriptor descriptor = new CompressionDescriptor();
descriptor.setCompressedLength(length * 1);
descriptor.setOriginalLength(length * elementSize);
descriptor.setOriginalElementSize(elementSize);
descriptor.setNumberOfElements(length);
descriptor.setCompressionAlgorithm(getDescriptor());
descriptor.setCompressionType(getCompressionType());
CompressedDataBuffer buffer = new CompressedDataBuffer(ptr, descriptor);
Nd4j.getNDArrayFactory().convertDataEx(srcType, srcPointer, DataBuffer.TypeEx.UINT8, ptr, length);
return buffer;
}
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
protected CompressedDataBuffer compressPointer(DataBuffer.TypeEx srcType, Pointer srcPointer, int length,
int elementSize) {
BytePointer ptr = new BytePointer(length);
CompressionDescriptor descriptor = new CompressionDescriptor();
descriptor.setCompressedLength(length * 1);
descriptor.setOriginalLength(length * elementSize);
descriptor.setOriginalElementSize(elementSize);
descriptor.setNumberOfElements(length);
descriptor.setCompressionAlgorithm(getDescriptor());
descriptor.setCompressionType(getCompressionType());
CompressedDataBuffer buffer = new CompressedDataBuffer(ptr, descriptor);
Nd4j.getNDArrayFactory().convertDataEx(srcType, srcPointer, DataBuffer.TypeEx.FLOAT8, ptr, length);
return buffer;
}
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
protected CompressedDataBuffer compressPointer(DataBuffer.TypeEx srcType, Pointer srcPointer, int length,
int elementSize) {
BytePointer ptr = new BytePointer(length * 2);
CompressionDescriptor descriptor = new CompressionDescriptor();
descriptor.setCompressedLength(length * 2);
descriptor.setOriginalLength(length * elementSize);
descriptor.setOriginalElementSize(elementSize);
descriptor.setNumberOfElements(length);
descriptor.setCompressionAlgorithm(getDescriptor());
descriptor.setCompressionType(getCompressionType());
CompressedDataBuffer buffer = new CompressedDataBuffer(ptr, descriptor);
Nd4j.getNDArrayFactory().convertDataEx(srcType, srcPointer, DataBuffer.TypeEx.INT16, ptr, length);
return buffer;
}
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
protected CompressedDataBuffer compressPointer(DataBuffer.TypeEx srcType, Pointer srcPointer, int length,
int elementSize) {
BytePointer ptr = new BytePointer(length * 2);
CompressionDescriptor descriptor = new CompressionDescriptor();
descriptor.setCompressedLength(length * 2);
descriptor.setOriginalLength(length * elementSize);
descriptor.setOriginalElementSize(elementSize);
descriptor.setNumberOfElements(length);
descriptor.setCompressionAlgorithm(getDescriptor());
descriptor.setCompressionType(getCompressionType());
CompressedDataBuffer buffer = new CompressedDataBuffer(ptr, descriptor);
Nd4j.getNDArrayFactory().convertDataEx(srcType, srcPointer, DataBuffer.TypeEx.FLOAT16, ptr, length);
return buffer;
}
}
内容来源于网络,如有侵权,请联系作者删除!