spateo.alignment.methods.backend¶
Attributes¶
Classes¶
Backend abstract class. |
|
NumPy implementation of the backend. |
|
PyTorch implementation of the backend |
Functions¶
|
|
|
|
|
|
Returns instances of all available backends. |
|
Returns the list of available backend implementations. |
|
|
Returns the proper backend for a list of input arrays |
|
Returns numpy arrays from any compatible backend |
Module Contents¶
- spateo.alignment.methods.backend.str_type_error = 'All array should be from the same type/backend. Current types are : {}'[source]¶
- spateo.alignment.methods.backend.get_backend_list()[source]¶
Returns instances of all available backends.
Note that the function forces all detected implementations to be instantiated even if specific backend was not use before. Be careful as instantiation of the backend might lead to side effects, like GPU memory pre-allocation. See the documentation for more details. If you only need to know which implementations are available, use :py:func:`ot.backend.get_available_backend_implementations, which does not force instance of the backend object to be created.
- spateo.alignment.methods.backend.get_available_backend_implementations()[source]¶
Returns the list of available backend implementations.
- spateo.alignment.methods.backend.get_backend(*args)[source]¶
Returns the proper backend for a list of input arrays
Accepts None entries in the arguments, and ignores them
Also raises TypeError if all arrays are not from the same backend
- spateo.alignment.methods.backend.to_numpy(*args)[source]¶
Returns numpy arrays from any compatible backend
- class spateo.alignment.methods.backend.Backend[source]¶
Backend abstract class. Implementations:
JaxBackend,NumpyBackend,TorchBackend,CupyBackend,TensorflowBackendThe __name__ class attribute refers to the name of the backend.
The __type__ class attribute refers to the data structure used by the backend.
- from_numpy(*arrays, type_as=None)[source]¶
Creates tensors cloning a numpy array, with the given precision (defaulting to input’s precision) and the given device (in case of GPUs)
- abstract _from_numpy(a, type_as=None)[source]¶
Creates a tensor cloning a numpy array, with the given precision (defaulting to input’s precision) and the given device (in case of GPUs)
- abstract zeros(shape, type_as=None)[source]¶
Creates a tensor full of zeros.
This function follows the api from
numpy.zerosSee: https://numpy.org/doc/stable/reference/generated/numpy.zeros.html
- abstract ones(shape, type_as=None)[source]¶
Creates a tensor full of ones.
This function follows the api from
numpy.onesSee: https://numpy.org/doc/stable/reference/generated/numpy.ones.html
- abstract full(shape, fill_value, type_as=None)[source]¶
Creates a tensor with given shape, filled with given value.
This function follows the api from
numpy.fullSee: https://numpy.org/doc/stable/reference/generated/numpy.full.html
- abstract eye(N, M=None, type_as=None)[source]¶
Creates the identity matrix of given size.
This function follows the api from
numpy.eyeSee: https://numpy.org/doc/stable/reference/generated/numpy.eye.html
- abstract sum(a, axis=None, keepdims=False)[source]¶
Sums tensor elements over given dimensions.
This function follows the api from
numpy.sumSee: https://numpy.org/doc/stable/reference/generated/numpy.sum.html
- abstract arange(stop, start=0, step=1, type_as=None)[source]¶
Returns evenly spaced values within a given interval.
This function follows the api from
numpy.arangeSee: https://numpy.org/doc/stable/reference/generated/numpy.arange.html
- abstract max(a, axis=None, keepdims=False)[source]¶
Returns the maximum of an array or maximum along given dimensions.
This function follows the api from
numpy.amaxSee: https://numpy.org/doc/stable/reference/generated/numpy.amax.html
- abstract min(a, axis=None, keepdims=False)[source]¶
Returns the maximum of an array or maximum along given dimensions.
This function follows the api from
numpy.aminSee: https://numpy.org/doc/stable/reference/generated/numpy.amin.html
- abstract maximum(a, b)[source]¶
Returns element-wise maximum of array elements.
This function follows the api from
numpy.maximumSee: https://numpy.org/doc/stable/reference/generated/numpy.maximum.html
- abstract minimum(a, b)[source]¶
Returns element-wise minimum of array elements.
This function follows the api from
numpy.minimumSee: https://numpy.org/doc/stable/reference/generated/numpy.minimum.html
- abstract dot(a, b)[source]¶
Returns the dot product of two tensors.
This function follows the api from
numpy.dotSee: https://numpy.org/doc/stable/reference/generated/numpy.dot.html
- abstract log(a)[source]¶
Computes the natural logarithm, element-wise.
This function follows the api from
numpy.logSee: https://numpy.org/doc/stable/reference/generated/numpy.log.html
- abstract sqrt(a)[source]¶
Returns the non-ngeative square root of a tensor, element-wise.
This function follows the api from
numpy.sqrtSee: https://numpy.org/doc/stable/reference/generated/numpy.sqrt.html
- abstract power(a, exponents)[source]¶
First tensor elements raised to powers from second tensor, element-wise.
This function follows the api from
numpy.powerSee: https://numpy.org/doc/stable/reference/generated/numpy.power.html
- abstract norm(a, axis=None, keepdims=False)[source]¶
Computes the matrix frobenius norm.
This function follows the api from
numpy.linalg.normSee: https://numpy.org/doc/stable/reference/generated/numpy.linalg.norm.html
- abstract any(a)[source]¶
Tests whether any tensor element along given dimensions evaluates to True.
This function follows the api from
numpy.anySee: https://numpy.org/doc/stable/reference/generated/numpy.any.html
- abstract isnan(a)[source]¶
Tests element-wise for NaN and returns result as a boolean tensor.
This function follows the api from
numpy.isnanSee: https://numpy.org/doc/stable/reference/generated/numpy.isnan.html
- abstract isinf(a)[source]¶
Tests element-wise for positive or negative infinity and returns result as a boolean tensor.
This function follows the api from
numpy.isinfSee: https://numpy.org/doc/stable/reference/generated/numpy.isinf.html
- abstract einsum(subscripts, *operands)[source]¶
Evaluates the Einstein summation convention on the operands.
This function follows the api from
numpy.einsumSee: https://numpy.org/doc/stable/reference/generated/numpy.einsum.html
- abstract sort(a, axis=-1)[source]¶
Returns a sorted copy of a tensor.
This function follows the api from
numpy.sortSee: https://numpy.org/doc/stable/reference/generated/numpy.sort.html
- abstract argsort(a, axis=None)[source]¶
Returns the indices that would sort a tensor.
This function follows the api from
numpy.argsortSee: https://numpy.org/doc/stable/reference/generated/numpy.argsort.html
- abstract searchsorted(a, v, side='left')[source]¶
Finds indices where elements should be inserted to maintain order in given tensor.
This function follows the api from
numpy.searchsortedSee: https://numpy.org/doc/stable/reference/generated/numpy.searchsorted.html
- abstract flip(a, axis=None)[source]¶
Reverses the order of elements in a tensor along given dimensions.
This function follows the api from
numpy.flipSee: https://numpy.org/doc/stable/reference/generated/numpy.flip.html
- abstract clip(a, a_min, a_max)[source]¶
Limits the values in a tensor.
This function follows the api from
numpy.clipSee: https://numpy.org/doc/stable/reference/generated/numpy.clip.html
- abstract repeat(a, repeats, axis=None)[source]¶
Repeats elements of a tensor.
This function follows the api from
numpy.repeatSee: https://numpy.org/doc/stable/reference/generated/numpy.repeat.html
- abstract take_along_axis(arr, indices, axis)[source]¶
Gathers elements of a tensor along given dimensions.
This function follows the api from
numpy.take_along_axisSee: https://numpy.org/doc/stable/reference/generated/numpy.take_along_axis.html
- abstract concatenate(arrays, axis=0)[source]¶
Joins a sequence of tensors along an existing dimension.
This function follows the api from
numpy.concatenateSee: https://numpy.org/doc/stable/reference/generated/numpy.concatenate.html
- abstract zero_pad(a, pad_width, value=0)[source]¶
Pads a tensor with a given value (0 by default).
This function follows the api from
numpy.padSee: https://numpy.org/doc/stable/reference/generated/numpy.pad.html
- abstract argmax(a, axis=None)[source]¶
Returns the indices of the maximum values of a tensor along given dimensions.
This function follows the api from
numpy.argmaxSee: https://numpy.org/doc/stable/reference/generated/numpy.argmax.html
- abstract argmin(a, axis=None)[source]¶
Returns the indices of the minimum values of a tensor along given dimensions.
This function follows the api from
numpy.argminSee: https://numpy.org/doc/stable/reference/generated/numpy.argmin.html
- abstract mean(a, axis=None)[source]¶
Computes the arithmetic mean of a tensor along given dimensions.
This function follows the api from
numpy.meanSee: https://numpy.org/doc/stable/reference/generated/numpy.mean.html
- abstract median(a, axis=None)[source]¶
Computes the median of a tensor along given dimensions.
This function follows the api from
numpy.medianSee: https://numpy.org/doc/stable/reference/generated/numpy.median.html
- abstract std(a, axis=None)[source]¶
Computes the standard deviation of a tensor along given dimensions.
This function follows the api from
numpy.stdSee: https://numpy.org/doc/stable/reference/generated/numpy.std.html
- abstract linspace(start, stop, num, type_as=None)[source]¶
Returns a specified number of evenly spaced values over a given interval.
This function follows the api from
numpy.linspaceSee: https://numpy.org/doc/stable/reference/generated/numpy.linspace.html
- abstract meshgrid(a, b)[source]¶
Returns coordinate matrices from coordinate vectors (Numpy convention).
This function follows the api from
numpy.meshgridSee: https://numpy.org/doc/stable/reference/generated/numpy.meshgrid.html
- abstract diag(a, k=0)[source]¶
Extracts or constructs a diagonal tensor.
This function follows the api from
numpy.diagSee: https://numpy.org/doc/stable/reference/generated/numpy.diag.html
- abstract unique(a, return_index=False, return_inverse=False)[source]¶
Finds unique elements of given tensor.
This function follows the api from
numpy.uniqueSee: https://numpy.org/doc/stable/reference/generated/numpy.unique.html
- abstract logsumexp(a, axis=None)[source]¶
Computes the log of the sum of exponentials of input elements.
This function follows the api from
scipy.special.logsumexpSee: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.logsumexp.html
- abstract stack(arrays, axis=0)[source]¶
Joins a sequence of tensors along a new dimension.
This function follows the api from
numpy.stackSee: https://numpy.org/doc/stable/reference/generated/numpy.stack.html
- abstract outer(a, b)[source]¶
Computes the outer product between two vectors.
This function follows the api from
numpy.outerSee: https://numpy.org/doc/stable/reference/generated/numpy.outer.html
- abstract reshape(a, shape)[source]¶
Gives a new shape to a tensor without changing its data.
This function follows the api from
numpy.reshapeSee: https://numpy.org/doc/stable/reference/generated/numpy.reshape.html
- abstract seed(seed=None)[source]¶
Sets the seed for the random generator.
This function follows the api from
numpy.random.seedSee: https://numpy.org/doc/stable/reference/random/generated/numpy.random.seed.html
- abstract rand(*size, type_as=None)[source]¶
Generate uniform random numbers.
This function follows the api from
numpy.random.randSee: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html
- abstract randn(*size, type_as=None)[source]¶
Generate normal Gaussian random numbers.
This function follows the api from
numpy.random.randSee: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html
- abstract coo_matrix(data, rows, cols, shape=None, type_as=None)[source]¶
Creates a sparse tensor in COOrdinate format.
This function follows the api from
scipy.sparse.coo_matrixSee: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.html
- abstract issparse(a)[source]¶
Checks whether or not the input tensor is a sparse tensor.
This function follows the api from
scipy.sparse.issparseSee: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.issparse.html
- abstract tocsr(a)[source]¶
Converts this matrix to Compressed Sparse Row format.
This function follows the api from
scipy.sparse.coo_matrix.tocsrSee: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.tocsr.html
- abstract eliminate_zeros(a, threshold=0.0)[source]¶
Removes entries smaller than the given threshold from the sparse tensor.
This function follows the api from
scipy.sparse.csr_matrix.eliminate_zeros
- abstract todense(a)[source]¶
Converts a sparse tensor to a dense tensor.
This function follows the api from
scipy.sparse.csr_matrix.toarraySee: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.toarray.html
- abstract where(condition, x, y)[source]¶
Returns elements chosen from x or y depending on condition.
This function follows the api from
numpy.whereSee: https://numpy.org/doc/stable/reference/generated/numpy.where.html
- abstract copy(a)[source]¶
Returns a copy of the given tensor.
This function follows the api from
numpy.copySee: https://numpy.org/doc/stable/reference/generated/numpy.copy.html
- abstract allclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False)[source]¶
Returns True if two arrays are element-wise equal within a tolerance.
This function follows the api from
numpy.allcloseSee: https://numpy.org/doc/stable/reference/generated/numpy.allclose.html
- abstract assert_same_dtype_device(a, b)[source]¶
Checks whether or not the two given inputs have the same dtype as well as the same device
- abstract squeeze(a, axis=None)[source]¶
Remove axes of length one from a.
This function follows the api from
numpy.squeeze.See: https://numpy.org/doc/stable/reference/generated/numpy.squeeze.html
- abstract bitsize(type_as)[source]¶
Gives the number of bits used by the data type of the given tensor.
- abstract device_type(type_as)[source]¶
Returns CPU or GPU depending on the device where the given tensor is located.
- abstract _bench(callable, *args, n_runs=1, warmup_runs=1)[source]¶
Executes a benchmark of the given callable with the given arguments.
- abstract solve(a, b)[source]¶
Solves a linear matrix equation, or system of linear scalar equations.
This function follows the api from
numpy.linalg.solve.See: https://numpy.org/doc/stable/reference/generated/numpy.linalg.solve.html
- abstract trace(a)[source]¶
Returns the sum along diagonals of the array.
This function follows the api from
numpy.trace.See: https://numpy.org/doc/stable/reference/generated/numpy.trace.html
- abstract inv(a)[source]¶
Computes the inverse of a matrix.
This function follows the api from
scipy.linalg.inv.See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.inv.html
- abstract sqrtm(a)[source]¶
Computes the matrix square root. Requires input to be definite positive.
This function follows the api from
scipy.linalg.sqrtm.See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.sqrtm.html
- abstract eigh(a)[source]¶
Computes the eigenvalues and eigenvectors of a symmetric tensor.
This function follows the api from
scipy.linalg.eigh.See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigh.html
- abstract kl_div(p, q, mass=False, eps=1e-16)[source]¶
Computes the (Generalized) Kullback-Leibler divergence.
This function follows the api from
scipy.stats.entropy.Parameter eps is used to avoid numerical errors and is added in the log.
\[KL(p,q) = \langle \mathbf{p}, log(\mathbf{p} / \mathbf{q} + eps \rangle + \mathbb{1}_{mass=True} \langle \mathbf{q} - \mathbf{p}, \mathbf{1} \rangle\]See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.entropy.html
- abstract isfinite(a)[source]¶
Tests element-wise for finiteness (not infinity and not Not a Number).
This function follows the api from
numpy.isfinite.See: https://numpy.org/doc/stable/reference/generated/numpy.isfinite.html
- abstract array_equal(a, b)[source]¶
True if two arrays have the same shape and elements, False otherwise.
This function follows the api from
numpy.array_equal.See: https://numpy.org/doc/stable/reference/generated/numpy.array_equal.html
- abstract tile(a, reps)[source]¶
Construct an array by repeating a the number of times given by reps
See: https://numpy.org/doc/stable/reference/generated/numpy.tile.html
- abstract floor(a)[source]¶
Return the floor of the input element-wise
See: https://numpy.org/doc/stable/reference/generated/numpy.floor.html
- abstract prod(a, axis=None)[source]¶
Return the product of all elements.
See: https://numpy.org/doc/stable/reference/generated/numpy.prod.html
- abstract sort2(a, axis=None)[source]¶
Return the sorted array and the indices to sort the array
See: https://pytorch.org/docs/stable/generated/torch.sort.html
- abstract qr(a)[source]¶
Return the QR factorization
See: https://numpy.org/doc/stable/reference/generated/numpy.linalg.qr.html
- abstract atan2(a, b)[source]¶
Element wise arctangent
See: https://numpy.org/doc/stable/reference/generated/numpy.arctan2.html
- abstract transpose(a, axes=None)[source]¶
Returns a tensor that is a transposed version of a. The given dimensions dim0 and dim1 are swapped.
See: https://numpy.org/doc/stable/reference/generated/numpy.transpose.html
- abstract matmul(a, b)[source]¶
Matrix product of two arrays.
See: https://numpy.org/doc/stable/reference/generated/numpy.matmul.html#numpy.matmul
- abstract nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None)[source]¶
Replace NaN with zero and infinity with large finite numbers or with the numbers defined by the user.
See: https://numpy.org/doc/stable/reference/generated/numpy.nan_to_num.html#numpy.nan_to_num
- abstract randperm(length)[source]¶
Returns a random permutation of integers from 0 to length - 1.
See: https://numpy.org/doc/stable/reference/random/generated/numpy.random.permutation.html
- abstract choice(a, size, replace=False)[source]¶
Generates a random sample from a given 1-D array.
See: https://numpy.org/doc/stable/reference/random/generated/numpy.random.choice.html
- abstract topk(a, topk, axis=-1)[source]¶
Returns the indices of the topk elements along a given axis.
See: https://numpy.org/doc/stable/reference/generated/numpy.argpartition.html
- abstract dstack(a)[source]¶
Stack arrays in sequence along the third axis.
See: https://numpy.org/doc/stable/reference/generated/numpy.dstack.html
- abstract vstack(a)[source]¶
Stack arrays in sequence vertically (row wise).
See: https://numpy.org/doc/stable/reference/generated/numpy.vstack.html
- abstract hstack(a)[source]¶
Stack arrays in sequence horizontally (column wise).
See: https://numpy.org/doc/stable/reference/generated/numpy.hstack.html
- abstract chunk(a, chunk_num, axis=0)[source]¶
Split the tensor into a list of sub-tensors.
See: https://numpy.org/doc/stable/reference/generated/numpy.array_split.html
- abstract roll(a, shift, axis=None)[source]¶
Roll array elements along a given axis.
See: https://numpy.org/doc/stable/reference/generated/numpy.roll.html
- class spateo.alignment.methods.backend.NumpyBackend[source]¶
Bases:
BackendNumPy implementation of the backend.
__name__ is “numpy”
__type__ is np.ndarray
- _from_numpy(a, type_as=None)[source]¶
Creates a tensor cloning a numpy array, with the given precision (defaulting to input’s precision) and the given device (in case of GPUs)
- zeros(shape, type_as=None)[source]¶
Creates a tensor full of zeros.
This function follows the api from
numpy.zerosSee: https://numpy.org/doc/stable/reference/generated/numpy.zeros.html
- einsum(subscripts, *operands)[source]¶
Evaluates the Einstein summation convention on the operands.
This function follows the api from
numpy.einsumSee: https://numpy.org/doc/stable/reference/generated/numpy.einsum.html
- mean(a, axis=None)[source]¶
Computes the arithmetic mean of a tensor along given dimensions.
This function follows the api from
numpy.meanSee: https://numpy.org/doc/stable/reference/generated/numpy.mean.html
- full(shape, fill_value, type_as=None)[source]¶
Creates a tensor with given shape, filled with given value.
This function follows the api from
numpy.fullSee: https://numpy.org/doc/stable/reference/generated/numpy.full.html
- sqrt(a)[source]¶
Returns the non-ngeative square root of a tensor, element-wise.
This function follows the api from
numpy.sqrtSee: https://numpy.org/doc/stable/reference/generated/numpy.sqrt.html
- ones(shape, type_as=None)[source]¶
Creates a tensor full of ones.
This function follows the api from
numpy.onesSee: https://numpy.org/doc/stable/reference/generated/numpy.ones.html
- maximum(a, b)[source]¶
Returns element-wise maximum of array elements.
This function follows the api from
numpy.maximumSee: https://numpy.org/doc/stable/reference/generated/numpy.maximum.html
- minimum(a, b)[source]¶
Returns element-wise minimum of array elements.
This function follows the api from
numpy.minimumSee: https://numpy.org/doc/stable/reference/generated/numpy.minimum.html
- max(a, axis=None, keepdims=False)[source]¶
Returns the maximum of an array or maximum along given dimensions.
This function follows the api from
numpy.amaxSee: https://numpy.org/doc/stable/reference/generated/numpy.amax.html
- min(a, axis=None, keepdims=False)[source]¶
Returns the maximum of an array or maximum along given dimensions.
This function follows the api from
numpy.aminSee: https://numpy.org/doc/stable/reference/generated/numpy.amin.html
- eye(N, M=None, type_as=None)[source]¶
Creates the identity matrix of given size.
This function follows the api from
numpy.eyeSee: https://numpy.org/doc/stable/reference/generated/numpy.eye.html
- argsort(a, axis=-1)[source]¶
Returns the indices that would sort a tensor.
This function follows the api from
numpy.argsortSee: https://numpy.org/doc/stable/reference/generated/numpy.argsort.html
- log(a)[source]¶
Computes the natural logarithm, element-wise.
This function follows the api from
numpy.logSee: https://numpy.org/doc/stable/reference/generated/numpy.log.html
- concatenate(arrays, axis=0)[source]¶
Joins a sequence of tensors along an existing dimension.
This function follows the api from
numpy.concatenateSee: https://numpy.org/doc/stable/reference/generated/numpy.concatenate.html
- sum(a, axis=None, keepdims=False)[source]¶
Sums tensor elements over given dimensions.
This function follows the api from
numpy.sumSee: https://numpy.org/doc/stable/reference/generated/numpy.sum.html
- arange(stop, start=0, step=1, type_as=None)[source]¶
Returns evenly spaced values within a given interval.
This function follows the api from
numpy.arangeSee: https://numpy.org/doc/stable/reference/generated/numpy.arange.html
- unique(a, return_index, return_inverse=False, axis=None)[source]¶
Finds unique elements of given tensor.
This function follows the api from
numpy.uniqueSee: https://numpy.org/doc/stable/reference/generated/numpy.unique.html
- power(a, exponents)[source]¶
First tensor elements raised to powers from second tensor, element-wise.
This function follows the api from
numpy.powerSee: https://numpy.org/doc/stable/reference/generated/numpy.power.html
- dot(a, b)[source]¶
Returns the dot product of two tensors.
This function follows the api from
numpy.dotSee: https://numpy.org/doc/stable/reference/generated/numpy.dot.html
- prod(a, axis=0)[source]¶
Return the product of all elements.
See: https://numpy.org/doc/stable/reference/generated/numpy.prod.html
- chunk(a, chunk_num, axis=0)[source]¶
Split the tensor into a list of sub-tensors.
See: https://numpy.org/doc/stable/reference/generated/numpy.array_split.html
- randperm(length)[source]¶
Returns a random permutation of integers from 0 to length - 1.
See: https://numpy.org/doc/stable/reference/random/generated/numpy.random.permutation.html
- roll(a, shift, axis=None)[source]¶
Roll array elements along a given axis.
See: https://numpy.org/doc/stable/reference/generated/numpy.roll.html
- choice(a, size, replace=False)[source]¶
Generates a random sample from a given 1-D array.
See: https://numpy.org/doc/stable/reference/random/generated/numpy.random.choice.html
- topk(a, topk, axis=-1)[source]¶
Returns the indices of the topk elements along a given axis.
See: https://numpy.org/doc/stable/reference/generated/numpy.argpartition.html
- dstack(a)[source]¶
Stack arrays in sequence along the third axis.
See: https://numpy.org/doc/stable/reference/generated/numpy.dstack.html
- vstack(a)[source]¶
Stack arrays in sequence vertically (row wise).
See: https://numpy.org/doc/stable/reference/generated/numpy.vstack.html
- hstack(a)[source]¶
Stack arrays in sequence horizontally (column wise).
See: https://numpy.org/doc/stable/reference/generated/numpy.hstack.html
- stack(arrays, axis=0)[source]¶
Joins a sequence of tensors along a new dimension.
This function follows the api from
numpy.stackSee: https://numpy.org/doc/stable/reference/generated/numpy.stack.html
- where(condition, x=None, y=None)[source]¶
Returns elements chosen from x or y depending on condition.
This function follows the api from
numpy.whereSee: https://numpy.org/doc/stable/reference/generated/numpy.where.html
- copy(a)[source]¶
Returns a copy of the given tensor.
This function follows the api from
numpy.copySee: https://numpy.org/doc/stable/reference/generated/numpy.copy.html
- repeat(a, repeats, axis=None)[source]¶
Repeats elements of a tensor.
This function follows the api from
numpy.repeatSee: https://numpy.org/doc/stable/reference/generated/numpy.repeat.html
- sort2(a, axis=-1, descending=False)[source]¶
Return the sorted array and the indices to sort the array
See: https://pytorch.org/docs/stable/generated/torch.sort.html
- coo_matrix(data, rows, cols, shape=None, type_as=None)[source]¶
Creates a sparse tensor in COOrdinate format.
This function follows the api from
scipy.sparse.coo_matrixSee: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.html
- issparse(a)[source]¶
Checks whether or not the input tensor is a sparse tensor.
This function follows the api from
scipy.sparse.issparseSee: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.issparse.html
- eliminate_zeros(a, threshold=0.0)[source]¶
Removes entries smaller than the given threshold from the sparse tensor.
This function follows the api from
scipy.sparse.csr_matrix.eliminate_zeros
- todense(a)[source]¶
Converts a sparse tensor to a dense tensor.
This function follows the api from
scipy.sparse.csr_matrix.toarraySee: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.toarray.html
- class spateo.alignment.methods.backend.TorchBackend[source]¶
Bases:
BackendPyTorch implementation of the backend
__name__ is “torch”
__type__ is torch.Tensor
- _from_numpy(a, type_as=None)[source]¶
Creates a tensor cloning a numpy array, with the given precision (defaulting to input’s precision) and the given device (in case of GPUs)
- zeros(shape, type_as=None)[source]¶
Creates a tensor full of zeros.
This function follows the api from
numpy.zerosSee: https://numpy.org/doc/stable/reference/generated/numpy.zeros.html
- einsum(subscripts, *operands)[source]¶
Evaluates the Einstein summation convention on the operands.
This function follows the api from
numpy.einsumSee: https://numpy.org/doc/stable/reference/generated/numpy.einsum.html
- mean(a, axis=None)[source]¶
Computes the arithmetic mean of a tensor along given dimensions.
This function follows the api from
numpy.meanSee: https://numpy.org/doc/stable/reference/generated/numpy.mean.html
- full(shape, fill_value, type_as=None)[source]¶
Creates a tensor with given shape, filled with given value.
This function follows the api from
numpy.fullSee: https://numpy.org/doc/stable/reference/generated/numpy.full.html
- sqrt(a)[source]¶
Returns the non-ngeative square root of a tensor, element-wise.
This function follows the api from
numpy.sqrtSee: https://numpy.org/doc/stable/reference/generated/numpy.sqrt.html
- ones(shape, type_as=None)[source]¶
Creates a tensor full of ones.
This function follows the api from
numpy.onesSee: https://numpy.org/doc/stable/reference/generated/numpy.ones.html
- arange(stop, start=0, step=1, type_as=None)[source]¶
Returns evenly spaced values within a given interval.
This function follows the api from
numpy.arangeSee: https://numpy.org/doc/stable/reference/generated/numpy.arange.html
- maximum(a, b)[source]¶
Returns element-wise maximum of array elements.
This function follows the api from
numpy.maximumSee: https://numpy.org/doc/stable/reference/generated/numpy.maximum.html
- minimum(a, b)[source]¶
Returns element-wise minimum of array elements.
This function follows the api from
numpy.minimumSee: https://numpy.org/doc/stable/reference/generated/numpy.minimum.html
- max(a, axis=None, keepdims=False)[source]¶
Returns the maximum of an array or maximum along given dimensions.
This function follows the api from
numpy.amaxSee: https://numpy.org/doc/stable/reference/generated/numpy.amax.html
- min(a, axis=None, keepdims=False)[source]¶
Returns the maximum of an array or maximum along given dimensions.
This function follows the api from
numpy.aminSee: https://numpy.org/doc/stable/reference/generated/numpy.amin.html
- eye(N, M=None, type_as=None)[source]¶
Creates the identity matrix of given size.
This function follows the api from
numpy.eyeSee: https://numpy.org/doc/stable/reference/generated/numpy.eye.html
- argsort(a, axis=-1)[source]¶
Returns the indices that would sort a tensor.
This function follows the api from
numpy.argsortSee: https://numpy.org/doc/stable/reference/generated/numpy.argsort.html
- log(a)[source]¶
Computes the natural logarithm, element-wise.
This function follows the api from
numpy.logSee: https://numpy.org/doc/stable/reference/generated/numpy.log.html
- concatenate(arrays, axis=0)[source]¶
Joins a sequence of tensors along an existing dimension.
This function follows the api from
numpy.concatenateSee: https://numpy.org/doc/stable/reference/generated/numpy.concatenate.html
- sum(a, axis=None, keepdims=False)[source]¶
Sums tensor elements over given dimensions.
This function follows the api from
numpy.sumSee: https://numpy.org/doc/stable/reference/generated/numpy.sum.html
- unique(a, return_index=False, return_inverse=False, axis=None)[source]¶
Finds unique elements of given tensor.
This function follows the api from
numpy.uniqueSee: https://numpy.org/doc/stable/reference/generated/numpy.unique.html
- power(a, exponents)[source]¶
First tensor elements raised to powers from second tensor, element-wise.
This function follows the api from
numpy.powerSee: https://numpy.org/doc/stable/reference/generated/numpy.power.html
- dot(a, b)[source]¶
Returns the dot product of two tensors.
This function follows the api from
numpy.dotSee: https://numpy.org/doc/stable/reference/generated/numpy.dot.html
- prod(a, axis=0)[source]¶
Return the product of all elements.
See: https://numpy.org/doc/stable/reference/generated/numpy.prod.html
- chunk(a, chunk_num, axis=0)[source]¶
Split the tensor into a list of sub-tensors.
See: https://numpy.org/doc/stable/reference/generated/numpy.array_split.html
- randperm(length)[source]¶
Returns a random permutation of integers from 0 to length - 1.
See: https://numpy.org/doc/stable/reference/random/generated/numpy.random.permutation.html
- roll(a, shift, axis=None)[source]¶
Roll array elements along a given axis.
See: https://numpy.org/doc/stable/reference/generated/numpy.roll.html
- choice(a, size, replace=False)[source]¶
Generates a random sample from a given 1-D array.
See: https://numpy.org/doc/stable/reference/random/generated/numpy.random.choice.html
- topk(a, topk, axis=-1)[source]¶
Returns the indices of the topk elements along a given axis.
See: https://numpy.org/doc/stable/reference/generated/numpy.argpartition.html
- dstack(a)[source]¶
Stack arrays in sequence along the third axis.
See: https://numpy.org/doc/stable/reference/generated/numpy.dstack.html
- vstack(a)[source]¶
Stack arrays in sequence vertically (row wise).
See: https://numpy.org/doc/stable/reference/generated/numpy.vstack.html
- hstack(a)[source]¶
Stack arrays in sequence horizontally (column wise).
See: https://numpy.org/doc/stable/reference/generated/numpy.hstack.html
- stack(arrays, axis=0)[source]¶
Joins a sequence of tensors along a new dimension.
This function follows the api from
numpy.stackSee: https://numpy.org/doc/stable/reference/generated/numpy.stack.html
- where(condition, x=None, y=None)[source]¶
Returns elements chosen from x or y depending on condition.
This function follows the api from
numpy.whereSee: https://numpy.org/doc/stable/reference/generated/numpy.where.html
- copy(a)[source]¶
Returns a copy of the given tensor.
This function follows the api from
numpy.copySee: https://numpy.org/doc/stable/reference/generated/numpy.copy.html
- repeat(a, repeats, axis=None)[source]¶
Repeats elements of a tensor.
This function follows the api from
numpy.repeatSee: https://numpy.org/doc/stable/reference/generated/numpy.repeat.html
- sort2(a, axis=-1, descending=False)[source]¶
Return the sorted array and the indices to sort the array
See: https://pytorch.org/docs/stable/generated/torch.sort.html
- coo_matrix(data, rows, cols, shape=None, type_as=None)[source]¶
Creates a sparse tensor in COOrdinate format.
This function follows the api from
scipy.sparse.coo_matrixSee: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.html
- issparse(a)[source]¶
Checks whether or not the input tensor is a sparse tensor.
This function follows the api from
scipy.sparse.issparseSee: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.issparse.html
- eliminate_zeros(a, threshold=0.0)[source]¶
Removes entries smaller than the given threshold from the sparse tensor.
This function follows the api from
scipy.sparse.csr_matrix.eliminate_zeros
- todense(a)[source]¶
Converts a sparse tensor to a dense tensor.
This function follows the api from
scipy.sparse.csr_matrix.toarraySee: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.toarray.html