Interface NDManager
- All Superinterfaces:
 AutoCloseable
- All Known Implementing Classes:
 BaseNDManager
NDManager is implemented in each deep learning Engine. NDArrays are resources
 that are allocated in each deep learning engine's native memory space. NDManager is the key class
 that manages these native resources.
 
NDArray can only be created through NDManager. By default, NDArray's lifecycle is attached to
 the creator NDManager. NDManager itself implements AutoCloseable. When NDManager is
 closed, all the resource associated with it will be closed as well.
 
A typical place to obtain NDManager is in PreProcessor.processInput(TranslatorContext, Object) or PostProcessor.processOutput(TranslatorContext, NDList).
 
The following is an example of how to use NDManager:
 public class MyTranslator implements Translator<FloatBuffer, String> {
     @Override
     public NDList processInput(TranslatorContext ctx, FloatBuffer input) {
         NDManager manager = ctx.getNDManager();
         NDArray array = manager.create(shape);
         array.set(input);
         return new NDList(array);
     } // NDArrays created in this method will be closed after method return.
 }
 
 NDManager has a hierarchical structure; it has a single parent NDManager and has child NDManagers. When the parent NDManager is closed, all children will be closed as well.
The DJL engine manages NDManager's lifecycle by default. You only need to manage the user created child NDManager. The child NDManager becomes useful when you create a large number of temporary NDArrays and want to free the resources earlier than the parent NDManager's lifecycle.
The following is an example of such a use case:
 public class MyTranslator implements Translator<List<FloatBuffer>>, String> {
     @Override
     public NDList processInput(TranslatorContext ctx, List<FloatBuffer> input) {
         NDManager manager = ctx.getNDManager();
         NDArray array = manager.create(shape, dataType);
         for (int i = 0; i < input.size(); ++i) {
             try (NDManager childManager = manager.newSubManager()) {
                  NDArray tmp = childManager.create(itemShape);
                  tmp.put(input.get(i);
                  array.put(i, tmp);
             } // NDArray tmp will be closed here
         }
         return new NDList(array);
     }
 }
 
 You can also close an individual NDArray. NDManager won't close an NDArray that's already been closed. In certain use cases, you might want to return an NDArray outside of NDManager's scope.
- 
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceANDManager.SystemNDManageris a marker class for a base NDManager. - 
Field Summary
Fields - 
Method Summary
Modifier and TypeMethodDescriptionallocateDirect(int capacity) Allocates a new engine specific direct byte buffer.default NDArrayarange(float stop) Returns evenly spaced values starting from 0.default NDArrayarange(float start, float stop) Returns evenly spaced values within a given interval with step 1.default NDArrayarange(float start, float stop, float step) Returns evenly spaced values within a given interval.Returns evenly spaced values within a given interval.default NDArrayReturns evenly spaced values within a given interval.default NDArrayarange(int stop) Returns evenly spaced values starting from 0.default NDArrayarange(int start, int stop) Returns evenly spaced values within a given interval with step 1.default NDArrayarange(int start, int stop, int step) Returns evenly spaced values within a given interval.default NDArrayReturns evenly spaced values within a given interval.default voidattachAll(NDResource... resources) Attaches all resources to this manager.voidattachInternal(String resourceId, AutoCloseable... resource) Attaches a resource to thisNDManager.voidattachUncappedInternal(String resourceId, AutoCloseable resource) Attaches a resource to thisNDManagercircumventing any cap protection.voidcap()Caps this manager to prevent unintentional attachment of resources.voidclose()default NDArraycreate(boolean data) Creates and initializes a scalarNDArray.default NDArraycreate(boolean[] data) Creates and initializes a 1DNDArray.default NDArraycreate(boolean[][] data) Creates and initializes a 2-DNDArray.default NDArraydefault NDArraycreate(byte data) Creates and initializes a scalarNDArray.default NDArraycreate(byte[] data) Creates and initializes a 1DNDArray.default NDArraycreate(byte[][] data) Creates and initializes a 2-DNDArray.default NDArraydefault NDArraycreate(double data) Creates and initializes a scalarNDArray.default NDArraycreate(double[] data) Creates and initializes a 1DNDArray.default NDArraycreate(double[][] data) Creates and initializes a 2DNDArray.default NDArraydefault NDArraycreate(float data) Creates and initializes a scalarNDArray.default NDArraycreate(float[] data) Creates and initializes a 1DNDArray.default NDArraycreate(float[][] data) Creates and initializes a 2DNDArray.default NDArraydefault NDArraycreate(int data) Creates and initializes a scalarNDArray.default NDArraycreate(int[] data) Creates and initializes a 1DNDArray.default NDArraycreate(int[][] data) Creates and initializes a 2DNDArray.default NDArraydefault NDArraycreate(long data) Creates and initializes a scalarNDArray.default NDArraycreate(long[] data) Creates and initializes a 1DNDArray.default NDArraycreate(long[][] data) Creates and initializes a 2-DNDArray.default NDArraydefault NDArraydefault NDArraydefault NDArrayCreates and initializes a scalarNDArray.default NDArrayCreates and initializes a scalarNDArray.default NDArrayCreates and initializes 1DNDArray.default NDArrayCreates a StringNDArraybased on the provided shape.default NDArrayCreates and initializes 1DNDArray.Creates a StringNDArraybased on the provided shape.default NDArraydefault NDArrayCreates a Coordinate Format (COO) Matrix.default NDArrayCreates a Compressed Sparse Row Storage (CSR) Format Matrix.Creates a Compressed Sparse Row Storage (CSR) Format Matrix.default NDArrayCreates a Compressed Sparse Row Storage (CSR) Format Matrix.createRowSparse(Buffer data, Shape dataShape, long[] indices, Shape shape) Stores the matrix in row sparse format.default NDArraycreateRowSparse(Buffer data, Shape dataShape, long[] indices, Shape shape, Device device) Stores the matrix in row sparse format.default NDArraydecode(byte[] bytes) DecodesNDArraythrough byte array.default NDArraydecode(InputStream is) DecodesNDArraythroughDataInputStream.Returns the default context used in Engine.voiddetachInternal(String resourceId) Detaches aNDArrayfrom thisNDManager's lifecycle.default NDArrayeye(int rows) Returns a 2-D array with ones on the diagonal and zeros elsewhere.default NDArrayeye(int rows, int k) Returns a 2-D array with ones on the diagonal and zeros elsewhere.default NDArrayeye(int rows, int cols, int k) Returns a 2-D array with ones on the diagonal and zeros elsewhere.Returns a 2-D array with ones on the diagonal and zeros elsewhere.default NDArrayReturns a 2-D array with ones on the diagonal and zeros elsewhere.Creates a newNDArrayif the inputNDArrayis from an external engine.default NDArrayReturn a newNDArrayof given shape, filled with value.Return a newNDArrayof given shape, filled with value.default NDArrayReturn a newNDArrayof given shape, device, filled with value.default NDArrayReturn a newNDArrayof given shape, filled with value.Returns the defaultDeviceof thisNDManager.Returns theEngineassociated with this manager.Returns allNDArrays managed by this manager (including recursively).getName()Gets the name of the NDManager.Returns the parentNDManager.default NDArrayhanningWindow(long numPoints) Builds the Hanning Window.voidAn engine specific generic invocation to native operation.An engine specific generic invocation to native operation.booleanisOpen()Check if the manager is still valid.default NDArraylinspace(float start, float stop, int num) Returns evenly spaced numbers over a specified interval.linspace(float start, float stop, int num, boolean endpoint) Returns evenly spaced numbers over a specified interval.default NDArrayReturns evenly spaced numbers over a specified interval.default NDArraylinspace(int start, int stop, int num) Returns evenly spaced numbers over a specified interval.default NDArraylinspace(int start, int stop, int num, boolean endpoint) Returns evenly spaced numbers over a specified interval.Loads the NDArrays saved to a file.default NDListLoads the NDArrays saved to a file.static NDManagerCreates a new top-levelNDManager.static NDManagernewBaseManager(Device device) Creates a new top-levelNDManagerwith specifiedDevice.static NDManagernewBaseManager(Device device, String engineName) Creates a new top-levelNDManagerwith specifiedDeviceand engine.static NDManagernewBaseManager(String engineName) Creates a new top-levelNDManagerwith specified engine.Creates a childNDManager.newSubManager(Device device) Creates a childNDManagerwith specified defaultDevice.static StringnextUid()Returns a low-cost unique ID.default NDArraydefault NDArraydefault NDArrayrandomInteger(long low, long high, Shape shape, DataType dataType) Returns random integer values from low (inclusive) to high (exclusive).randomMultinomial(int n, NDArray pValues) Draw samples from a multinomial distribution.randomMultinomial(int n, NDArray pValues, Shape shape) Draw samples from a multinomial distribution.randomNormal(float loc, float scale, Shape shape, DataType dataType) Draws random samples from a normal (Gaussian) distribution.default NDArrayrandomNormal(float loc, float scale, Shape shape, DataType dataType, Device device) Draws random samples from a normal (Gaussian) distribution.default NDArrayrandomNormal(Shape shape) Draws random samples from a normal (Gaussian) distribution with mean 0 and standard deviation 1.default NDArrayrandomNormal(Shape shape, DataType dataType) Draws random samples from a normal (Gaussian) distribution with mean 0 and standard deviation 1.randomPermutation(long n) Returns a random permutation of integers from 0 to n - 1.default NDArrayrandomUniform(float low, float high, Shape shape) Draws samples from a uniform distribution.randomUniform(float low, float high, Shape shape, DataType dataType) Draws samples from a uniform distribution.default NDArrayrandomUniform(float low, float high, Shape shape, DataType dataType, Device device) Draws samples from a uniform distribution.default <T extends NDResource>
Tret(T resource) Returns a value outside of this manager by attaching to this manager's parent.sampleGamma(NDArray alpha, NDArray beta) Draw random samples from a gamma distribution.sampleGamma(NDArray alpha, NDArray beta, Shape shape) Draw random samples from a gamma distribution.sampleNormal(NDArray mu, NDArray sigma) Concurrent sampling from multiple normal distributions with parameters *mu* (mean) and *sigma* (standard deviation).sampleNormal(NDArray mu, NDArray sigma, Shape shape) Concurrent sampling from multiple normal distributions with parameters *mu* (mean) and *sigma* (standard deviation).samplePoisson(NDArray lam) Draw random samples from a Poisson distribution.samplePoisson(NDArray lam, Shape shape) Draw random samples from a Poisson distribution.voidSets the name for the NDManager.static NDManagersubManagerOf(NDResource resource) Creates a new manager based on the given resource.default voidtempAttachAll(NDResource... resources) Temporarily attaches all resources to this manager.voidtempAttachInternal(NDManager originalManager, String resourceId, NDResource resource) Temporarily attaches a resource to thisNDManagerto be returned when this is closed.truncatedNormal(float loc, float scale, Shape shape, DataType dataType) Draws random samples from a normal (Gaussian) distribution, discarding and re-drawing any samples that are more than two standard deviations from the mean.default NDArraytruncatedNormal(float loc, float scale, Shape shape, DataType dataType, Device device) Draws random samples from a normal (Gaussian) distribution, discarding and re-drawing any samples that are more than two standard deviations from the mean.default NDArraytruncatedNormal(Shape shape) Draws random samples from a normal (Gaussian) distribution with mean 0 and standard deviation 1, discarding and re-drawing any samples that are more than two standard deviations from the mean.default NDArraytruncatedNormal(Shape shape, DataType dataType) Draws random samples from a normal (Gaussian) distribution with mean 0 and standard deviation 1, discarding and re-drawing any samples that are more than two standard deviations from the mean.default NDArraydefault NDArraydefault NDArray 
- 
Field Details
- 
UID_GENERATOR
 
 - 
 - 
Method Details
- 
nextUid
Returns a low-cost unique ID.- Returns:
 - a string UID.
 
 - 
newBaseManager
Creates a new top-levelNDManager.NDManagerwill inherit defaultDevice.- Returns:
 - a new top-level 
NDManager 
 - 
newBaseManager
Creates a new top-levelNDManagerwith specifiedDevice.- Parameters:
 device- the defaultDevice- Returns:
 - a new top-level 
NDManager 
 - 
newBaseManager
Creates a new top-levelNDManagerwith specified engine.- Parameters:
 engineName- the name of the engine- Returns:
 - a new top-level 
NDManager 
 - 
newBaseManager
Creates a new top-levelNDManagerwith specifiedDeviceand engine.- Parameters:
 device- the defaultDeviceengineName- the name of the engine- Returns:
 - a new top-level 
NDManager 
 - 
subManagerOf
Creates a new manager based on the given resource.- Parameters:
 resource- the resource to use- Returns:
 - a new memory scrope containing the array
 
 - 
defaultDevice
Device defaultDevice()Returns the default context used in Engine.The default type is defined by whether the deep learning engine is recognizing GPUs available on your machine. If there is no GPU available, CPU will be used.
- Returns:
 - a 
Device 
 - 
allocateDirect
Allocates a new engine specific direct byte buffer.- Parameters:
 capacity- the new buffer's capacity, in bytes- Returns:
 - the new byte buffer
 
 - 
from
Creates a newNDArrayif the inputNDArrayis from an external engine.- Parameters:
 array- the inputNDArray- Returns:
 - a new 
NDArrayif the inputNDArrayis from external engine 
 - 
create
 - 
create
Creates and initializes a scalarNDArray. - 
create
Creates and initializes a scalarNDArray.- Parameters:
 data- the float that needs to be set- Returns:
 - a new instance of 
NDArray 
 - 
create
Creates and initializes a scalarNDArray.- Parameters:
 data- the float data that needs to be set- Returns:
 - a new instance of 
NDArray 
 - 
create
Creates and initializes a scalarNDArray.- Parameters:
 data- the double data that needs to be set- Returns:
 - a new instance of 
NDArray 
 - 
create
Creates and initializes a scalarNDArray.- Parameters:
 data- the long data that needs to be set- Returns:
 - a new instance of 
NDArray 
 - 
create
Creates and initializes a scalarNDArray.- Parameters:
 data- the byte data that needs to be set- Returns:
 - a new instance of 
NDArray 
 - 
create
Creates and initializes a scalarNDArray.- Parameters:
 data- the boolean data that needs to be set- Returns:
 - a new instance of 
NDArray 
 - 
create
Creates and initializes a scalarNDArray.- Parameters:
 data- the String data that needs to be set- Returns:
 - a new instance of 
NDArray 
 - 
create
Creates and initializes 1DNDArray.- Parameters:
 data- the String data that needs to be set- Returns:
 - a new instance of 
NDArray 
 - 
create
Creates and initializes 1DNDArray.- Parameters:
 data- the String data that needs to be setcharset- the charset to decode the string- Returns:
 - a new instance of 
NDArray 
 - 
create
Creates a StringNDArraybased on the provided shape.- Parameters:
 data- the flattened String arrayshape- the shape of the String NDArray- Returns:
 - a new instance of 
NDArray 
 - 
create
Creates a StringNDArraybased on the provided shape.- Parameters:
 data- the flattened String arraycharset- the charset to decode the stringshape- the shape of the String NDArray- Returns:
 - a new instance of 
NDArray 
 - 
create
Creates and initializes a 1DNDArray.- Parameters:
 data- the float array that needs to be set- Returns:
 - a new instance of 
NDArray 
 - 
create
Creates and initializes a 1DNDArray.- Parameters:
 data- the float array that needs to be set- Returns:
 - a new instance of 
NDArray 
 - 
create
Creates and initializes a 1DNDArray.- Parameters:
 data- the float array that needs to be set- Returns:
 - a new instance of 
NDArray 
 - 
create
Creates and initializes a 1DNDArray.- Parameters:
 data- the float array that needs to be set- Returns:
 - a new instance of 
NDArray 
 - 
create
Creates and initializes a 1DNDArray.- Parameters:
 data- the float array that needs to be set- Returns:
 - a new instance of 
NDArray 
 - 
create
Creates and initializes a 1DNDArray.- Parameters:
 data- the bool array that needs to be set- Returns:
 - a new instance of 
NDArray 
 - 
create
Creates and initializes a 2DNDArray.- Parameters:
 data- the float array that needs to be set- Returns:
 - a new instance of 
NDArray 
 - 
create
Creates and initializes a 2DNDArray.- Parameters:
 data- the float array that needs to be set- Returns:
 - a new instance of 
NDArray 
 - 
create
Creates and initializes a 2DNDArray.- Parameters:
 data- the float array that needs to be set- Returns:
 - a new instance of 
NDArray 
 - 
create
Creates and initializes a 2-DNDArray.- Parameters:
 data- the float array that needs to be set- Returns:
 - a new instance of 
NDArray 
 - 
create
Creates and initializes a 2-DNDArray.- Parameters:
 data- the float array that needs to be set- Returns:
 - a new instance of 
NDArray 
 - 
create
Creates and initializes a 2-DNDArray.- Parameters:
 data- the boolean array that needs to be set- Returns:
 - a new instance of 
NDArray 
 - 
create
 - 
create
 - 
create
 - 
create
 - 
create
 - 
create
 - 
create
 - 
create
 - 
create
 - 
create
 - 
createCSR
Creates a Compressed Sparse Row Storage (CSR) Format Matrix.- Parameters:
 data- the data to set for the CSR Matrixindptr- the indptr array is what will help identify the rows where the data appearsindices- the indices array stores the column index for each non-zero element in datashape- theShapeof theNDArraydevice- theDeviceof theNDArray- Returns:
 - a new instance of 
NDArray 
 - 
createCSR
Creates a Compressed Sparse Row Storage (CSR) Format Matrix.- Parameters:
 data- the data to set for the CSR Matrixindptr- the indptr array is what will help identify the rows where the data appearsindices- the indices array stores the column index for each non-zero element in datashape- theShapeof theNDArraydevice- theDeviceof theNDArray- Returns:
 - a new instance of 
NDArray 
 - 
createCSR
Creates a Compressed Sparse Row Storage (CSR) Format Matrix. - 
createRowSparse
default NDArray createRowSparse(Buffer data, Shape dataShape, long[] indices, Shape shape, Device device) Stores the matrix in row sparse format. - 
createRowSparse
Stores the matrix in row sparse format. - 
createCoo
Creates a Coordinate Format (COO) Matrix. - 
decode
DecodesNDArraythrough byte array.- Parameters:
 bytes- byte array to load from- Returns:
 NDArray
 - 
decode
DecodesNDArraythroughDataInputStream.- Parameters:
 is- input stream data to load from- Returns:
 NDArray- Throws:
 IOException- data is not readable
 - 
load
Loads the NDArrays saved to a file.- Parameters:
 path- the path to the file- Returns:
 - the loaded arrays
 
 - 
load
Loads the NDArrays saved to a file.- Parameters:
 path- the path to the filedevice- the device to use for the loaded arrays- Returns:
 - the loaded arrays
 
 - 
setName
Sets the name for the NDManager.- Parameters:
 name- the name assigned to the manager
 - 
getName
String getName()Gets the name of the NDManager.- Returns:
 - name
 
 - 
zeros
 - 
zeros
 - 
zeros
 - 
ones
 - 
ones
 - 
ones
 - 
full
Return a newNDArrayof given shape, filled with value.- Parameters:
 shape- shape of a newNDArrayvalue- fill value- Returns:
 NDArrayof fill value with the given shape
 - 
full
Return a newNDArrayof given shape, filled with value.- Parameters:
 shape- shape of a newNDArrayvalue- fill value- Returns:
 NDArrayof fill value with the given shape
 - 
full
Return a newNDArrayof given shape, filled with value.- Parameters:
 shape- shape of a newNDArrayvalue- fill valuedataType- the desired data-type for theNDArray- Returns:
 NDArrayof fill value with the given shape
 - 
full
Return a newNDArrayof given shape, device, filled with value. - 
arange
Returns evenly spaced values starting from 0.Values are generated within the half-open interval [start, stop) (in other words, the interval including start but excluding stop). For integer arguments, the function is equivalent to the Python built-in range function, but returns an instance of
NDArrayrather than a list.- Parameters:
 stop- the end of the interval. The interval does not include this value- Returns:
 - a new instance of 
NDArray 
 - 
arange
Returns evenly spaced values starting from 0.Values are generated within the half-open interval [start, stop) (in other words, the interval including start but excluding stop). For integer arguments, the function is equivalent to the Python built-in range function, but returns an instance of
NDArrayrather than a list.- Parameters:
 stop- the end of the interval. The interval does not include this value- Returns:
 - a new instance of 
NDArray 
 - 
arange
Returns evenly spaced values within a given interval with step 1.Values are generated within the half-open interval [start, stop) (in other words, the interval including start but excluding stop). For integer arguments, the function is equivalent to the Python built-in range function, but returns an instance of
NDArrayrather than a list.- Parameters:
 start- the start of interval. The interval includes this valuestop- the end of interval. The interval does not include this value- Returns:
 - a new instance of 
NDArray 
 - 
arange
Returns evenly spaced values within a given interval with step 1.Values are generated within the half-open interval [start, stop) (in other words, the interval including start but excluding stop). For integer arguments, the function is equivalent to the Python built-in range function, but returns an instance of
NDArrayrather than a list.- Parameters:
 start- the start of interval. The interval includes this valuestop- the end of interval. The interval does not include this value- Returns:
 - a new instance of 
NDArray 
 - 
arange
Returns evenly spaced values within a given interval.Values are generated within the half-open interval [start, stop) (in other words, the interval including start but excluding stop). For integer arguments, the function is equivalent to the Python built-in range function, but returns an instance of
NDArrayrather than a list.- Parameters:
 start- the start of interval. The interval includes this valuestop- the end of interval. The interval does not include this valuestep- the spacing between values- Returns:
 - a new instance of 
NDArray 
 - 
arange
Returns evenly spaced values within a given interval.Values are generated within the half-open interval [start, stop) (in other words, the interval including start but excluding stop). For integer arguments, the function is equivalent to the Python built-in range function, but returns an instance of
NDArrayrather than a list.- Parameters:
 start- the start of interval. The interval includes this valuestop- the end of interval. The interval does not include this valuestep- the spacing between values- Returns:
 - a new instance of 
NDArray 
 - 
arange
Returns evenly spaced values within a given interval.Values are generated within the half-open interval [start, stop) (in other words, the interval including start but excluding stop). For integer arguments, the function is equivalent to the Python built-in range function, but returns an instance of
NDArrayrather than a list. - 
arange
Returns evenly spaced values within a given interval.Values are generated within the half-open interval [start, stop) (in other words, the interval including start but excluding stop). For integer arguments, the function is equivalent to the Python built-in range function, but returns an instance of
NDArrayrather than a list. - 
arange
Returns evenly spaced values within a given interval.Values are generated within the half-open interval [start, stop) (in other words, the interval including start but excluding stop). For integer arguments, the function is equivalent to the Python built-in range function, but returns an instance of
NDArrayrather than a list. - 
eye
Returns a 2-D array with ones on the diagonal and zeros elsewhere.- Parameters:
 rows- the number of rows and cols in the output- Returns:
 - a 
NDArraywhere all elements are equal to zero, except for the k-th diagonal, whose values are equal to one 
 - 
eye
Returns a 2-D array with ones on the diagonal and zeros elsewhere.- Parameters:
 rows- the number of rows and cols in the outputk- the index of the diagonal: a positive value refers to an upper diagonal, and a negative value to a lower diagonal- Returns:
 - a 
NDArraywhere all elements are equal to zero, except for the k-th diagonal, whose values are equal to one 
 - 
eye
Returns a 2-D array with ones on the diagonal and zeros elsewhere.- Parameters:
 rows- the number of rows in the outputcols- the number of columns in the outputk- the index of the diagonal: a positive value refers to an upper diagonal, and a negative value to a lower diagonal- Returns:
 - a 
NDArraywhere all elements are equal to zero, except for the k-th diagonal, whose values are equal to one 
 - 
eye
Returns a 2-D array with ones on the diagonal and zeros elsewhere.- Parameters:
 rows- the number of rows int the outputcols- the number of columns in the outputk- the index of the diagonal: a positive value refers to an upper diagonal, and a negative value to a lower diagonaldataType- theDataTypeof theNDArray- Returns:
 - a 
NDArraywhere all elements are equal to zero, except for the k-th diagonal, whose values are equal to one 
 - 
eye
Returns a 2-D array with ones on the diagonal and zeros elsewhere.- Parameters:
 rows- the number of rows int the outputcols- the number of columns in the outputk- the index of the diagonal: a positive value refers to an upper diagonal, and a negative value to a lower diagonaldataType- theDataTypeof theNDArraydevice- theDeviceof theNDArray- Returns:
 - a 
NDArraywhere all elements are equal to zero, except for the k-th diagonal, whose values are equal to one 
 - 
linspace
Returns evenly spaced numbers over a specified interval.Returns num evenly spaced samples, calculated over the interval [start, stop].
- Parameters:
 start- the starting value of the sequencestop- the end value of the sequencenum- the number of samples to generate- Returns:
 - a new instance of 
NDArray 
 - 
linspace
Returns evenly spaced numbers over a specified interval.Returns num evenly spaced samples, calculated over the interval [start, stop].
- Parameters:
 start- the starting value of the sequencestop- the end value of the sequencenum- the number of samples to generate- Returns:
 - a new instance of 
NDArray 
 - 
linspace
Returns evenly spaced numbers over a specified interval.Returns num evenly spaced samples, calculated over the interval [start, stop].The endpoint of the interval can optionally be excluded.
- Parameters:
 start- the starting value of the sequencestop- the end value of the sequencenum- the number of samples to generateendpoint- iftrue, stop is the last sample, otherwise, it is not included- Returns:
 - a new instance of 
NDArray 
 - 
linspace
Returns evenly spaced numbers over a specified interval.Returns num evenly spaced samples, calculated over the interval [start, stop].The endpoint of the interval can optionally be excluded.
- Parameters:
 start- the starting value of the sequencestop- the end value of the sequencenum- the number of samples to generateendpoint- iftrue, stop is the last sample, otherwise, it is not included- Returns:
 - a new instance of 
NDArray 
 - 
linspace
Returns evenly spaced numbers over a specified interval.Returns num evenly spaced samples, calculated over the interval [start, stop].The endpoint of the interval can optionally be excluded.
 - 
randomInteger
Returns random integer values from low (inclusive) to high (exclusive). - 
randomPermutation
Returns a random permutation of integers from 0 to n - 1.- Parameters:
 n- (int) – the upper bound (exclusive)- Returns:
 - a random permutation of integers from 0 to n - 1.
 
 - 
randomUniform
Draws samples from a uniform distribution.Samples are uniformly distributed over the half-open interval [low, high) (includes low, but excludes high). In other words, any value within the given interval is equally likely to be drawn by uniform.
 - 
randomUniform
Draws samples from a uniform distribution.Samples are uniformly distributed over the half-open interval [low, high) (includes low, but excludes high). In other words, any value within the given interval is equally likely to be drawn by uniform.
- Parameters:
 low- the lower boundary of the output interval. All values generated will be greater than or equal to low.high- the upper boundary of the output interval. All values generated will be less than high.shape- theShapeof theNDArraydataType- theDataTypeof theNDArray- Returns:
 - the drawn samples 
NDArray 
 - 
randomUniform
Draws samples from a uniform distribution.Samples are uniformly distributed over the half-open interval [low, high) (includes low, but excludes high). In other words, any value within the given interval is equally likely to be drawn by uniform.
- Parameters:
 low- the lower boundary of the output interval. All values generated will be greater than or equal to low.high- the upper boundary of the output interval. All values generated will be less than high.shape- theShapeof theNDArraydataType- theDataTypeof theNDArraydevice- theDeviceof theNDArray- Returns:
 - the drawn samples 
NDArray 
 - 
randomNormal
Draws random samples from a normal (Gaussian) distribution with mean 0 and standard deviation 1.Samples are distributed according to a normal distribution parametrized by mean = 0 and standard deviation = 1.
 - 
randomNormal
Draws random samples from a normal (Gaussian) distribution with mean 0 and standard deviation 1. - 
randomNormal
Draws random samples from a normal (Gaussian) distribution. - 
randomNormal
Draws random samples from a normal (Gaussian) distribution. - 
truncatedNormal
Draws random samples from a normal (Gaussian) distribution with mean 0 and standard deviation 1, discarding and re-drawing any samples that are more than two standard deviations from the mean.Samples are distributed according to a normal distribution parametrized by mean = 0 and standard deviation = 1.
 - 
truncatedNormal
Draws random samples from a normal (Gaussian) distribution with mean 0 and standard deviation 1, discarding and re-drawing any samples that are more than two standard deviations from the mean. - 
truncatedNormal
Draws random samples from a normal (Gaussian) distribution, discarding and re-drawing any samples that are more than two standard deviations from the mean. - 
truncatedNormal
default NDArray truncatedNormal(float loc, float scale, Shape shape, DataType dataType, Device device) Draws random samples from a normal (Gaussian) distribution, discarding and re-drawing any samples that are more than two standard deviations from the mean. - 
randomMultinomial
Draw samples from a multinomial distribution.The multinomial distribution is a multivariate generalization of the binomial distribution. Take an experiment with one of p possible outcomes. An example of such an experiment is throwing a dice, where the outcome can be 1 through 6. Each sample drawn from the distribution represents n such experiments. Its values, X_i = [X_0, X_1, ..., X_p], represent the number of times the outcome was i.
- Parameters:
 n- the number of experimentspValues- the probabilities of each of the p different outcomes. These should sum to 1 The last element is always assumed to account for the remaining probability, as long as pValues.sum().getFloat() <= 1)- Returns:
 - the drawn samples 
NDArray 
 - 
randomMultinomial
Draw samples from a multinomial distribution.The multinomial distribution is a multivariate generalization of the binomial distribution. Take an experiment with one of p possible outcomes. An example of such an experiment is throwing a dice, where the outcome can be 1 through 6. Each sample drawn from the distribution represents n such experiments. Its values, X_i = [X_0, X_1, ..., X_p], represent the number of times the outcome was i.
- Parameters:
 n- the number of experimentspValues- the probabilities of each of the p different outcomes. These should sum to 1 The last element is always assumed to account for the remaining probability, as long as pValues.sum().getFloat() <= 1)shape- the outputShape- Returns:
 - the drawn samples 
NDArray 
 - 
sampleNormal
Concurrent sampling from multiple normal distributions with parameters *mu* (mean) and *sigma* (standard deviation).- Parameters:
 mu- Means of the distributionssigma- Standard deviations of the distributions- Returns:
 - the drawn samples 
NDArray 
 - 
sampleNormal
Concurrent sampling from multiple normal distributions with parameters *mu* (mean) and *sigma* (standard deviation).- Parameters:
 mu- Means of the distributionssigma- Standard deviations of the distributionsshape- Shape to be sampled from each random distribution- Returns:
 - the drawn samples 
NDArray 
 - 
samplePoisson
Draw random samples from a Poisson distribution.Samples are distributed according to a Poisson distribution parametrized by *lambda* (rate). Samples will always be returned as a floating point data type.
- Parameters:
 lam- Lambda (rate) parameters of the distributions- Returns:
 - the drawn samples 
NDArray 
 - 
samplePoisson
Draw random samples from a Poisson distribution.Samples are distributed according to a Poisson distribution parametrized by *lambda* (rate). Samples will always be returned as a floating point data type.
- Parameters:
 lam- Lambda (rate) parameters of the distributionsshape- Shape to be sampled from each random distribution- Returns:
 - the drawn samples 
NDArray 
 - 
sampleGamma
Draw random samples from a gamma distribution.Samples are distributed according to a gamma distribution parametrized by *alpha* (shape) and *beta* (scale).
- Parameters:
 alpha- The shape of the gamma distributionbeta- The scale of the gamma distribution- Returns:
 - the drawn samples 
NDArray 
 - 
sampleGamma
Draw random samples from a gamma distribution.Samples are distributed according to a gamma distribution parametrized by *alpha* (shape) and *beta* (scale).
- Parameters:
 alpha- The shape of the gamma distributionbeta- The scale of the gamma distributionshape- Shape to be sampled from each random distribution- Returns:
 - the drawn samples 
NDArray 
 - 
hanningWindow
Builds the Hanning Window.The Hanning was named for Julius von Hann, an Austrian meteorologist. It is also known as the Cosine Bell. Some authors prefer that it be called a Hann window, to help avoid confusion with the very similar Hamming window.
- Parameters:
 numPoints- Number of points in the output window.- Returns:
 - the window
 
 - 
isOpen
boolean isOpen()Check if the manager is still valid.- Returns:
 - the current status
 
 - 
cap
void cap()Caps this manager to prevent unintentional attachment of resources. This is useful to detect memory leaks at an early point in time. The attachment of sub managers is still allowed after this method has been called. - 
getParentManager
NDManager getParentManager()Returns the parentNDManager.- Returns:
 - the parent 
NDManager 
 - 
newSubManager
NDManager newSubManager()Creates a childNDManager.Child
NDManagerwill inherit defaultDevicefrom thisNDManager.- Returns:
 - a child 
NDManager 
 - 
newSubManager
Creates a childNDManagerwith specified defaultDevice.- Parameters:
 device- the defaultDevice- Returns:
 - a child 
NDManager 
 - 
getDevice
Device getDevice()Returns the defaultDeviceof thisNDManager.- Returns:
 - the default 
Deviceof thisNDManager 
 - 
getManagedArrays
Returns allNDArrays managed by this manager (including recursively).- Returns:
 - all 
NDArrays managed by this manager (including recursively) 
 - 
attachInternal
Attaches a resource to thisNDManager.The attached resource will be closed when this
NDManageris closed.This attachment is internal. Many resources will internally track which manager they are attached to. In that case, you should call
NDResource.attach(NDManager)instead and that should then call attachInternal.- Parameters:
 resourceId- the unique resourceIdresource- theAutoCloseableresource to be attached
 - 
attachUncappedInternal
Attaches a resource to thisNDManagercircumventing any cap protection.The attached resource will be closed when this
NDManageris closed.This attachment is internal. Many resources will internally track which manager they are attached to. In that case, you should call
NDResource.attach(NDManager)instead and that should then call attachInternal.- Parameters:
 resourceId- the unique resourceIdresource- theAutoCloseableresource to be attached
 - 
tempAttachInternal
Temporarily attaches a resource to thisNDManagerto be returned when this is closed.The attached resource will be returned to it's original manager when this
NDManageris closed.This attachment is internal. Many resources will internally track which manager they are attached to. In that case, you should call
NDResource.attach(NDManager)instead and that should then call tempAttachInternal.- Parameters:
 originalManager- the original manager to return the resource toresourceId- the unique resourceIdresource- theAutoCloseableresource to be attached
 - 
detachInternal
Detaches aNDArrayfrom thisNDManager's lifecycle.The detached
NDArraybecome un-managed, it's user's responsibility to close the resource. Failed to close the resource has to wait on GC to be freed, and might cause out of native memory.This detach is internal. Many resources will internally track which manager they are attached to. In that case, you should call
NDResource.detach()instead and that should then call detachInternal.- Parameters:
 resourceId- the resourceId to be removed from thisNDManager's lifecycle
 - 
ret
Returns a value outside of this manager by attaching to this manager's parent.- Type Parameters:
 T- the type of the resource- Parameters:
 resource- the resource to return- Returns:
 - the passed in resource, after attaching to a new manager
 
 - 
attachAll
Attaches all resources to this manager.- Parameters:
 resources- the resources to attach- See Also:
 
 - 
tempAttachAll
Temporarily attaches all resources to this manager.- Parameters:
 resources- the resources to attach- See Also:
 
 - 
invoke
An engine specific generic invocation to native operation.You should avoid using this function if possible. Since this function is engine specific, using this API may cause a portability issue. Native operation may not be compatible between each version.
- Parameters:
 operation- the native operation to performsrc- theNDListof sourceNDArraydest- theNDListto save output toparams- the parameters to be passed to the native operation- Throws:
 IllegalArgumentException- if operation is not supported by EngineEngineException- if operation failed in native engine
 - 
invoke
An engine specific generic invocation to native operation.You should avoid using this function if possible. Since this function is engine specific, using this API may cause a portability issue. Native operation may not compatible between each version.
- Parameters:
 operation- the native operation to performsrc- theNDListof sourceNDArrayparams- the parameters to be passed to the native operation- Returns:
 - the output array of 
NDArray - Throws:
 IllegalArgumentException- if operation is not supported by EngineEngineException- if operation failed in native engine
 - 
getEngine
Engine getEngine()Returns theEngineassociated with this manager.- Returns:
 - the 
Engineassociated with this manager 
 - 
close
void close()- Specified by:
 closein interfaceAutoCloseable
 
 -