jacinle.nd.meta#
Functions
|
|
|
Check if the given object is a numpy array. |
|
Get the batch size of a numpy array. |
|
Concatenate a list of numpy arrays. |
|
Get the length of a numpy array. |
|
Split a numpy array into n parts. |
|
Split a size into n parts. |
Functions
- nd_batch_size(thing)[source]#
Get the batch size of a numpy array. This function handles the case when the input a nested list or dict.
Examples
>>> nd_batch_size(np.array([1, 2, 3])) 3 >>> nd_batch_size([np.zeros((2, 3)), np.zeros((2, 5))]) 2 >>> nd_batch_size({'a': np.zeros((2, 3)), 'b': np.zeros((2, 5))}) 2
- nd_concat(list_of_arrays)[source]#
Concatenate a list of numpy arrays. This function handles the case when the list is empty or contains only one element.
- nd_len(thing)[source]#
Get the length of a numpy array. This function handles the case when the input is a scalar or plain Python objects.
- nd_split_n(ndarray, n)[source]#
Split a numpy array into n parts. If the size is not divisible by n, the last part will be larger.