ot.backend

POT的多库后端

目标是编写与后端无关的代码。无论您使用的是 Numpy、PyTorch、Jax、Cupy 还是 Tensorflow,POT 代码都应该能够正常工作。 要实现这一点,POT 提供了后端类,这些类实现了各自后端的函数,模仿 Numpy API。作为约定,我们使用 nx 而不是 np 来引用后端。

示例

>>> from ot.utils import list_to_array
>>> from ot.backend import get_backend
>>> def f(a, b):  # the function does not know which backend to use
...     a, b = list_to_array(a, b)  # if a list in given, make it an array
...     nx = get_backend(a, b)  # infer the backend from the arguments
...     c = nx.dot(a, b)  # now use the backend to do any calculation
...     return c

警告

Tensorflow 只能与 Numpy API 一起使用。要激活它,请运行以下命令:

from tensorflow.python.ops.numpy_ops import np_config
np_config.enable_numpy_behavior()

性能

  • 中央处理器: Intel(R) Xeon(R) Gold 6248中央处理器 @ 2.50GHz

  • GPU: 特斯拉 V100-SXM2-32GB

  • 基准日期:2021年12月8日

  • 基准测试的提交: PR #316, https://github.com/PythonOT/POT/pull/316

Sinkhorn Knopp - 在100次运行上取平均
位数32 位
设备中央处理器图形处理器
样本大小NumpyPytorchTensorflowCupyJaxPytorchTensorflow
500.00080.00220.01510.00950.01930.00510.0293
1000.00050.00130.00970.00570.01150.00290.0173
5000.00090.00160.01100.00580.01150.00290.0166
10000.00210.00210.01450.00560.01180.00290.0168
20000.00690.00430.02780.00590.01180.00300.0165
50000.07070.03140.13950.00740.01250.00350.0198
 
位大小64 位
设备中央处理器图形处理器
样本大小NumpyPytorchTensorflowCupyJaxPytorchTensorflow
500.00080.00200.01540.00930.01910.00510.0328
1000.00050.00130.00940.00560.01140.00290.0169
5000.00130.00170.01200.00590.01160.00290.0168
10000.00340.00270.01770.00580.01180.00290.0167
20000.01460.00750.04360.00590.01200.00290.0165
50000.14670.05680.24680.00770.01460.00450.0204

函数

ot.backend.get_available_backend_implementations()[源]

返回可用的后端实现列表。

ot.backend.get_backend(*args)[源]

返回一个输入数组列表的正确后端

接受参数中的None条目,并忽略它们

如果所有数组不来自相同的后端,也会引发TypeError

ot.backend.get_backend_list()[源]

返回所有可用后端的实例。

请注意,此函数强制所有检测到的实现被实例化,即使之前未使用特定的后端。请小心,因为后端的实例化可能导致副作用,例如 GPU 内存的预分配。有关更多详细信息,请参阅文档。如果您只需要知道哪些实现是可用的,请使用 :py:func:`ot.backend.get_available_backend_implementations,该函数不会强制创建后端对象的实例。

ot.backend.to_numpy(*args)[源]

从任何兼容的后端返回numpy数组

class ot.backend.Backend[源]

后端抽象类。 实现: JaxBackend, NumpyBackend, TorchBackend, CupyBackend, TensorflowBackend

  • __name__类属性指的是后端的名称。

  • 变量 __type__ 类属性指的是后端使用的数据结构。

abs(a)[源]

逐元素计算绝对值。

此函数遵循来自 numpy.absolute 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.absolute.html

allclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False)[源]

如果两个数组在容差范围内逐元素相等,则返回 True。

此函数遵循来自 numpy.allclose 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.allclose.html

any(a)[源]

测试沿给定维度的任何张量元素是否评估为真。

此函数遵循来自 numpy.any 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.any.html

arange(stop, start=0, step=1, type_as=None)[源]

返回特定区间内均匀间隔的值。

此函数遵循来自 numpy.arange 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.arange.html

argmax(a, axis=None)[源]

返回张量在给定维度上的最大值的索引。

这个函数遵循来自 numpy.argmax 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.argmax.html

argmin(a, axis=None)[源]

返回张量在给定维度上的最小值的索引。

此函数遵循来自 numpy.argmin 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.argmin.html

argsort(a, axis=None)[源]

返回将张量排序的索引。

此函数遵循来自 numpy.argsort 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.argsort.html

array_equal(a, b)[源]

如果两个数组具有相同的形状和元素,则返回True,否则返回False。

此函数遵循numpy.array_equal的API。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.array_equal.html

assert_same_dtype_device(a, b)[源]

检查两个给定输入是否具有相同的数据类型以及相同的设备

atan2(a, b)[源]

逐元素反正切

见: https://numpy.org/doc/stable/reference/generated/numpy.arctan2.html

bitsize(type_as)[源]

给定张量的数据类型所使用的比特数。

clip(a, a_min, a_max)[源]

限制张量中的值。

此函数遵循numpy.clip的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.clip.html

concatenate(arrays, axis=0)[源]

沿着现有维度连接一系列张量。

此函数遵循来自 numpy.concatenate 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.concatenate.html

coo_matrix(data, rows, cols, shape=None, type_as=None)[源]

创建一个稀疏张量,采用坐标格式。

此函数遵循来自 scipy.sparse.coo_matrix 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.html

copy(a)[源]

返回给定张量的副本。

这个函数遵循来自 numpy.copy 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.copy.html

cumsum(a, axis=None)[源]

返回给定维度上张量元素的累计和。

这个函数遵循来自 numpy.cumsum 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.cumsum.html

det(a)[源]

计算数组的行列式。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.det.html

detach(*arrays)[源]

将张量从计算图中分离

查看: https://pytorch.org/docs/stable/generated/torch.Tensor.detach.html

device_type(type_as)[源]

根据给定张量所在设备返回CPU或GPU。

diag(a, k=0)[源]

提取或构造对角张量。

该函数遵循来自 numpy.diag 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.diag.html

dot(a, b)[源]

返回两个张量的点积。

此函数遵循来自 numpy.dot 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.dot.html

dtype_device(a)[源]

返回给定张量的 dtype 和设备。

eigh(a)[源]

计算对称张量的特征值和特征向量。

此函数遵循来自 scipy.linalg.eigh 的 API。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigh.html

einsum(subscripts, *operands)[源]

对操作数评估爱因斯坦求和约定。

该函数遵循来自 numpy.einsum 的API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.einsum.html

eliminate_zeros(a, threshold=0.0)[源]

从稀疏张量中移除小于给定阈值的条目。

此函数遵循来自 scipy.sparse.csr_matrix.eliminate_zeros 的 API

查看: https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.sparse.csr_matrix.eliminate_zeros.html

exp(a)[源]

逐元素计算指数值。

此函数遵循来自 numpy.exp 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.exp.html

eye(N, M=None, type_as=None)[源]

创建给定大小的单位矩阵。

该函数遵循来自 numpy.eye 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.eye.html

flip(a, axis=None)[源]

沿给定维度反转张量中元素的顺序。

此函数遵循来自 numpy.flip 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.flip.html

floor(a)[源]

返回输入的元素的下限

见: https://numpy.org/doc/stable/reference/generated/numpy.floor.html

from_numpy(*arrays, type_as=None)[源]

创建张量,克隆一个numpy数组,具有给定的精度(默认为输入的精度)和给定的设备(在使用GPU的情况下)

full(shape, fill_value, type_as=None)[源]

创建一个具有给定形状的张量,并用给定值填充。

该函数遵循来自 numpy.full 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.full.html

inv(a)[源]

计算矩阵的逆。

此函数遵循来自 scipy.linalg.inv 的 API。

请查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.inv.html

is_floating_point(a)[源]

返回输入是否由浮点数组成

isfinite(a)[源]

逐元素测试有限性(非无限和非数字)。

该函数遵循来自 numpy.isfinite 的API。

查看: https://numpy.org/doc/stable/reference/generated/numpy.isfinite.html

isinf(a)[源]

逐元素测试正无穷大或负无穷大,并返回布尔张量作为结果。

此函数遵循来自 numpy.isinf 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.isinf.html

isnan(a)[源]

逐元素测试是否为NaN,并将结果返回为布尔张量。

这个函数遵循来自 numpy.isnan 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.isnan.html

issparse(a)[源]

检查输入张量是否为稀疏张量。

此函数遵循来自 scipy.sparse.issparse 的API

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.issparse.html

kl_div(p, q, mass=False, eps=1e-16)[源]

计算(广义)Kullback-Leibler散度。

此函数遵循来自 scipy.stats.entropy 的 API。

参数 eps 用于避免数值错误,并添加在日志中。

\[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\]

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.entropy.html

linspace(start, stop, num, type_as=None)[源]

在给定区间内返回指定数量的均匀间隔的值。

此函数遵循来自 numpy.linspace 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.linspace.html

log(a)[源]

逐元素计算自然对数。

该函数遵循来自 numpy.log 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.log.html

logsumexp(a, axis=None)[源]

计算输入元素指数和的对数。

此函数遵循来自 scipy.special.logsumexp 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.logsumexp.html

matmul(a, b)[源]

两个数组的矩阵乘积。

见: https://numpy.org/doc/stable/reference/generated/numpy.matmul.html#numpy.matmul

max(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

此函数遵循来自 numpy.amax 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.amax.html

maximum(a, b)[源]

返回数组元素的逐元素最大值。

此函数遵循来自 numpy.maximum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.maximum.html

mean(a, axis=None)[源]

计算张量沿给定维度的算术平均值。

此函数遵循来自 numpy.mean 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.mean.html

median(a, axis=None)[源]

计算张量在给定维度上的中位数。

此函数遵循来自 numpy.median 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.median.html

meshgrid(a, b)[源]

从坐标向量返回坐标矩阵(Numpy 约定)。

该函数遵循numpy.meshgrid的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.meshgrid.html

min(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

这个函数遵循来自 numpy.amin 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.amin.html

minimum(a, b)[源]

返回数组元素的逐元素最小值。

该函数遵循来自 numpy.minimum 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.minimum.html

nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None)[源]

将NaN替换为零,将无穷大替换为大型有限数字或用户定义的数字。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.nan_to_num.html#numpy.nan_to_num

norm(a, axis=None, keepdims=False)[源]

计算矩阵的弗罗贝尼乌斯范数。

此函数遵循来自 numpy.linalg.norm 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.norm.html

ones(shape, type_as=None)[源]

创建一个全为一的张量。

此函数遵循来自 numpy.ones 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.ones.html

outer(a, b)[源]

计算两个向量之间的外积。

此函数遵循来自 numpy.outer 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.outer.html

power(a, exponents)[源]

第一个张量的元素逐个提升到第二个张量的幂。

该函数遵循来自 numpy.power 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.power.html

prod(a, axis=None)[源]

返回所有元素的乘积。

查看: https://numpy.org/doc/stable/reference/generated/numpy.prod.html

qr(a)[源]

返回QR分解

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.qr.html

rand(*size, type_as=None)[源]

生成均匀随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

randn(*size, type_as=None)[源]

生成正态高斯随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

repeat(a, repeats, axis=None)[源]

重复张量的元素。

此函数遵循来自 numpy.repeat 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.repeat.html

reshape(a, shape)[源]

不改变数据的情况下,给张量赋予新的形状。

该函数遵循来自 numpy.reshape 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.reshape.html

searchsorted(a, v, side='left')[源]

找到应该插入元素以保持给定张量中的顺序的索引。

此函数遵循来自 numpy.searchsorted 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.searchsorted.html

seed(seed=None)[源]

设置随机生成器的种子。

这个函数遵循来自 numpy.random.seed 的 API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.seed.html

set_gradients(val, inputs, grads)[源]

定义相对于输入的值 val 的梯度

sign(a)[源]

返回一个元素逐个指示一个数字的符号。

此函数遵循来自 numpy.sign 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.sign.html

solve(a, b)[源]

求解线性矩阵方程或线性标量方程组。

此函数遵循来自 numpy.linalg.solve 的 API。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.solve.html

sort(a, axis=-1)[源]

返回一个排序后的张量副本。

此函数遵循来自 numpy.sort 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.sort.html

sort2(a, axis=None)[源]

返回排序后的数组和排序数组的索引

查看: https://pytorch.org/docs/stable/generated/torch.sort.html

sqrt(a)[源]

返回张量的非负平方根,逐元素进行。

此函数遵循来自 numpy.sqrt 的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.sqrt.html

sqrtm(a)[源]

计算矩阵的平方根。 需要输入对称的半正定。

这个函数遵循scipy.linalg.sqrtm的API,允许批处理。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.sqrtm.html

squeeze(a, axis=None)[源]

从a中移除长度为一的轴。

此函数遵循来自 numpy.squeeze 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.squeeze.html

stack(arrays, axis=0)[源]

在新的维度上连接一系列张量。

此函数遵循来自 numpy.stack 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.stack.html

std(a, axis=None)[源]

计算给定维度上张量的标准差。

此函数遵循来自 numpy.std 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.std.html

sum(a, axis=None, keepdims=False)[源]

对给定维度的张量元素求和。

该函数遵循来自 numpy.sum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.sum.html

take_along_axis(arr, indices, axis)[源]

沿给定维度收集张量的元素。

此函数遵循来自 numpy.take_along_axis 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.take_along_axis.html

tile(a, reps)[源]

通过重复给定次数的数字构建数组

见: https://numpy.org/doc/stable/reference/generated/numpy.tile.html

to_numpy(*arrays)[源]

返回张量的numpy版本

tocsr(a)[源]

将此矩阵转换为压缩稀疏行格式。

此函数遵循来自 scipy.sparse.coo_matrix.tocsr 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.tocsr.html

todense(a)[源]

将稀疏张量转换为密集张量。

此函数遵循来自 scipy.sparse.csr_matrix.toarray 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.toarray.html

trace(a)[源]

返回数组沿对角线的和。

这个函数遵循来自 numpy.trace 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.trace.html

transpose(a, axes=None)[源]

返回一个张量,该张量是a的转置版本。给定的维度dim0和dim1被交换。

见: https://numpy.org/doc/stable/reference/generated/numpy.transpose.html

unique(a, return_inverse=False)[源]

查找给定张量的唯一元素。

此函数遵循来自 numpy.unique 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.unique.html

where(condition, x, y)[源]

根据条件从 x 或 y 中返回选定的元素。

此函数遵循来自 numpy.where 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.where.html

zero_pad(a, pad_width, value=0)[源]

用给定的值(默认是0)填充一个张量。

此函数遵循来自 numpy.pad 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.pad.html

zeros(shape, type_as=None)[源]

创建一个满是零的张量。

该函数遵循来自 numpy.zeros 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.zeros.html

class ot.backend.CupyBackend[源]

CuPy 后端的实现

  • __name__ 是 “cupy”

  • __type__ 是 cp.ndarray

abs(a)[源]

逐元素计算绝对值。

此函数遵循来自 numpy.absolute 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.absolute.html

allclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False)[源]

如果两个数组在容差范围内逐元素相等,则返回 True。

此函数遵循来自 numpy.allclose 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.allclose.html

any(a)[源]

测试沿给定维度的任何张量元素是否评估为真。

此函数遵循来自 numpy.any 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.any.html

arange(stop, start=0, step=1, type_as=None)[源]

返回特定区间内均匀间隔的值。

此函数遵循来自 numpy.arange 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.arange.html

argmax(a, axis=None)[源]

返回张量在给定维度上的最大值的索引。

这个函数遵循来自 numpy.argmax 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.argmax.html

argmin(a, axis=None)[源]

返回张量在给定维度上的最小值的索引。

此函数遵循来自 numpy.argmin 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.argmin.html

argsort(a, axis=-1)[源]

返回将张量排序的索引。

此函数遵循来自 numpy.argsort 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.argsort.html

array_equal(a, b)[源]

如果两个数组具有相同的形状和元素,则返回True,否则返回False。

此函数遵循numpy.array_equal的API。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.array_equal.html

assert_same_dtype_device(a, b)[源]

检查两个给定输入是否具有相同的数据类型以及相同的设备

atan2(a, b)[源]

逐元素反正切

见: https://numpy.org/doc/stable/reference/generated/numpy.arctan2.html

bitsize(type_as)[源]

给定张量的数据类型所使用的比特数。

clip(a, a_min, a_max)[源]

限制张量中的值。

此函数遵循numpy.clip的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.clip.html

concatenate(arrays, axis=0)[源]

沿着现有维度连接一系列张量。

此函数遵循来自 numpy.concatenate 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.concatenate.html

coo_matrix(data, rows, cols, shape=None, type_as=None)[源]

创建一个稀疏张量,采用坐标格式。

此函数遵循来自 scipy.sparse.coo_matrix 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.html

copy(a)[源]

返回给定张量的副本。

这个函数遵循来自 numpy.copy 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.copy.html

cumsum(a, axis=None)[源]

返回给定维度上张量元素的累计和。

这个函数遵循来自 numpy.cumsum 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.cumsum.html

det(x)[源]

计算数组的行列式。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.det.html

device_type(type_as)[源]

根据给定张量所在设备返回CPU或GPU。

diag(a, k=0)[源]

提取或构造对角张量。

该函数遵循来自 numpy.diag 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.diag.html

dot(a, b)[源]

返回两个张量的点积。

此函数遵循来自 numpy.dot 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.dot.html

dtype_device(a)[源]

返回给定张量的 dtype 和设备。

eigh(a)[源]

计算对称张量的特征值和特征向量。

此函数遵循来自 scipy.linalg.eigh 的 API。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigh.html

einsum(subscripts, *operands)[源]

对操作数评估爱因斯坦求和约定。

该函数遵循来自 numpy.einsum 的API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.einsum.html

eliminate_zeros(a, threshold=0.0)[源]

从稀疏张量中移除小于给定阈值的条目。

此函数遵循来自 scipy.sparse.csr_matrix.eliminate_zeros 的 API

查看: https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.sparse.csr_matrix.eliminate_zeros.html

exp(a)[源]

逐元素计算指数值。

此函数遵循来自 numpy.exp 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.exp.html

eye(N, M=None, type_as=None)[源]

创建给定大小的单位矩阵。

该函数遵循来自 numpy.eye 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.eye.html

flip(a, axis=None)[源]

沿给定维度反转张量中元素的顺序。

此函数遵循来自 numpy.flip 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.flip.html

floor(a)[源]

返回输入的元素的下限

见: https://numpy.org/doc/stable/reference/generated/numpy.floor.html

full(shape, fill_value, type_as=None)[源]

创建一个具有给定形状的张量,并用给定值填充。

该函数遵循来自 numpy.full 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.full.html

inv(a)[源]

计算矩阵的逆。

此函数遵循来自 scipy.linalg.inv 的 API。

请查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.inv.html

is_floating_point(a)[源]

返回输入是否由浮点数组成

isfinite(a)[源]

逐元素测试有限性(非无限和非数字)。

该函数遵循来自 numpy.isfinite 的API。

查看: https://numpy.org/doc/stable/reference/generated/numpy.isfinite.html

isinf(a)[源]

逐元素测试正无穷大或负无穷大,并返回布尔张量作为结果。

此函数遵循来自 numpy.isinf 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.isinf.html

isnan(a)[源]

逐元素测试是否为NaN,并将结果返回为布尔张量。

这个函数遵循来自 numpy.isnan 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.isnan.html

issparse(a)[源]

检查输入张量是否为稀疏张量。

此函数遵循来自 scipy.sparse.issparse 的API

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.issparse.html

kl_div(p, q, mass=False, eps=1e-16)[源]

计算(广义)Kullback-Leibler散度。

此函数遵循来自 scipy.stats.entropy 的 API。

参数 eps 用于避免数值错误,并添加在日志中。

\[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\]

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.entropy.html

linspace(start, stop, num, type_as=None)[源]

在给定区间内返回指定数量的均匀间隔的值。

此函数遵循来自 numpy.linspace 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.linspace.html

log(a)[源]

逐元素计算自然对数。

该函数遵循来自 numpy.log 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.log.html

logsumexp(a, axis=None)[源]

计算输入元素指数和的对数。

此函数遵循来自 scipy.special.logsumexp 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.logsumexp.html

matmul(a, b)[源]

两个数组的矩阵乘积。

见: https://numpy.org/doc/stable/reference/generated/numpy.matmul.html#numpy.matmul

max(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

此函数遵循来自 numpy.amax 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.amax.html

maximum(a, b)[源]

返回数组元素的逐元素最大值。

此函数遵循来自 numpy.maximum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.maximum.html

mean(a, axis=None)[源]

计算张量沿给定维度的算术平均值。

此函数遵循来自 numpy.mean 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.mean.html

median(a, axis=None)[源]

计算张量在给定维度上的中位数。

此函数遵循来自 numpy.median 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.median.html

meshgrid(a, b)[源]

从坐标向量返回坐标矩阵(Numpy 约定)。

该函数遵循numpy.meshgrid的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.meshgrid.html

min(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

这个函数遵循来自 numpy.amin 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.amin.html

minimum(a, b)[源]

返回数组元素的逐元素最小值。

该函数遵循来自 numpy.minimum 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.minimum.html

nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None)[源]

将NaN替换为零,将无穷大替换为大型有限数字或用户定义的数字。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.nan_to_num.html#numpy.nan_to_num

norm(a, axis=None, keepdims=False)[源]

计算矩阵的弗罗贝尼乌斯范数。

此函数遵循来自 numpy.linalg.norm 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.norm.html

ones(shape, type_as=None)[源]

创建一个全为一的张量。

此函数遵循来自 numpy.ones 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.ones.html

outer(a, b)[源]

计算两个向量之间的外积。

此函数遵循来自 numpy.outer 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.outer.html

power(a, exponents)[源]

第一个张量的元素逐个提升到第二个张量的幂。

该函数遵循来自 numpy.power 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.power.html

prod(a, axis=0)[源]

返回所有元素的乘积。

查看: https://numpy.org/doc/stable/reference/generated/numpy.prod.html

qr(a)[源]

返回QR分解

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.qr.html

rand(*size, type_as=None)[源]

生成均匀随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

randn(*size, type_as=None)[源]

生成正态高斯随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

repeat(a, repeats, axis=None)[源]

重复张量的元素。

此函数遵循来自 numpy.repeat 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.repeat.html

reshape(a, shape)[源]

不改变数据的情况下,给张量赋予新的形状。

该函数遵循来自 numpy.reshape 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.reshape.html

searchsorted(a, v, side='left')[源]

找到应该插入元素以保持给定张量中的顺序的索引。

此函数遵循来自 numpy.searchsorted 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.searchsorted.html

seed(seed=None)[源]

设置随机生成器的种子。

这个函数遵循来自 numpy.random.seed 的 API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.seed.html

set_gradients(val, inputs, grads)[源]

定义相对于输入的值 val 的梯度

sign(a)[源]

返回一个元素逐个指示一个数字的符号。

此函数遵循来自 numpy.sign 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.sign.html

solve(a, b)[源]

求解线性矩阵方程或线性标量方程组。

此函数遵循来自 numpy.linalg.solve 的 API。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.solve.html

sort(a, axis=-1)[源]

返回一个排序后的张量副本。

此函数遵循来自 numpy.sort 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.sort.html

sort2(a, axis=-1)[源]

返回排序后的数组和排序数组的索引

查看: https://pytorch.org/docs/stable/generated/torch.sort.html

sqrt(a)[源]

返回张量的非负平方根,逐元素进行。

此函数遵循来自 numpy.sqrt 的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.sqrt.html

sqrtm(a)[源]

计算矩阵的平方根。 需要输入对称的半正定。

这个函数遵循scipy.linalg.sqrtm的API,允许批处理。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.sqrtm.html

squeeze(a, axis=None)[源]

从a中移除长度为一的轴。

此函数遵循来自 numpy.squeeze 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.squeeze.html

stack(arrays, axis=0)[源]

在新的维度上连接一系列张量。

此函数遵循来自 numpy.stack 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.stack.html

std(a, axis=None)[源]

计算给定维度上张量的标准差。

此函数遵循来自 numpy.std 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.std.html

sum(a, axis=None, keepdims=False)[源]

对给定维度的张量元素求和。

该函数遵循来自 numpy.sum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.sum.html

take_along_axis(arr, indices, axis)[源]

沿给定维度收集张量的元素。

此函数遵循来自 numpy.take_along_axis 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.take_along_axis.html

tile(a, reps)[源]

通过重复给定次数的数字构建数组

见: https://numpy.org/doc/stable/reference/generated/numpy.tile.html

tocsr(a)[源]

将此矩阵转换为压缩稀疏行格式。

此函数遵循来自 scipy.sparse.coo_matrix.tocsr 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.tocsr.html

todense(a)[源]

将稀疏张量转换为密集张量。

此函数遵循来自 scipy.sparse.csr_matrix.toarray 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.toarray.html

trace(a)[源]

返回数组沿对角线的和。

这个函数遵循来自 numpy.trace 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.trace.html

transpose(a, axes=None)[源]

返回一个张量,该张量是a的转置版本。给定的维度dim0和dim1被交换。

见: https://numpy.org/doc/stable/reference/generated/numpy.transpose.html

unique(a, return_inverse=False)[源]

查找给定张量的唯一元素。

此函数遵循来自 numpy.unique 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.unique.html

where(condition, x=None, y=None)[源]

根据条件从 x 或 y 中返回选定的元素。

此函数遵循来自 numpy.where 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.where.html

zero_pad(a, pad_width, value=0)[源]

用给定的值(默认是0)填充一个张量。

此函数遵循来自 numpy.pad 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.pad.html

zeros(shape, type_as=None)[源]

创建一个满是零的张量。

该函数遵循来自 numpy.zeros 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.zeros.html

class ot.backend.JaxBackend[源]

后端的JAX实现

  • __name__ 是 “jax”

  • __type__ 是 jax.numpy.ndarray

abs(a)[源]

逐元素计算绝对值。

此函数遵循来自 numpy.absolute 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.absolute.html

allclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False)[源]

如果两个数组在容差范围内逐元素相等,则返回 True。

此函数遵循来自 numpy.allclose 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.allclose.html

any(a)[源]

测试沿给定维度的任何张量元素是否评估为真。

此函数遵循来自 numpy.any 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.any.html

arange(stop, start=0, step=1, type_as=None)[源]

返回特定区间内均匀间隔的值。

此函数遵循来自 numpy.arange 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.arange.html

argmax(a, axis=None)[源]

返回张量在给定维度上的最大值的索引。

这个函数遵循来自 numpy.argmax 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.argmax.html

argmin(a, axis=None)[源]

返回张量在给定维度上的最小值的索引。

此函数遵循来自 numpy.argmin 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.argmin.html

argsort(a, axis=-1)[源]

返回将张量排序的索引。

此函数遵循来自 numpy.argsort 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.argsort.html

array_equal(a, b)[源]

如果两个数组具有相同的形状和元素,则返回True,否则返回False。

此函数遵循numpy.array_equal的API。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.array_equal.html

assert_same_dtype_device(a, b)[源]

检查两个给定输入是否具有相同的数据类型以及相同的设备

atan2(a, b)[源]

逐元素反正切

见: https://numpy.org/doc/stable/reference/generated/numpy.arctan2.html

bitsize(type_as)[源]

给定张量的数据类型所使用的比特数。

clip(a, a_min, a_max)[源]

限制张量中的值。

此函数遵循numpy.clip的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.clip.html

concatenate(arrays, axis=0)[源]

沿着现有维度连接一系列张量。

此函数遵循来自 numpy.concatenate 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.concatenate.html

coo_matrix(data, rows, cols, shape=None, type_as=None)[源]

创建一个稀疏张量,采用坐标格式。

此函数遵循来自 scipy.sparse.coo_matrix 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.html

copy(a)[源]

返回给定张量的副本。

这个函数遵循来自 numpy.copy 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.copy.html

cumsum(a, axis=None)[源]

返回给定维度上张量元素的累计和。

这个函数遵循来自 numpy.cumsum 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.cumsum.html

det(x)[源]

计算数组的行列式。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.det.html

device_type(type_as)[源]

根据给定张量所在设备返回CPU或GPU。

diag(a, k=0)[源]

提取或构造对角张量。

该函数遵循来自 numpy.diag 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.diag.html

dot(a, b)[源]

返回两个张量的点积。

此函数遵循来自 numpy.dot 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.dot.html

dtype_device(a)[源]

返回给定张量的 dtype 和设备。

eigh(a)[源]

计算对称张量的特征值和特征向量。

此函数遵循来自 scipy.linalg.eigh 的 API。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigh.html

einsum(subscripts, *operands)[源]

对操作数评估爱因斯坦求和约定。

该函数遵循来自 numpy.einsum 的API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.einsum.html

eliminate_zeros(a, threshold=0.0)[源]

从稀疏张量中移除小于给定阈值的条目。

此函数遵循来自 scipy.sparse.csr_matrix.eliminate_zeros 的 API

查看: https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.sparse.csr_matrix.eliminate_zeros.html

exp(a)[源]

逐元素计算指数值。

此函数遵循来自 numpy.exp 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.exp.html

eye(N, M=None, type_as=None)[源]

创建给定大小的单位矩阵。

该函数遵循来自 numpy.eye 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.eye.html

flip(a, axis=None)[源]

沿给定维度反转张量中元素的顺序。

此函数遵循来自 numpy.flip 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.flip.html

floor(a)[源]

返回输入的元素的下限

见: https://numpy.org/doc/stable/reference/generated/numpy.floor.html

full(shape, fill_value, type_as=None)[源]

创建一个具有给定形状的张量,并用给定值填充。

该函数遵循来自 numpy.full 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.full.html

inv(a)[源]

计算矩阵的逆。

此函数遵循来自 scipy.linalg.inv 的 API。

请查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.inv.html

is_floating_point(a)[源]

返回输入是否由浮点数组成

isfinite(a)[源]

逐元素测试有限性(非无限和非数字)。

该函数遵循来自 numpy.isfinite 的API。

查看: https://numpy.org/doc/stable/reference/generated/numpy.isfinite.html

isinf(a)[源]

逐元素测试正无穷大或负无穷大,并返回布尔张量作为结果。

此函数遵循来自 numpy.isinf 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.isinf.html

isnan(a)[源]

逐元素测试是否为NaN,并将结果返回为布尔张量。

这个函数遵循来自 numpy.isnan 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.isnan.html

issparse(a)[源]

检查输入张量是否为稀疏张量。

此函数遵循来自 scipy.sparse.issparse 的API

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.issparse.html

kl_div(p, q, mass=False, eps=1e-16)[源]

计算(广义)Kullback-Leibler散度。

此函数遵循来自 scipy.stats.entropy 的 API。

参数 eps 用于避免数值错误,并添加在日志中。

\[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\]

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.entropy.html

linspace(start, stop, num, type_as=None)[源]

在给定区间内返回指定数量的均匀间隔的值。

此函数遵循来自 numpy.linspace 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.linspace.html

log(a)[源]

逐元素计算自然对数。

该函数遵循来自 numpy.log 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.log.html

logsumexp(a, axis=None)[源]

计算输入元素指数和的对数。

此函数遵循来自 scipy.special.logsumexp 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.logsumexp.html

matmul(a, b)[源]

两个数组的矩阵乘积。

见: https://numpy.org/doc/stable/reference/generated/numpy.matmul.html#numpy.matmul

max(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

此函数遵循来自 numpy.amax 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.amax.html

maximum(a, b)[源]

返回数组元素的逐元素最大值。

此函数遵循来自 numpy.maximum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.maximum.html

mean(a, axis=None)[源]

计算张量沿给定维度的算术平均值。

此函数遵循来自 numpy.mean 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.mean.html

median(a, axis=None)[源]

计算张量在给定维度上的中位数。

此函数遵循来自 numpy.median 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.median.html

meshgrid(a, b)[源]

从坐标向量返回坐标矩阵(Numpy 约定)。

该函数遵循numpy.meshgrid的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.meshgrid.html

min(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

这个函数遵循来自 numpy.amin 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.amin.html

minimum(a, b)[源]

返回数组元素的逐元素最小值。

该函数遵循来自 numpy.minimum 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.minimum.html

nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None)[源]

将NaN替换为零,将无穷大替换为大型有限数字或用户定义的数字。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.nan_to_num.html#numpy.nan_to_num

norm(a, axis=None, keepdims=False)[源]

计算矩阵的弗罗贝尼乌斯范数。

此函数遵循来自 numpy.linalg.norm 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.norm.html

ones(shape, type_as=None)[源]

创建一个全为一的张量。

此函数遵循来自 numpy.ones 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.ones.html

outer(a, b)[源]

计算两个向量之间的外积。

此函数遵循来自 numpy.outer 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.outer.html

power(a, exponents)[源]

第一个张量的元素逐个提升到第二个张量的幂。

该函数遵循来自 numpy.power 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.power.html

prod(a, axis=0)[源]

返回所有元素的乘积。

查看: https://numpy.org/doc/stable/reference/generated/numpy.prod.html

qr(a)[源]

返回QR分解

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.qr.html

rand(*size, type_as=None)[源]

生成均匀随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

randn(*size, type_as=None)[源]

生成正态高斯随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

repeat(a, repeats, axis=None)[源]

重复张量的元素。

此函数遵循来自 numpy.repeat 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.repeat.html

reshape(a, shape)[源]

不改变数据的情况下,给张量赋予新的形状。

该函数遵循来自 numpy.reshape 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.reshape.html

searchsorted(a, v, side='left')[源]

找到应该插入元素以保持给定张量中的顺序的索引。

此函数遵循来自 numpy.searchsorted 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.searchsorted.html

seed(seed=None)[源]

设置随机生成器的种子。

这个函数遵循来自 numpy.random.seed 的 API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.seed.html

set_gradients(val, inputs, grads)[源]

定义相对于输入的值 val 的梯度

sign(a)[源]

返回一个元素逐个指示一个数字的符号。

此函数遵循来自 numpy.sign 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.sign.html

solve(a, b)[源]

求解线性矩阵方程或线性标量方程组。

此函数遵循来自 numpy.linalg.solve 的 API。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.solve.html

sort(a, axis=-1)[源]

返回一个排序后的张量副本。

此函数遵循来自 numpy.sort 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.sort.html

sort2(a, axis=-1)[源]

返回排序后的数组和排序数组的索引

查看: https://pytorch.org/docs/stable/generated/torch.sort.html

sqrt(a)[源]

返回张量的非负平方根,逐元素进行。

此函数遵循来自 numpy.sqrt 的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.sqrt.html

sqrtm(a)[源]

计算矩阵的平方根。 需要输入对称的半正定。

这个函数遵循scipy.linalg.sqrtm的API,允许批处理。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.sqrtm.html

squeeze(a, axis=None)[源]

从a中移除长度为一的轴。

此函数遵循来自 numpy.squeeze 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.squeeze.html

stack(arrays, axis=0)[源]

在新的维度上连接一系列张量。

此函数遵循来自 numpy.stack 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.stack.html

std(a, axis=None)[源]

计算给定维度上张量的标准差。

此函数遵循来自 numpy.std 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.std.html

sum(a, axis=None, keepdims=False)[源]

对给定维度的张量元素求和。

该函数遵循来自 numpy.sum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.sum.html

take_along_axis(arr, indices, axis)[源]

沿给定维度收集张量的元素。

此函数遵循来自 numpy.take_along_axis 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.take_along_axis.html

tile(a, reps)[源]

通过重复给定次数的数字构建数组

见: https://numpy.org/doc/stable/reference/generated/numpy.tile.html

tocsr(a)[源]

将此矩阵转换为压缩稀疏行格式。

此函数遵循来自 scipy.sparse.coo_matrix.tocsr 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.tocsr.html

todense(a)[源]

将稀疏张量转换为密集张量。

此函数遵循来自 scipy.sparse.csr_matrix.toarray 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.toarray.html

trace(a)[源]

返回数组沿对角线的和。

这个函数遵循来自 numpy.trace 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.trace.html

transpose(a, axes=None)[源]

返回一个张量,该张量是a的转置版本。给定的维度dim0和dim1被交换。

见: https://numpy.org/doc/stable/reference/generated/numpy.transpose.html

unique(a, return_inverse=False)[源]

查找给定张量的唯一元素。

此函数遵循来自 numpy.unique 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.unique.html

where(condition, x=None, y=None)[源]

根据条件从 x 或 y 中返回选定的元素。

此函数遵循来自 numpy.where 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.where.html

zero_pad(a, pad_width, value=0)[源]

用给定的值(默认是0)填充一个张量。

此函数遵循来自 numpy.pad 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.pad.html

zeros(shape, type_as=None)[源]

创建一个满是零的张量。

该函数遵循来自 numpy.zeros 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.zeros.html

class ot.backend.NumpyBackend[源]

NumPy 后端实现

  • __name__ 是 “numpy”

  • __type__ 是 np.ndarray

abs(a)[源]

逐元素计算绝对值。

此函数遵循来自 numpy.absolute 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.absolute.html

allclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False)[源]

如果两个数组在容差范围内逐元素相等,则返回 True。

此函数遵循来自 numpy.allclose 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.allclose.html

any(a)[源]

测试沿给定维度的任何张量元素是否评估为真。

此函数遵循来自 numpy.any 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.any.html

arange(stop, start=0, step=1, type_as=None)[源]

返回特定区间内均匀间隔的值。

此函数遵循来自 numpy.arange 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.arange.html

argmax(a, axis=None)[源]

返回张量在给定维度上的最大值的索引。

这个函数遵循来自 numpy.argmax 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.argmax.html

argmin(a, axis=None)[源]

返回张量在给定维度上的最小值的索引。

此函数遵循来自 numpy.argmin 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.argmin.html

argsort(a, axis=-1)[源]

返回将张量排序的索引。

此函数遵循来自 numpy.argsort 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.argsort.html

array_equal(a, b)[源]

如果两个数组具有相同的形状和元素,则返回True,否则返回False。

此函数遵循numpy.array_equal的API。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.array_equal.html

assert_same_dtype_device(a, b)[源]

检查两个给定输入是否具有相同的数据类型以及相同的设备

atan2(a, b)[源]

逐元素反正切

见: https://numpy.org/doc/stable/reference/generated/numpy.arctan2.html

bitsize(type_as)[源]

给定张量的数据类型所使用的比特数。

clip(a, a_min, a_max)[源]

限制张量中的值。

此函数遵循numpy.clip的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.clip.html

concatenate(arrays, axis=0)[源]

沿着现有维度连接一系列张量。

此函数遵循来自 numpy.concatenate 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.concatenate.html

coo_matrix(data, rows, cols, shape=None, type_as=None)[源]

创建一个稀疏张量,采用坐标格式。

此函数遵循来自 scipy.sparse.coo_matrix 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.html

copy(a)[源]

返回给定张量的副本。

这个函数遵循来自 numpy.copy 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.copy.html

cumsum(a, axis=None)[源]

返回给定维度上张量元素的累计和。

这个函数遵循来自 numpy.cumsum 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.cumsum.html

det(a)[源]

计算数组的行列式。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.det.html

device_type(type_as)[源]

根据给定张量所在设备返回CPU或GPU。

diag(a, k=0)[源]

提取或构造对角张量。

该函数遵循来自 numpy.diag 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.diag.html

dot(a, b)[源]

返回两个张量的点积。

此函数遵循来自 numpy.dot 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.dot.html

dtype_device(a)[源]

返回给定张量的 dtype 和设备。

eigh(a)[源]

计算对称张量的特征值和特征向量。

此函数遵循来自 scipy.linalg.eigh 的 API。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigh.html

einsum(subscripts, *operands)[源]

对操作数评估爱因斯坦求和约定。

该函数遵循来自 numpy.einsum 的API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.einsum.html

eliminate_zeros(a, threshold=0.0)[源]

从稀疏张量中移除小于给定阈值的条目。

此函数遵循来自 scipy.sparse.csr_matrix.eliminate_zeros 的 API

查看: https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.sparse.csr_matrix.eliminate_zeros.html

exp(a)[源]

逐元素计算指数值。

此函数遵循来自 numpy.exp 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.exp.html

eye(N, M=None, type_as=None)[源]

创建给定大小的单位矩阵。

该函数遵循来自 numpy.eye 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.eye.html

flip(a, axis=None)[源]

沿给定维度反转张量中元素的顺序。

此函数遵循来自 numpy.flip 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.flip.html

floor(a)[源]

返回输入的元素的下限

见: https://numpy.org/doc/stable/reference/generated/numpy.floor.html

full(shape, fill_value, type_as=None)[源]

创建一个具有给定形状的张量,并用给定值填充。

该函数遵循来自 numpy.full 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.full.html

inv(a)[源]

计算矩阵的逆。

此函数遵循来自 scipy.linalg.inv 的 API。

请查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.inv.html

is_floating_point(a)[源]

返回输入是否由浮点数组成

isfinite(a)[源]

逐元素测试有限性(非无限和非数字)。

该函数遵循来自 numpy.isfinite 的API。

查看: https://numpy.org/doc/stable/reference/generated/numpy.isfinite.html

isinf(a)[源]

逐元素测试正无穷大或负无穷大,并返回布尔张量作为结果。

此函数遵循来自 numpy.isinf 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.isinf.html

isnan(a)[源]

逐元素测试是否为NaN,并将结果返回为布尔张量。

这个函数遵循来自 numpy.isnan 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.isnan.html

issparse(a)[源]

检查输入张量是否为稀疏张量。

此函数遵循来自 scipy.sparse.issparse 的API

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.issparse.html

kl_div(p, q, mass=False, eps=1e-16)[源]

计算(广义)Kullback-Leibler散度。

此函数遵循来自 scipy.stats.entropy 的 API。

参数 eps 用于避免数值错误,并添加在日志中。

\[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\]

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.entropy.html

linspace(start, stop, num, type_as=None)[源]

在给定区间内返回指定数量的均匀间隔的值。

此函数遵循来自 numpy.linspace 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.linspace.html

log(a)[源]

逐元素计算自然对数。

该函数遵循来自 numpy.log 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.log.html

logsumexp(a, axis=None)[源]

计算输入元素指数和的对数。

此函数遵循来自 scipy.special.logsumexp 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.logsumexp.html

matmul(a, b)[源]

两个数组的矩阵乘积。

见: https://numpy.org/doc/stable/reference/generated/numpy.matmul.html#numpy.matmul

max(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

此函数遵循来自 numpy.amax 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.amax.html

maximum(a, b)[源]

返回数组元素的逐元素最大值。

此函数遵循来自 numpy.maximum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.maximum.html

mean(a, axis=None)[源]

计算张量沿给定维度的算术平均值。

此函数遵循来自 numpy.mean 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.mean.html

median(a, axis=None)[源]

计算张量在给定维度上的中位数。

此函数遵循来自 numpy.median 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.median.html

meshgrid(a, b)[源]

从坐标向量返回坐标矩阵(Numpy 约定)。

该函数遵循numpy.meshgrid的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.meshgrid.html

min(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

这个函数遵循来自 numpy.amin 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.amin.html

minimum(a, b)[源]

返回数组元素的逐元素最小值。

该函数遵循来自 numpy.minimum 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.minimum.html

nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None)[源]

将NaN替换为零,将无穷大替换为大型有限数字或用户定义的数字。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.nan_to_num.html#numpy.nan_to_num

norm(a, axis=None, keepdims=False)[源]

计算矩阵的弗罗贝尼乌斯范数。

此函数遵循来自 numpy.linalg.norm 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.norm.html

ones(shape, type_as=None)[源]

创建一个全为一的张量。

此函数遵循来自 numpy.ones 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.ones.html

outer(a, b)[源]

计算两个向量之间的外积。

此函数遵循来自 numpy.outer 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.outer.html

power(a, exponents)[源]

第一个张量的元素逐个提升到第二个张量的幂。

该函数遵循来自 numpy.power 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.power.html

prod(a, axis=0)[源]

返回所有元素的乘积。

查看: https://numpy.org/doc/stable/reference/generated/numpy.prod.html

qr(a)[源]

返回QR分解

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.qr.html

rand(*size, type_as=None)[源]

生成均匀随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

randn(*size, type_as=None)[源]

生成正态高斯随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

repeat(a, repeats, axis=None)[源]

重复张量的元素。

此函数遵循来自 numpy.repeat 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.repeat.html

reshape(a, shape)[源]

不改变数据的情况下,给张量赋予新的形状。

该函数遵循来自 numpy.reshape 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.reshape.html

searchsorted(a, v, side='left')[源]

找到应该插入元素以保持给定张量中的顺序的索引。

此函数遵循来自 numpy.searchsorted 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.searchsorted.html

seed(seed=None)[源]

设置随机生成器的种子。

这个函数遵循来自 numpy.random.seed 的 API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.seed.html

set_gradients(val, inputs, grads)[源]

定义相对于输入的值 val 的梯度

sign(a)[源]

返回一个元素逐个指示一个数字的符号。

此函数遵循来自 numpy.sign 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.sign.html

solve(a, b)[源]

求解线性矩阵方程或线性标量方程组。

此函数遵循来自 numpy.linalg.solve 的 API。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.solve.html

sort(a, axis=-1)[源]

返回一个排序后的张量副本。

此函数遵循来自 numpy.sort 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.sort.html

sort2(a, axis=-1)[源]

返回排序后的数组和排序数组的索引

查看: https://pytorch.org/docs/stable/generated/torch.sort.html

sqrt(a)[源]

返回张量的非负平方根,逐元素进行。

此函数遵循来自 numpy.sqrt 的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.sqrt.html

sqrtm(a)[源]

计算矩阵的平方根。 需要输入对称的半正定。

这个函数遵循scipy.linalg.sqrtm的API,允许批处理。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.sqrtm.html

squeeze(a, axis=None)[源]

从a中移除长度为一的轴。

此函数遵循来自 numpy.squeeze 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.squeeze.html

stack(arrays, axis=0)[源]

在新的维度上连接一系列张量。

此函数遵循来自 numpy.stack 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.stack.html

std(a, axis=None)[源]

计算给定维度上张量的标准差。

此函数遵循来自 numpy.std 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.std.html

sum(a, axis=None, keepdims=False)[源]

对给定维度的张量元素求和。

该函数遵循来自 numpy.sum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.sum.html

take_along_axis(arr, indices, axis)[源]

沿给定维度收集张量的元素。

此函数遵循来自 numpy.take_along_axis 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.take_along_axis.html

tile(a, reps)[源]

通过重复给定次数的数字构建数组

见: https://numpy.org/doc/stable/reference/generated/numpy.tile.html

tocsr(a)[源]

将此矩阵转换为压缩稀疏行格式。

此函数遵循来自 scipy.sparse.coo_matrix.tocsr 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.tocsr.html

todense(a)[源]

将稀疏张量转换为密集张量。

此函数遵循来自 scipy.sparse.csr_matrix.toarray 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.toarray.html

trace(a)[源]

返回数组沿对角线的和。

这个函数遵循来自 numpy.trace 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.trace.html

transpose(a, axes=None)[源]

返回一个张量,该张量是a的转置版本。给定的维度dim0和dim1被交换。

见: https://numpy.org/doc/stable/reference/generated/numpy.transpose.html

unique(a, return_inverse=False)[源]

查找给定张量的唯一元素。

此函数遵循来自 numpy.unique 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.unique.html

where(condition, x=None, y=None)[源]

根据条件从 x 或 y 中返回选定的元素。

此函数遵循来自 numpy.where 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.where.html

zero_pad(a, pad_width, value=0)[源]

用给定的值(默认是0)填充一个张量。

此函数遵循来自 numpy.pad 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.pad.html

zeros(shape, type_as=None)[源]

创建一个满是零的张量。

该函数遵循来自 numpy.zeros 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.zeros.html

class ot.backend.TensorflowBackend[源]
abs(a)[源]

逐元素计算绝对值。

此函数遵循来自 numpy.absolute 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.absolute.html

allclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False)[源]

如果两个数组在容差范围内逐元素相等,则返回 True。

此函数遵循来自 numpy.allclose 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.allclose.html

any(a)[源]

测试沿给定维度的任何张量元素是否评估为真。

此函数遵循来自 numpy.any 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.any.html

arange(stop, start=0, step=1, type_as=None)[源]

返回特定区间内均匀间隔的值。

此函数遵循来自 numpy.arange 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.arange.html

argmax(a, axis=None)[源]

返回张量在给定维度上的最大值的索引。

这个函数遵循来自 numpy.argmax 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.argmax.html

argmin(a, axis=None)[源]

返回张量在给定维度上的最小值的索引。

此函数遵循来自 numpy.argmin 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.argmin.html

argsort(a, axis=-1)[源]

返回将张量排序的索引。

此函数遵循来自 numpy.argsort 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.argsort.html

array_equal(a, b)[源]

如果两个数组具有相同的形状和元素,则返回True,否则返回False。

此函数遵循numpy.array_equal的API。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.array_equal.html

assert_same_dtype_device(a, b)[源]

检查两个给定输入是否具有相同的数据类型以及相同的设备

atan2(a, b)[源]

逐元素反正切

见: https://numpy.org/doc/stable/reference/generated/numpy.arctan2.html

bitsize(type_as)[源]

给定张量的数据类型所使用的比特数。

clip(a, a_min, a_max)[源]

限制张量中的值。

此函数遵循numpy.clip的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.clip.html

concatenate(arrays, axis=0)[源]

沿着现有维度连接一系列张量。

此函数遵循来自 numpy.concatenate 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.concatenate.html

coo_matrix(data, rows, cols, shape=None, type_as=None)[源]

创建一个稀疏张量,采用坐标格式。

此函数遵循来自 scipy.sparse.coo_matrix 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.html

copy(a)[源]

返回给定张量的副本。

这个函数遵循来自 numpy.copy 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.copy.html

cumsum(a, axis=None)[源]

返回给定维度上张量元素的累计和。

这个函数遵循来自 numpy.cumsum 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.cumsum.html

det(x)[源]

计算数组的行列式。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.det.html

device_type(type_as)[源]

根据给定张量所在设备返回CPU或GPU。

diag(a, k=0)[源]

提取或构造对角张量。

该函数遵循来自 numpy.diag 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.diag.html

dot(a, b)[源]

返回两个张量的点积。

此函数遵循来自 numpy.dot 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.dot.html

dtype_device(a)[源]

返回给定张量的 dtype 和设备。

eigh(a)[源]

计算对称张量的特征值和特征向量。

此函数遵循来自 scipy.linalg.eigh 的 API。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigh.html

einsum(subscripts, *operands)[源]

对操作数评估爱因斯坦求和约定。

该函数遵循来自 numpy.einsum 的API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.einsum.html

eliminate_zeros(a, threshold=0.0)[源]

从稀疏张量中移除小于给定阈值的条目。

此函数遵循来自 scipy.sparse.csr_matrix.eliminate_zeros 的 API

查看: https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.sparse.csr_matrix.eliminate_zeros.html

exp(a)[源]

逐元素计算指数值。

此函数遵循来自 numpy.exp 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.exp.html

eye(N, M=None, type_as=None)[源]

创建给定大小的单位矩阵。

该函数遵循来自 numpy.eye 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.eye.html

flip(a, axis=None)[源]

沿给定维度反转张量中元素的顺序。

此函数遵循来自 numpy.flip 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.flip.html

floor(a)[源]

返回输入的元素的下限

见: https://numpy.org/doc/stable/reference/generated/numpy.floor.html

full(shape, fill_value, type_as=None)[源]

创建一个具有给定形状的张量,并用给定值填充。

该函数遵循来自 numpy.full 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.full.html

inv(a)[源]

计算矩阵的逆。

此函数遵循来自 scipy.linalg.inv 的 API。

请查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.inv.html

is_floating_point(a)[源]

返回输入是否由浮点数组成

isfinite(a)[源]

逐元素测试有限性(非无限和非数字)。

该函数遵循来自 numpy.isfinite 的API。

查看: https://numpy.org/doc/stable/reference/generated/numpy.isfinite.html

isinf(a)[源]

逐元素测试正无穷大或负无穷大,并返回布尔张量作为结果。

此函数遵循来自 numpy.isinf 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.isinf.html

isnan(a)[源]

逐元素测试是否为NaN,并将结果返回为布尔张量。

这个函数遵循来自 numpy.isnan 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.isnan.html

issparse(a)[源]

检查输入张量是否为稀疏张量。

此函数遵循来自 scipy.sparse.issparse 的API

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.issparse.html

kl_div(p, q, mass=False, eps=1e-16)[源]

计算(广义)Kullback-Leibler散度。

此函数遵循来自 scipy.stats.entropy 的 API。

参数 eps 用于避免数值错误,并添加在日志中。

\[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\]

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.entropy.html

linspace(start, stop, num, type_as=None)[源]

在给定区间内返回指定数量的均匀间隔的值。

此函数遵循来自 numpy.linspace 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.linspace.html

log(a)[源]

逐元素计算自然对数。

该函数遵循来自 numpy.log 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.log.html

logsumexp(a, axis=None)[源]

计算输入元素指数和的对数。

此函数遵循来自 scipy.special.logsumexp 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.logsumexp.html

matmul(a, b)[源]

两个数组的矩阵乘积。

见: https://numpy.org/doc/stable/reference/generated/numpy.matmul.html#numpy.matmul

max(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

此函数遵循来自 numpy.amax 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.amax.html

maximum(a, b)[源]

返回数组元素的逐元素最大值。

此函数遵循来自 numpy.maximum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.maximum.html

mean(a, axis=None)[源]

计算张量沿给定维度的算术平均值。

此函数遵循来自 numpy.mean 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.mean.html

median(a, axis=None)[源]

计算张量在给定维度上的中位数。

此函数遵循来自 numpy.median 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.median.html

meshgrid(a, b)[源]

从坐标向量返回坐标矩阵(Numpy 约定)。

该函数遵循numpy.meshgrid的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.meshgrid.html

min(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

这个函数遵循来自 numpy.amin 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.amin.html

minimum(a, b)[源]

返回数组元素的逐元素最小值。

该函数遵循来自 numpy.minimum 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.minimum.html

nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None)[源]

将NaN替换为零,将无穷大替换为大型有限数字或用户定义的数字。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.nan_to_num.html#numpy.nan_to_num

norm(a, axis=None, keepdims=False)[源]

计算矩阵的弗罗贝尼乌斯范数。

此函数遵循来自 numpy.linalg.norm 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.norm.html

ones(shape, type_as=None)[源]

创建一个全为一的张量。

此函数遵循来自 numpy.ones 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.ones.html

outer(a, b)[源]

计算两个向量之间的外积。

此函数遵循来自 numpy.outer 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.outer.html

power(a, exponents)[源]

第一个张量的元素逐个提升到第二个张量的幂。

该函数遵循来自 numpy.power 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.power.html

prod(a, axis=0)[源]

返回所有元素的乘积。

查看: https://numpy.org/doc/stable/reference/generated/numpy.prod.html

qr(a)[源]

返回QR分解

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.qr.html

rand(*size, type_as=None)[源]

生成均匀随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

randn(*size, type_as=None)[源]

生成正态高斯随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

repeat(a, repeats, axis=None)[源]

重复张量的元素。

此函数遵循来自 numpy.repeat 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.repeat.html

reshape(a, shape)[源]

不改变数据的情况下,给张量赋予新的形状。

该函数遵循来自 numpy.reshape 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.reshape.html

searchsorted(a, v, side='left')[源]

找到应该插入元素以保持给定张量中的顺序的索引。

此函数遵循来自 numpy.searchsorted 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.searchsorted.html

seed(seed=None)[源]

设置随机生成器的种子。

这个函数遵循来自 numpy.random.seed 的 API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.seed.html

set_gradients(val, inputs, grads)[源]

定义相对于输入的值 val 的梯度

sign(a)[源]

返回一个元素逐个指示一个数字的符号。

此函数遵循来自 numpy.sign 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.sign.html

solve(a, b)[源]

求解线性矩阵方程或线性标量方程组。

此函数遵循来自 numpy.linalg.solve 的 API。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.solve.html

sort(a, axis=-1)[源]

返回一个排序后的张量副本。

此函数遵循来自 numpy.sort 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.sort.html

sort2(a, axis=-1)[源]

返回排序后的数组和排序数组的索引

查看: https://pytorch.org/docs/stable/generated/torch.sort.html

sqrt(a)[源]

返回张量的非负平方根,逐元素进行。

此函数遵循来自 numpy.sqrt 的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.sqrt.html

sqrtm(a)[源]

计算矩阵的平方根。 需要输入对称的半正定。

这个函数遵循scipy.linalg.sqrtm的API,允许批处理。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.sqrtm.html

squeeze(a, axis=None)[源]

从a中移除长度为一的轴。

此函数遵循来自 numpy.squeeze 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.squeeze.html

stack(arrays, axis=0)[源]

在新的维度上连接一系列张量。

此函数遵循来自 numpy.stack 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.stack.html

std(a, axis=None)[源]

计算给定维度上张量的标准差。

此函数遵循来自 numpy.std 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.std.html

sum(a, axis=None, keepdims=False)[源]

对给定维度的张量元素求和。

该函数遵循来自 numpy.sum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.sum.html

take_along_axis(arr, indices, axis)[源]

沿给定维度收集张量的元素。

此函数遵循来自 numpy.take_along_axis 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.take_along_axis.html

tile(a, reps)[源]

通过重复给定次数的数字构建数组

见: https://numpy.org/doc/stable/reference/generated/numpy.tile.html

tocsr(a)[源]

将此矩阵转换为压缩稀疏行格式。

此函数遵循来自 scipy.sparse.coo_matrix.tocsr 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.tocsr.html

todense(a)[源]

将稀疏张量转换为密集张量。

此函数遵循来自 scipy.sparse.csr_matrix.toarray 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.toarray.html

trace(a)[源]

返回数组沿对角线的和。

这个函数遵循来自 numpy.trace 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.trace.html

transpose(a, axes=None)[源]

返回一个张量,该张量是a的转置版本。给定的维度dim0和dim1被交换。

见: https://numpy.org/doc/stable/reference/generated/numpy.transpose.html

unique(a, return_inverse=False)[源]

查找给定张量的唯一元素。

此函数遵循来自 numpy.unique 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.unique.html

where(condition, x=None, y=None)[源]

根据条件从 x 或 y 中返回选定的元素。

此函数遵循来自 numpy.where 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.where.html

zero_pad(a, pad_width, value=0)[源]

用给定的值(默认是0)填充一个张量。

此函数遵循来自 numpy.pad 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.pad.html

zeros(shape, type_as=None)[源]

创建一个满是零的张量。

该函数遵循来自 numpy.zeros 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.zeros.html

class ot.backend.TorchBackend[源]

后端的PyTorch实现

  • __name__ 是 “torch”

  • __type__ 是 torch.Tensor

abs(a)[源]

逐元素计算绝对值。

此函数遵循来自 numpy.absolute 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.absolute.html

allclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False)[源]

如果两个数组在容差范围内逐元素相等,则返回 True。

此函数遵循来自 numpy.allclose 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.allclose.html

any(a)[源]

测试沿给定维度的任何张量元素是否评估为真。

此函数遵循来自 numpy.any 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.any.html

arange(stop, start=0, step=1, type_as=None)[源]

返回特定区间内均匀间隔的值。

此函数遵循来自 numpy.arange 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.arange.html

argmax(a, axis=None)[源]

返回张量在给定维度上的最大值的索引。

这个函数遵循来自 numpy.argmax 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.argmax.html

argmin(a, axis=None)[源]

返回张量在给定维度上的最小值的索引。

此函数遵循来自 numpy.argmin 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.argmin.html

argsort(a, axis=-1)[源]

返回将张量排序的索引。

此函数遵循来自 numpy.argsort 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.argsort.html

array_equal(a, b)[源]

如果两个数组具有相同的形状和元素,则返回True,否则返回False。

此函数遵循numpy.array_equal的API。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.array_equal.html

assert_same_dtype_device(a, b)[源]

检查两个给定输入是否具有相同的数据类型以及相同的设备

atan2(a, b)[源]

逐元素反正切

见: https://numpy.org/doc/stable/reference/generated/numpy.arctan2.html

bitsize(type_as)[源]

给定张量的数据类型所使用的比特数。

clip(a, a_min, a_max)[源]

限制张量中的值。

此函数遵循numpy.clip的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.clip.html

concatenate(arrays, axis=0)[源]

沿着现有维度连接一系列张量。

此函数遵循来自 numpy.concatenate 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.concatenate.html

coo_matrix(data, rows, cols, shape=None, type_as=None)[源]

创建一个稀疏张量,采用坐标格式。

此函数遵循来自 scipy.sparse.coo_matrix 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.html

copy(a)[源]

返回给定张量的副本。

这个函数遵循来自 numpy.copy 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.copy.html

cumsum(a, axis=None)[源]

返回给定维度上张量元素的累计和。

这个函数遵循来自 numpy.cumsum 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.cumsum.html

det(x)[源]

计算数组的行列式。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.det.html

device_type(type_as)[源]

根据给定张量所在设备返回CPU或GPU。

diag(a, k=0)[源]

提取或构造对角张量。

该函数遵循来自 numpy.diag 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.diag.html

dot(a, b)[源]

返回两个张量的点积。

此函数遵循来自 numpy.dot 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.dot.html

dtype_device(a)[源]

返回给定张量的 dtype 和设备。

eigh(a)[源]

计算对称张量的特征值和特征向量。

此函数遵循来自 scipy.linalg.eigh 的 API。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigh.html

einsum(subscripts, *operands)[源]

对操作数评估爱因斯坦求和约定。

该函数遵循来自 numpy.einsum 的API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.einsum.html

eliminate_zeros(a, threshold=0.0)[源]

从稀疏张量中移除小于给定阈值的条目。

此函数遵循来自 scipy.sparse.csr_matrix.eliminate_zeros 的 API

查看: https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.sparse.csr_matrix.eliminate_zeros.html

exp(a)[源]

逐元素计算指数值。

此函数遵循来自 numpy.exp 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.exp.html

eye(N, M=None, type_as=None)[源]

创建给定大小的单位矩阵。

该函数遵循来自 numpy.eye 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.eye.html

flip(a, axis=None)[源]

沿给定维度反转张量中元素的顺序。

此函数遵循来自 numpy.flip 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.flip.html

floor(a)[源]

返回输入的元素的下限

见: https://numpy.org/doc/stable/reference/generated/numpy.floor.html

full(shape, fill_value, type_as=None)[源]

创建一个具有给定形状的张量,并用给定值填充。

该函数遵循来自 numpy.full 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.full.html

inv(a)[源]

计算矩阵的逆。

此函数遵循来自 scipy.linalg.inv 的 API。

请查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.inv.html

is_floating_point(a)[源]

返回输入是否由浮点数组成

isfinite(a)[源]

逐元素测试有限性(非无限和非数字)。

该函数遵循来自 numpy.isfinite 的API。

查看: https://numpy.org/doc/stable/reference/generated/numpy.isfinite.html

isinf(a)[源]

逐元素测试正无穷大或负无穷大,并返回布尔张量作为结果。

此函数遵循来自 numpy.isinf 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.isinf.html

isnan(a)[源]

逐元素测试是否为NaN,并将结果返回为布尔张量。

这个函数遵循来自 numpy.isnan 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.isnan.html

issparse(a)[源]

检查输入张量是否为稀疏张量。

此函数遵循来自 scipy.sparse.issparse 的API

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.issparse.html

kl_div(p, q, mass=False, eps=1e-16)[源]

计算(广义)Kullback-Leibler散度。

此函数遵循来自 scipy.stats.entropy 的 API。

参数 eps 用于避免数值错误,并添加在日志中。

\[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\]

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.entropy.html

linspace(start, stop, num, type_as=None)[源]

在给定区间内返回指定数量的均匀间隔的值。

此函数遵循来自 numpy.linspace 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.linspace.html

log(a)[源]

逐元素计算自然对数。

该函数遵循来自 numpy.log 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.log.html

logsumexp(a, axis=None)[源]

计算输入元素指数和的对数。

此函数遵循来自 scipy.special.logsumexp 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.logsumexp.html

matmul(a, b)[源]

两个数组的矩阵乘积。

见: https://numpy.org/doc/stable/reference/generated/numpy.matmul.html#numpy.matmul

max(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

此函数遵循来自 numpy.amax 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.amax.html

maximum(a, b)[源]

返回数组元素的逐元素最大值。

此函数遵循来自 numpy.maximum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.maximum.html

mean(a, axis=None)[源]

计算张量沿给定维度的算术平均值。

此函数遵循来自 numpy.mean 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.mean.html

median(a, axis=None)[源]

计算张量在给定维度上的中位数。

此函数遵循来自 numpy.median 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.median.html

meshgrid(a, b)[源]

从坐标向量返回坐标矩阵(Numpy 约定)。

该函数遵循numpy.meshgrid的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.meshgrid.html

min(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

这个函数遵循来自 numpy.amin 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.amin.html

minimum(a, b)[源]

返回数组元素的逐元素最小值。

该函数遵循来自 numpy.minimum 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.minimum.html

nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None)[源]

将NaN替换为零,将无穷大替换为大型有限数字或用户定义的数字。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.nan_to_num.html#numpy.nan_to_num

norm(a, axis=None, keepdims=False)[源]

计算矩阵的弗罗贝尼乌斯范数。

此函数遵循来自 numpy.linalg.norm 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.norm.html

ones(shape, type_as=None)[源]

创建一个全为一的张量。

此函数遵循来自 numpy.ones 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.ones.html

outer(a, b)[源]

计算两个向量之间的外积。

此函数遵循来自 numpy.outer 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.outer.html

power(a, exponents)[源]

第一个张量的元素逐个提升到第二个张量的幂。

该函数遵循来自 numpy.power 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.power.html

prod(a, axis=0)[源]

返回所有元素的乘积。

查看: https://numpy.org/doc/stable/reference/generated/numpy.prod.html

qr(a)[源]

返回QR分解

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.qr.html

rand(*size, type_as=None)[源]

生成均匀随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

randn(*size, type_as=None)[源]

生成正态高斯随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

repeat(a, repeats, axis=None)[源]

重复张量的元素。

此函数遵循来自 numpy.repeat 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.repeat.html

reshape(a, shape)[源]

不改变数据的情况下,给张量赋予新的形状。

该函数遵循来自 numpy.reshape 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.reshape.html

searchsorted(a, v, side='left')[源]

找到应该插入元素以保持给定张量中的顺序的索引。

此函数遵循来自 numpy.searchsorted 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.searchsorted.html

seed(seed=None)[源]

设置随机生成器的种子。

这个函数遵循来自 numpy.random.seed 的 API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.seed.html

set_gradients(val, inputs, grads)[源]

定义相对于输入的值 val 的梯度

sign(a)[源]

返回一个元素逐个指示一个数字的符号。

此函数遵循来自 numpy.sign 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.sign.html

solve(a, b)[源]

求解线性矩阵方程或线性标量方程组。

此函数遵循来自 numpy.linalg.solve 的 API。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.solve.html

sort(a, axis=-1)[源]

返回一个排序后的张量副本。

此函数遵循来自 numpy.sort 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.sort.html

sort2(a, axis=-1)[源]

返回排序后的数组和排序数组的索引

查看: https://pytorch.org/docs/stable/generated/torch.sort.html

sqrt(a)[源]

返回张量的非负平方根,逐元素进行。

此函数遵循来自 numpy.sqrt 的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.sqrt.html

sqrtm(a)[源]

计算矩阵的平方根。 需要输入对称的半正定。

这个函数遵循scipy.linalg.sqrtm的API,允许批处理。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.sqrtm.html

squeeze(a, axis=None)[源]

从a中移除长度为一的轴。

此函数遵循来自 numpy.squeeze 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.squeeze.html

stack(arrays, axis=0)[源]

在新的维度上连接一系列张量。

此函数遵循来自 numpy.stack 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.stack.html

std(a, axis=None)[源]

计算给定维度上张量的标准差。

此函数遵循来自 numpy.std 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.std.html

sum(a, axis=None, keepdims=False)[源]

对给定维度的张量元素求和。

该函数遵循来自 numpy.sum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.sum.html

take_along_axis(arr, indices, axis)[源]

沿给定维度收集张量的元素。

此函数遵循来自 numpy.take_along_axis 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.take_along_axis.html

tile(a, reps)[源]

通过重复给定次数的数字构建数组

见: https://numpy.org/doc/stable/reference/generated/numpy.tile.html

tocsr(a)[源]

将此矩阵转换为压缩稀疏行格式。

此函数遵循来自 scipy.sparse.coo_matrix.tocsr 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.tocsr.html

todense(a)[源]

将稀疏张量转换为密集张量。

此函数遵循来自 scipy.sparse.csr_matrix.toarray 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.toarray.html

trace(a)[源]

返回数组沿对角线的和。

这个函数遵循来自 numpy.trace 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.trace.html

transpose(a, axes=None)[源]

返回一个张量,该张量是a的转置版本。给定的维度dim0和dim1被交换。

见: https://numpy.org/doc/stable/reference/generated/numpy.transpose.html

unique(a, return_inverse=False)[源]

查找给定张量的唯一元素。

此函数遵循来自 numpy.unique 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.unique.html

where(condition, x=None, y=None)[源]

根据条件从 x 或 y 中返回选定的元素。

此函数遵循来自 numpy.where 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.where.html

zero_pad(a, pad_width, value=0)[源]

用给定的值(默认是0)填充一个张量。

此函数遵循来自 numpy.pad 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.pad.html

zeros(shape, type_as=None)[源]

创建一个满是零的张量。

该函数遵循来自 numpy.zeros 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.zeros.html

class ot.backend.Backend[源]

后端抽象类。 实现: JaxBackend, NumpyBackend, TorchBackend, CupyBackend, TensorflowBackend

  • __name__类属性指的是后端的名称。

  • 变量 __type__ 类属性指的是后端使用的数据结构。

abs(a)[源]

逐元素计算绝对值。

此函数遵循来自 numpy.absolute 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.absolute.html

allclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False)[源]

如果两个数组在容差范围内逐元素相等,则返回 True。

此函数遵循来自 numpy.allclose 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.allclose.html

any(a)[源]

测试沿给定维度的任何张量元素是否评估为真。

此函数遵循来自 numpy.any 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.any.html

arange(stop, start=0, step=1, type_as=None)[源]

返回特定区间内均匀间隔的值。

此函数遵循来自 numpy.arange 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.arange.html

argmax(a, axis=None)[源]

返回张量在给定维度上的最大值的索引。

这个函数遵循来自 numpy.argmax 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.argmax.html

argmin(a, axis=None)[源]

返回张量在给定维度上的最小值的索引。

此函数遵循来自 numpy.argmin 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.argmin.html

argsort(a, axis=None)[源]

返回将张量排序的索引。

此函数遵循来自 numpy.argsort 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.argsort.html

array_equal(a, b)[源]

如果两个数组具有相同的形状和元素,则返回True,否则返回False。

此函数遵循numpy.array_equal的API。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.array_equal.html

assert_same_dtype_device(a, b)[源]

检查两个给定输入是否具有相同的数据类型以及相同的设备

atan2(a, b)[源]

逐元素反正切

见: https://numpy.org/doc/stable/reference/generated/numpy.arctan2.html

bitsize(type_as)[源]

给定张量的数据类型所使用的比特数。

clip(a, a_min, a_max)[源]

限制张量中的值。

此函数遵循numpy.clip的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.clip.html

concatenate(arrays, axis=0)[源]

沿着现有维度连接一系列张量。

此函数遵循来自 numpy.concatenate 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.concatenate.html

coo_matrix(data, rows, cols, shape=None, type_as=None)[源]

创建一个稀疏张量,采用坐标格式。

此函数遵循来自 scipy.sparse.coo_matrix 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.html

copy(a)[源]

返回给定张量的副本。

这个函数遵循来自 numpy.copy 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.copy.html

cumsum(a, axis=None)[源]

返回给定维度上张量元素的累计和。

这个函数遵循来自 numpy.cumsum 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.cumsum.html

det(a)[源]

计算数组的行列式。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.det.html

detach(*arrays)[源]

将张量从计算图中分离

查看: https://pytorch.org/docs/stable/generated/torch.Tensor.detach.html

device_type(type_as)[源]

根据给定张量所在设备返回CPU或GPU。

diag(a, k=0)[源]

提取或构造对角张量。

该函数遵循来自 numpy.diag 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.diag.html

dot(a, b)[源]

返回两个张量的点积。

此函数遵循来自 numpy.dot 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.dot.html

dtype_device(a)[源]

返回给定张量的 dtype 和设备。

eigh(a)[源]

计算对称张量的特征值和特征向量。

此函数遵循来自 scipy.linalg.eigh 的 API。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigh.html

einsum(subscripts, *operands)[源]

对操作数评估爱因斯坦求和约定。

该函数遵循来自 numpy.einsum 的API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.einsum.html

eliminate_zeros(a, threshold=0.0)[源]

从稀疏张量中移除小于给定阈值的条目。

此函数遵循来自 scipy.sparse.csr_matrix.eliminate_zeros 的 API

查看: https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.sparse.csr_matrix.eliminate_zeros.html

exp(a)[源]

逐元素计算指数值。

此函数遵循来自 numpy.exp 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.exp.html

eye(N, M=None, type_as=None)[源]

创建给定大小的单位矩阵。

该函数遵循来自 numpy.eye 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.eye.html

flip(a, axis=None)[源]

沿给定维度反转张量中元素的顺序。

此函数遵循来自 numpy.flip 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.flip.html

floor(a)[源]

返回输入的元素的下限

见: https://numpy.org/doc/stable/reference/generated/numpy.floor.html

from_numpy(*arrays, type_as=None)[源]

创建张量,克隆一个numpy数组,具有给定的精度(默认为输入的精度)和给定的设备(在使用GPU的情况下)

full(shape, fill_value, type_as=None)[源]

创建一个具有给定形状的张量,并用给定值填充。

该函数遵循来自 numpy.full 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.full.html

inv(a)[源]

计算矩阵的逆。

此函数遵循来自 scipy.linalg.inv 的 API。

请查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.inv.html

is_floating_point(a)[源]

返回输入是否由浮点数组成

isfinite(a)[源]

逐元素测试有限性(非无限和非数字)。

该函数遵循来自 numpy.isfinite 的API。

查看: https://numpy.org/doc/stable/reference/generated/numpy.isfinite.html

isinf(a)[源]

逐元素测试正无穷大或负无穷大,并返回布尔张量作为结果。

此函数遵循来自 numpy.isinf 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.isinf.html

isnan(a)[源]

逐元素测试是否为NaN,并将结果返回为布尔张量。

这个函数遵循来自 numpy.isnan 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.isnan.html

issparse(a)[源]

检查输入张量是否为稀疏张量。

此函数遵循来自 scipy.sparse.issparse 的API

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.issparse.html

kl_div(p, q, mass=False, eps=1e-16)[源]

计算(广义)Kullback-Leibler散度。

此函数遵循来自 scipy.stats.entropy 的 API。

参数 eps 用于避免数值错误,并添加在日志中。

\[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\]

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.entropy.html

linspace(start, stop, num, type_as=None)[源]

在给定区间内返回指定数量的均匀间隔的值。

此函数遵循来自 numpy.linspace 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.linspace.html

log(a)[源]

逐元素计算自然对数。

该函数遵循来自 numpy.log 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.log.html

logsumexp(a, axis=None)[源]

计算输入元素指数和的对数。

此函数遵循来自 scipy.special.logsumexp 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.logsumexp.html

matmul(a, b)[源]

两个数组的矩阵乘积。

见: https://numpy.org/doc/stable/reference/generated/numpy.matmul.html#numpy.matmul

max(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

此函数遵循来自 numpy.amax 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.amax.html

maximum(a, b)[源]

返回数组元素的逐元素最大值。

此函数遵循来自 numpy.maximum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.maximum.html

mean(a, axis=None)[源]

计算张量沿给定维度的算术平均值。

此函数遵循来自 numpy.mean 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.mean.html

median(a, axis=None)[源]

计算张量在给定维度上的中位数。

此函数遵循来自 numpy.median 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.median.html

meshgrid(a, b)[源]

从坐标向量返回坐标矩阵(Numpy 约定)。

该函数遵循numpy.meshgrid的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.meshgrid.html

min(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

这个函数遵循来自 numpy.amin 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.amin.html

minimum(a, b)[源]

返回数组元素的逐元素最小值。

该函数遵循来自 numpy.minimum 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.minimum.html

nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None)[源]

将NaN替换为零,将无穷大替换为大型有限数字或用户定义的数字。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.nan_to_num.html#numpy.nan_to_num

norm(a, axis=None, keepdims=False)[源]

计算矩阵的弗罗贝尼乌斯范数。

此函数遵循来自 numpy.linalg.norm 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.norm.html

ones(shape, type_as=None)[源]

创建一个全为一的张量。

此函数遵循来自 numpy.ones 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.ones.html

outer(a, b)[源]

计算两个向量之间的外积。

此函数遵循来自 numpy.outer 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.outer.html

power(a, exponents)[源]

第一个张量的元素逐个提升到第二个张量的幂。

该函数遵循来自 numpy.power 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.power.html

prod(a, axis=None)[源]

返回所有元素的乘积。

查看: https://numpy.org/doc/stable/reference/generated/numpy.prod.html

qr(a)[源]

返回QR分解

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.qr.html

rand(*size, type_as=None)[源]

生成均匀随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

randn(*size, type_as=None)[源]

生成正态高斯随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

repeat(a, repeats, axis=None)[源]

重复张量的元素。

此函数遵循来自 numpy.repeat 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.repeat.html

reshape(a, shape)[源]

不改变数据的情况下,给张量赋予新的形状。

该函数遵循来自 numpy.reshape 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.reshape.html

searchsorted(a, v, side='left')[源]

找到应该插入元素以保持给定张量中的顺序的索引。

此函数遵循来自 numpy.searchsorted 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.searchsorted.html

seed(seed=None)[源]

设置随机生成器的种子。

这个函数遵循来自 numpy.random.seed 的 API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.seed.html

set_gradients(val, inputs, grads)[源]

定义相对于输入的值 val 的梯度

sign(a)[源]

返回一个元素逐个指示一个数字的符号。

此函数遵循来自 numpy.sign 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.sign.html

solve(a, b)[源]

求解线性矩阵方程或线性标量方程组。

此函数遵循来自 numpy.linalg.solve 的 API。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.solve.html

sort(a, axis=-1)[源]

返回一个排序后的张量副本。

此函数遵循来自 numpy.sort 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.sort.html

sort2(a, axis=None)[源]

返回排序后的数组和排序数组的索引

查看: https://pytorch.org/docs/stable/generated/torch.sort.html

sqrt(a)[源]

返回张量的非负平方根,逐元素进行。

此函数遵循来自 numpy.sqrt 的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.sqrt.html

sqrtm(a)[源]

计算矩阵的平方根。 需要输入对称的半正定。

这个函数遵循scipy.linalg.sqrtm的API,允许批处理。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.sqrtm.html

squeeze(a, axis=None)[源]

从a中移除长度为一的轴。

此函数遵循来自 numpy.squeeze 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.squeeze.html

stack(arrays, axis=0)[源]

在新的维度上连接一系列张量。

此函数遵循来自 numpy.stack 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.stack.html

std(a, axis=None)[源]

计算给定维度上张量的标准差。

此函数遵循来自 numpy.std 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.std.html

sum(a, axis=None, keepdims=False)[源]

对给定维度的张量元素求和。

该函数遵循来自 numpy.sum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.sum.html

take_along_axis(arr, indices, axis)[源]

沿给定维度收集张量的元素。

此函数遵循来自 numpy.take_along_axis 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.take_along_axis.html

tile(a, reps)[源]

通过重复给定次数的数字构建数组

见: https://numpy.org/doc/stable/reference/generated/numpy.tile.html

to_numpy(*arrays)[源]

返回张量的numpy版本

tocsr(a)[源]

将此矩阵转换为压缩稀疏行格式。

此函数遵循来自 scipy.sparse.coo_matrix.tocsr 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.tocsr.html

todense(a)[源]

将稀疏张量转换为密集张量。

此函数遵循来自 scipy.sparse.csr_matrix.toarray 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.toarray.html

trace(a)[源]

返回数组沿对角线的和。

这个函数遵循来自 numpy.trace 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.trace.html

transpose(a, axes=None)[源]

返回一个张量,该张量是a的转置版本。给定的维度dim0和dim1被交换。

见: https://numpy.org/doc/stable/reference/generated/numpy.transpose.html

unique(a, return_inverse=False)[源]

查找给定张量的唯一元素。

此函数遵循来自 numpy.unique 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.unique.html

where(condition, x, y)[源]

根据条件从 x 或 y 中返回选定的元素。

此函数遵循来自 numpy.where 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.where.html

zero_pad(a, pad_width, value=0)[源]

用给定的值(默认是0)填充一个张量。

此函数遵循来自 numpy.pad 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.pad.html

zeros(shape, type_as=None)[源]

创建一个满是零的张量。

该函数遵循来自 numpy.zeros 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.zeros.html

class ot.backend.CupyBackend[源]

CuPy 后端的实现

  • __name__ 是 “cupy”

  • __type__ 是 cp.ndarray

abs(a)[源]

逐元素计算绝对值。

此函数遵循来自 numpy.absolute 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.absolute.html

allclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False)[源]

如果两个数组在容差范围内逐元素相等,则返回 True。

此函数遵循来自 numpy.allclose 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.allclose.html

any(a)[源]

测试沿给定维度的任何张量元素是否评估为真。

此函数遵循来自 numpy.any 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.any.html

arange(stop, start=0, step=1, type_as=None)[源]

返回特定区间内均匀间隔的值。

此函数遵循来自 numpy.arange 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.arange.html

argmax(a, axis=None)[源]

返回张量在给定维度上的最大值的索引。

这个函数遵循来自 numpy.argmax 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.argmax.html

argmin(a, axis=None)[源]

返回张量在给定维度上的最小值的索引。

此函数遵循来自 numpy.argmin 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.argmin.html

argsort(a, axis=-1)[源]

返回将张量排序的索引。

此函数遵循来自 numpy.argsort 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.argsort.html

array_equal(a, b)[源]

如果两个数组具有相同的形状和元素,则返回True,否则返回False。

此函数遵循numpy.array_equal的API。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.array_equal.html

assert_same_dtype_device(a, b)[源]

检查两个给定输入是否具有相同的数据类型以及相同的设备

atan2(a, b)[源]

逐元素反正切

见: https://numpy.org/doc/stable/reference/generated/numpy.arctan2.html

bitsize(type_as)[源]

给定张量的数据类型所使用的比特数。

clip(a, a_min, a_max)[源]

限制张量中的值。

此函数遵循numpy.clip的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.clip.html

concatenate(arrays, axis=0)[源]

沿着现有维度连接一系列张量。

此函数遵循来自 numpy.concatenate 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.concatenate.html

coo_matrix(data, rows, cols, shape=None, type_as=None)[源]

创建一个稀疏张量,采用坐标格式。

此函数遵循来自 scipy.sparse.coo_matrix 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.html

copy(a)[源]

返回给定张量的副本。

这个函数遵循来自 numpy.copy 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.copy.html

cumsum(a, axis=None)[源]

返回给定维度上张量元素的累计和。

这个函数遵循来自 numpy.cumsum 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.cumsum.html

det(x)[源]

计算数组的行列式。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.det.html

device_type(type_as)[源]

根据给定张量所在设备返回CPU或GPU。

diag(a, k=0)[源]

提取或构造对角张量。

该函数遵循来自 numpy.diag 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.diag.html

dot(a, b)[源]

返回两个张量的点积。

此函数遵循来自 numpy.dot 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.dot.html

dtype_device(a)[源]

返回给定张量的 dtype 和设备。

eigh(a)[源]

计算对称张量的特征值和特征向量。

此函数遵循来自 scipy.linalg.eigh 的 API。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigh.html

einsum(subscripts, *operands)[源]

对操作数评估爱因斯坦求和约定。

该函数遵循来自 numpy.einsum 的API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.einsum.html

eliminate_zeros(a, threshold=0.0)[源]

从稀疏张量中移除小于给定阈值的条目。

此函数遵循来自 scipy.sparse.csr_matrix.eliminate_zeros 的 API

查看: https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.sparse.csr_matrix.eliminate_zeros.html

exp(a)[源]

逐元素计算指数值。

此函数遵循来自 numpy.exp 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.exp.html

eye(N, M=None, type_as=None)[源]

创建给定大小的单位矩阵。

该函数遵循来自 numpy.eye 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.eye.html

flip(a, axis=None)[源]

沿给定维度反转张量中元素的顺序。

此函数遵循来自 numpy.flip 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.flip.html

floor(a)[源]

返回输入的元素的下限

见: https://numpy.org/doc/stable/reference/generated/numpy.floor.html

full(shape, fill_value, type_as=None)[源]

创建一个具有给定形状的张量,并用给定值填充。

该函数遵循来自 numpy.full 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.full.html

inv(a)[源]

计算矩阵的逆。

此函数遵循来自 scipy.linalg.inv 的 API。

请查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.inv.html

is_floating_point(a)[源]

返回输入是否由浮点数组成

isfinite(a)[源]

逐元素测试有限性(非无限和非数字)。

该函数遵循来自 numpy.isfinite 的API。

查看: https://numpy.org/doc/stable/reference/generated/numpy.isfinite.html

isinf(a)[源]

逐元素测试正无穷大或负无穷大,并返回布尔张量作为结果。

此函数遵循来自 numpy.isinf 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.isinf.html

isnan(a)[源]

逐元素测试是否为NaN,并将结果返回为布尔张量。

这个函数遵循来自 numpy.isnan 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.isnan.html

issparse(a)[源]

检查输入张量是否为稀疏张量。

此函数遵循来自 scipy.sparse.issparse 的API

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.issparse.html

kl_div(p, q, mass=False, eps=1e-16)[源]

计算(广义)Kullback-Leibler散度。

此函数遵循来自 scipy.stats.entropy 的 API。

参数 eps 用于避免数值错误,并添加在日志中。

\[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\]

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.entropy.html

linspace(start, stop, num, type_as=None)[源]

在给定区间内返回指定数量的均匀间隔的值。

此函数遵循来自 numpy.linspace 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.linspace.html

log(a)[源]

逐元素计算自然对数。

该函数遵循来自 numpy.log 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.log.html

logsumexp(a, axis=None)[源]

计算输入元素指数和的对数。

此函数遵循来自 scipy.special.logsumexp 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.logsumexp.html

matmul(a, b)[源]

两个数组的矩阵乘积。

见: https://numpy.org/doc/stable/reference/generated/numpy.matmul.html#numpy.matmul

max(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

此函数遵循来自 numpy.amax 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.amax.html

maximum(a, b)[源]

返回数组元素的逐元素最大值。

此函数遵循来自 numpy.maximum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.maximum.html

mean(a, axis=None)[源]

计算张量沿给定维度的算术平均值。

此函数遵循来自 numpy.mean 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.mean.html

median(a, axis=None)[源]

计算张量在给定维度上的中位数。

此函数遵循来自 numpy.median 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.median.html

meshgrid(a, b)[源]

从坐标向量返回坐标矩阵(Numpy 约定)。

该函数遵循numpy.meshgrid的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.meshgrid.html

min(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

这个函数遵循来自 numpy.amin 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.amin.html

minimum(a, b)[源]

返回数组元素的逐元素最小值。

该函数遵循来自 numpy.minimum 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.minimum.html

nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None)[源]

将NaN替换为零,将无穷大替换为大型有限数字或用户定义的数字。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.nan_to_num.html#numpy.nan_to_num

norm(a, axis=None, keepdims=False)[源]

计算矩阵的弗罗贝尼乌斯范数。

此函数遵循来自 numpy.linalg.norm 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.norm.html

ones(shape, type_as=None)[源]

创建一个全为一的张量。

此函数遵循来自 numpy.ones 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.ones.html

outer(a, b)[源]

计算两个向量之间的外积。

此函数遵循来自 numpy.outer 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.outer.html

power(a, exponents)[源]

第一个张量的元素逐个提升到第二个张量的幂。

该函数遵循来自 numpy.power 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.power.html

prod(a, axis=0)[源]

返回所有元素的乘积。

查看: https://numpy.org/doc/stable/reference/generated/numpy.prod.html

qr(a)[源]

返回QR分解

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.qr.html

rand(*size, type_as=None)[源]

生成均匀随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

randn(*size, type_as=None)[源]

生成正态高斯随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

repeat(a, repeats, axis=None)[源]

重复张量的元素。

此函数遵循来自 numpy.repeat 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.repeat.html

reshape(a, shape)[源]

不改变数据的情况下,给张量赋予新的形状。

该函数遵循来自 numpy.reshape 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.reshape.html

searchsorted(a, v, side='left')[源]

找到应该插入元素以保持给定张量中的顺序的索引。

此函数遵循来自 numpy.searchsorted 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.searchsorted.html

seed(seed=None)[源]

设置随机生成器的种子。

这个函数遵循来自 numpy.random.seed 的 API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.seed.html

set_gradients(val, inputs, grads)[源]

定义相对于输入的值 val 的梯度

sign(a)[源]

返回一个元素逐个指示一个数字的符号。

此函数遵循来自 numpy.sign 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.sign.html

solve(a, b)[源]

求解线性矩阵方程或线性标量方程组。

此函数遵循来自 numpy.linalg.solve 的 API。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.solve.html

sort(a, axis=-1)[源]

返回一个排序后的张量副本。

此函数遵循来自 numpy.sort 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.sort.html

sort2(a, axis=-1)[源]

返回排序后的数组和排序数组的索引

查看: https://pytorch.org/docs/stable/generated/torch.sort.html

sqrt(a)[源]

返回张量的非负平方根,逐元素进行。

此函数遵循来自 numpy.sqrt 的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.sqrt.html

sqrtm(a)[源]

计算矩阵的平方根。 需要输入对称的半正定。

这个函数遵循scipy.linalg.sqrtm的API,允许批处理。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.sqrtm.html

squeeze(a, axis=None)[源]

从a中移除长度为一的轴。

此函数遵循来自 numpy.squeeze 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.squeeze.html

stack(arrays, axis=0)[源]

在新的维度上连接一系列张量。

此函数遵循来自 numpy.stack 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.stack.html

std(a, axis=None)[源]

计算给定维度上张量的标准差。

此函数遵循来自 numpy.std 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.std.html

sum(a, axis=None, keepdims=False)[源]

对给定维度的张量元素求和。

该函数遵循来自 numpy.sum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.sum.html

take_along_axis(arr, indices, axis)[源]

沿给定维度收集张量的元素。

此函数遵循来自 numpy.take_along_axis 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.take_along_axis.html

tile(a, reps)[源]

通过重复给定次数的数字构建数组

见: https://numpy.org/doc/stable/reference/generated/numpy.tile.html

tocsr(a)[源]

将此矩阵转换为压缩稀疏行格式。

此函数遵循来自 scipy.sparse.coo_matrix.tocsr 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.tocsr.html

todense(a)[源]

将稀疏张量转换为密集张量。

此函数遵循来自 scipy.sparse.csr_matrix.toarray 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.toarray.html

trace(a)[源]

返回数组沿对角线的和。

这个函数遵循来自 numpy.trace 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.trace.html

transpose(a, axes=None)[源]

返回一个张量,该张量是a的转置版本。给定的维度dim0和dim1被交换。

见: https://numpy.org/doc/stable/reference/generated/numpy.transpose.html

unique(a, return_inverse=False)[源]

查找给定张量的唯一元素。

此函数遵循来自 numpy.unique 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.unique.html

where(condition, x=None, y=None)[源]

根据条件从 x 或 y 中返回选定的元素。

此函数遵循来自 numpy.where 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.where.html

zero_pad(a, pad_width, value=0)[源]

用给定的值(默认是0)填充一个张量。

此函数遵循来自 numpy.pad 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.pad.html

zeros(shape, type_as=None)[源]

创建一个满是零的张量。

该函数遵循来自 numpy.zeros 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.zeros.html

class ot.backend.JaxBackend[源]

后端的JAX实现

  • __name__ 是 “jax”

  • __type__ 是 jax.numpy.ndarray

abs(a)[源]

逐元素计算绝对值。

此函数遵循来自 numpy.absolute 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.absolute.html

allclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False)[源]

如果两个数组在容差范围内逐元素相等,则返回 True。

此函数遵循来自 numpy.allclose 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.allclose.html

any(a)[源]

测试沿给定维度的任何张量元素是否评估为真。

此函数遵循来自 numpy.any 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.any.html

arange(stop, start=0, step=1, type_as=None)[源]

返回特定区间内均匀间隔的值。

此函数遵循来自 numpy.arange 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.arange.html

argmax(a, axis=None)[源]

返回张量在给定维度上的最大值的索引。

这个函数遵循来自 numpy.argmax 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.argmax.html

argmin(a, axis=None)[源]

返回张量在给定维度上的最小值的索引。

此函数遵循来自 numpy.argmin 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.argmin.html

argsort(a, axis=-1)[源]

返回将张量排序的索引。

此函数遵循来自 numpy.argsort 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.argsort.html

array_equal(a, b)[源]

如果两个数组具有相同的形状和元素,则返回True,否则返回False。

此函数遵循numpy.array_equal的API。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.array_equal.html

assert_same_dtype_device(a, b)[源]

检查两个给定输入是否具有相同的数据类型以及相同的设备

atan2(a, b)[源]

逐元素反正切

见: https://numpy.org/doc/stable/reference/generated/numpy.arctan2.html

bitsize(type_as)[源]

给定张量的数据类型所使用的比特数。

clip(a, a_min, a_max)[源]

限制张量中的值。

此函数遵循numpy.clip的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.clip.html

concatenate(arrays, axis=0)[源]

沿着现有维度连接一系列张量。

此函数遵循来自 numpy.concatenate 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.concatenate.html

coo_matrix(data, rows, cols, shape=None, type_as=None)[源]

创建一个稀疏张量,采用坐标格式。

此函数遵循来自 scipy.sparse.coo_matrix 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.html

copy(a)[源]

返回给定张量的副本。

这个函数遵循来自 numpy.copy 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.copy.html

cumsum(a, axis=None)[源]

返回给定维度上张量元素的累计和。

这个函数遵循来自 numpy.cumsum 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.cumsum.html

det(x)[源]

计算数组的行列式。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.det.html

device_type(type_as)[源]

根据给定张量所在设备返回CPU或GPU。

diag(a, k=0)[源]

提取或构造对角张量。

该函数遵循来自 numpy.diag 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.diag.html

dot(a, b)[源]

返回两个张量的点积。

此函数遵循来自 numpy.dot 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.dot.html

dtype_device(a)[源]

返回给定张量的 dtype 和设备。

eigh(a)[源]

计算对称张量的特征值和特征向量。

此函数遵循来自 scipy.linalg.eigh 的 API。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigh.html

einsum(subscripts, *operands)[源]

对操作数评估爱因斯坦求和约定。

该函数遵循来自 numpy.einsum 的API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.einsum.html

eliminate_zeros(a, threshold=0.0)[源]

从稀疏张量中移除小于给定阈值的条目。

此函数遵循来自 scipy.sparse.csr_matrix.eliminate_zeros 的 API

查看: https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.sparse.csr_matrix.eliminate_zeros.html

exp(a)[源]

逐元素计算指数值。

此函数遵循来自 numpy.exp 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.exp.html

eye(N, M=None, type_as=None)[源]

创建给定大小的单位矩阵。

该函数遵循来自 numpy.eye 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.eye.html

flip(a, axis=None)[源]

沿给定维度反转张量中元素的顺序。

此函数遵循来自 numpy.flip 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.flip.html

floor(a)[源]

返回输入的元素的下限

见: https://numpy.org/doc/stable/reference/generated/numpy.floor.html

full(shape, fill_value, type_as=None)[源]

创建一个具有给定形状的张量,并用给定值填充。

该函数遵循来自 numpy.full 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.full.html

inv(a)[源]

计算矩阵的逆。

此函数遵循来自 scipy.linalg.inv 的 API。

请查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.inv.html

is_floating_point(a)[源]

返回输入是否由浮点数组成

isfinite(a)[源]

逐元素测试有限性(非无限和非数字)。

该函数遵循来自 numpy.isfinite 的API。

查看: https://numpy.org/doc/stable/reference/generated/numpy.isfinite.html

isinf(a)[源]

逐元素测试正无穷大或负无穷大,并返回布尔张量作为结果。

此函数遵循来自 numpy.isinf 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.isinf.html

isnan(a)[源]

逐元素测试是否为NaN,并将结果返回为布尔张量。

这个函数遵循来自 numpy.isnan 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.isnan.html

issparse(a)[源]

检查输入张量是否为稀疏张量。

此函数遵循来自 scipy.sparse.issparse 的API

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.issparse.html

kl_div(p, q, mass=False, eps=1e-16)[源]

计算(广义)Kullback-Leibler散度。

此函数遵循来自 scipy.stats.entropy 的 API。

参数 eps 用于避免数值错误,并添加在日志中。

\[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\]

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.entropy.html

linspace(start, stop, num, type_as=None)[源]

在给定区间内返回指定数量的均匀间隔的值。

此函数遵循来自 numpy.linspace 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.linspace.html

log(a)[源]

逐元素计算自然对数。

该函数遵循来自 numpy.log 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.log.html

logsumexp(a, axis=None)[源]

计算输入元素指数和的对数。

此函数遵循来自 scipy.special.logsumexp 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.logsumexp.html

matmul(a, b)[源]

两个数组的矩阵乘积。

见: https://numpy.org/doc/stable/reference/generated/numpy.matmul.html#numpy.matmul

max(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

此函数遵循来自 numpy.amax 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.amax.html

maximum(a, b)[源]

返回数组元素的逐元素最大值。

此函数遵循来自 numpy.maximum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.maximum.html

mean(a, axis=None)[源]

计算张量沿给定维度的算术平均值。

此函数遵循来自 numpy.mean 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.mean.html

median(a, axis=None)[源]

计算张量在给定维度上的中位数。

此函数遵循来自 numpy.median 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.median.html

meshgrid(a, b)[源]

从坐标向量返回坐标矩阵(Numpy 约定)。

该函数遵循numpy.meshgrid的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.meshgrid.html

min(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

这个函数遵循来自 numpy.amin 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.amin.html

minimum(a, b)[源]

返回数组元素的逐元素最小值。

该函数遵循来自 numpy.minimum 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.minimum.html

nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None)[源]

将NaN替换为零,将无穷大替换为大型有限数字或用户定义的数字。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.nan_to_num.html#numpy.nan_to_num

norm(a, axis=None, keepdims=False)[源]

计算矩阵的弗罗贝尼乌斯范数。

此函数遵循来自 numpy.linalg.norm 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.norm.html

ones(shape, type_as=None)[源]

创建一个全为一的张量。

此函数遵循来自 numpy.ones 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.ones.html

outer(a, b)[源]

计算两个向量之间的外积。

此函数遵循来自 numpy.outer 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.outer.html

power(a, exponents)[源]

第一个张量的元素逐个提升到第二个张量的幂。

该函数遵循来自 numpy.power 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.power.html

prod(a, axis=0)[源]

返回所有元素的乘积。

查看: https://numpy.org/doc/stable/reference/generated/numpy.prod.html

qr(a)[源]

返回QR分解

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.qr.html

rand(*size, type_as=None)[源]

生成均匀随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

randn(*size, type_as=None)[源]

生成正态高斯随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

repeat(a, repeats, axis=None)[源]

重复张量的元素。

此函数遵循来自 numpy.repeat 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.repeat.html

reshape(a, shape)[源]

不改变数据的情况下,给张量赋予新的形状。

该函数遵循来自 numpy.reshape 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.reshape.html

searchsorted(a, v, side='left')[源]

找到应该插入元素以保持给定张量中的顺序的索引。

此函数遵循来自 numpy.searchsorted 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.searchsorted.html

seed(seed=None)[源]

设置随机生成器的种子。

这个函数遵循来自 numpy.random.seed 的 API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.seed.html

set_gradients(val, inputs, grads)[源]

定义相对于输入的值 val 的梯度

sign(a)[源]

返回一个元素逐个指示一个数字的符号。

此函数遵循来自 numpy.sign 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.sign.html

solve(a, b)[源]

求解线性矩阵方程或线性标量方程组。

此函数遵循来自 numpy.linalg.solve 的 API。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.solve.html

sort(a, axis=-1)[源]

返回一个排序后的张量副本。

此函数遵循来自 numpy.sort 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.sort.html

sort2(a, axis=-1)[源]

返回排序后的数组和排序数组的索引

查看: https://pytorch.org/docs/stable/generated/torch.sort.html

sqrt(a)[源]

返回张量的非负平方根,逐元素进行。

此函数遵循来自 numpy.sqrt 的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.sqrt.html

sqrtm(a)[源]

计算矩阵的平方根。 需要输入对称的半正定。

这个函数遵循scipy.linalg.sqrtm的API,允许批处理。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.sqrtm.html

squeeze(a, axis=None)[源]

从a中移除长度为一的轴。

此函数遵循来自 numpy.squeeze 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.squeeze.html

stack(arrays, axis=0)[源]

在新的维度上连接一系列张量。

此函数遵循来自 numpy.stack 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.stack.html

std(a, axis=None)[源]

计算给定维度上张量的标准差。

此函数遵循来自 numpy.std 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.std.html

sum(a, axis=None, keepdims=False)[源]

对给定维度的张量元素求和。

该函数遵循来自 numpy.sum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.sum.html

take_along_axis(arr, indices, axis)[源]

沿给定维度收集张量的元素。

此函数遵循来自 numpy.take_along_axis 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.take_along_axis.html

tile(a, reps)[源]

通过重复给定次数的数字构建数组

见: https://numpy.org/doc/stable/reference/generated/numpy.tile.html

tocsr(a)[源]

将此矩阵转换为压缩稀疏行格式。

此函数遵循来自 scipy.sparse.coo_matrix.tocsr 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.tocsr.html

todense(a)[源]

将稀疏张量转换为密集张量。

此函数遵循来自 scipy.sparse.csr_matrix.toarray 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.toarray.html

trace(a)[源]

返回数组沿对角线的和。

这个函数遵循来自 numpy.trace 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.trace.html

transpose(a, axes=None)[源]

返回一个张量,该张量是a的转置版本。给定的维度dim0和dim1被交换。

见: https://numpy.org/doc/stable/reference/generated/numpy.transpose.html

unique(a, return_inverse=False)[源]

查找给定张量的唯一元素。

此函数遵循来自 numpy.unique 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.unique.html

where(condition, x=None, y=None)[源]

根据条件从 x 或 y 中返回选定的元素。

此函数遵循来自 numpy.where 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.where.html

zero_pad(a, pad_width, value=0)[源]

用给定的值(默认是0)填充一个张量。

此函数遵循来自 numpy.pad 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.pad.html

zeros(shape, type_as=None)[源]

创建一个满是零的张量。

该函数遵循来自 numpy.zeros 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.zeros.html

class ot.backend.NumpyBackend[源]

NumPy 后端实现

  • __name__ 是 “numpy”

  • __type__ 是 np.ndarray

abs(a)[源]

逐元素计算绝对值。

此函数遵循来自 numpy.absolute 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.absolute.html

allclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False)[源]

如果两个数组在容差范围内逐元素相等,则返回 True。

此函数遵循来自 numpy.allclose 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.allclose.html

any(a)[源]

测试沿给定维度的任何张量元素是否评估为真。

此函数遵循来自 numpy.any 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.any.html

arange(stop, start=0, step=1, type_as=None)[源]

返回特定区间内均匀间隔的值。

此函数遵循来自 numpy.arange 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.arange.html

argmax(a, axis=None)[源]

返回张量在给定维度上的最大值的索引。

这个函数遵循来自 numpy.argmax 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.argmax.html

argmin(a, axis=None)[源]

返回张量在给定维度上的最小值的索引。

此函数遵循来自 numpy.argmin 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.argmin.html

argsort(a, axis=-1)[源]

返回将张量排序的索引。

此函数遵循来自 numpy.argsort 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.argsort.html

array_equal(a, b)[源]

如果两个数组具有相同的形状和元素,则返回True,否则返回False。

此函数遵循numpy.array_equal的API。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.array_equal.html

assert_same_dtype_device(a, b)[源]

检查两个给定输入是否具有相同的数据类型以及相同的设备

atan2(a, b)[源]

逐元素反正切

见: https://numpy.org/doc/stable/reference/generated/numpy.arctan2.html

bitsize(type_as)[源]

给定张量的数据类型所使用的比特数。

clip(a, a_min, a_max)[源]

限制张量中的值。

此函数遵循numpy.clip的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.clip.html

concatenate(arrays, axis=0)[源]

沿着现有维度连接一系列张量。

此函数遵循来自 numpy.concatenate 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.concatenate.html

coo_matrix(data, rows, cols, shape=None, type_as=None)[源]

创建一个稀疏张量,采用坐标格式。

此函数遵循来自 scipy.sparse.coo_matrix 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.html

copy(a)[源]

返回给定张量的副本。

这个函数遵循来自 numpy.copy 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.copy.html

cumsum(a, axis=None)[源]

返回给定维度上张量元素的累计和。

这个函数遵循来自 numpy.cumsum 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.cumsum.html

det(a)[源]

计算数组的行列式。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.det.html

device_type(type_as)[源]

根据给定张量所在设备返回CPU或GPU。

diag(a, k=0)[源]

提取或构造对角张量。

该函数遵循来自 numpy.diag 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.diag.html

dot(a, b)[源]

返回两个张量的点积。

此函数遵循来自 numpy.dot 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.dot.html

dtype_device(a)[源]

返回给定张量的 dtype 和设备。

eigh(a)[源]

计算对称张量的特征值和特征向量。

此函数遵循来自 scipy.linalg.eigh 的 API。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigh.html

einsum(subscripts, *operands)[源]

对操作数评估爱因斯坦求和约定。

该函数遵循来自 numpy.einsum 的API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.einsum.html

eliminate_zeros(a, threshold=0.0)[源]

从稀疏张量中移除小于给定阈值的条目。

此函数遵循来自 scipy.sparse.csr_matrix.eliminate_zeros 的 API

查看: https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.sparse.csr_matrix.eliminate_zeros.html

exp(a)[源]

逐元素计算指数值。

此函数遵循来自 numpy.exp 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.exp.html

eye(N, M=None, type_as=None)[源]

创建给定大小的单位矩阵。

该函数遵循来自 numpy.eye 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.eye.html

flip(a, axis=None)[源]

沿给定维度反转张量中元素的顺序。

此函数遵循来自 numpy.flip 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.flip.html

floor(a)[源]

返回输入的元素的下限

见: https://numpy.org/doc/stable/reference/generated/numpy.floor.html

full(shape, fill_value, type_as=None)[源]

创建一个具有给定形状的张量,并用给定值填充。

该函数遵循来自 numpy.full 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.full.html

inv(a)[源]

计算矩阵的逆。

此函数遵循来自 scipy.linalg.inv 的 API。

请查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.inv.html

is_floating_point(a)[源]

返回输入是否由浮点数组成

isfinite(a)[源]

逐元素测试有限性(非无限和非数字)。

该函数遵循来自 numpy.isfinite 的API。

查看: https://numpy.org/doc/stable/reference/generated/numpy.isfinite.html

isinf(a)[源]

逐元素测试正无穷大或负无穷大,并返回布尔张量作为结果。

此函数遵循来自 numpy.isinf 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.isinf.html

isnan(a)[源]

逐元素测试是否为NaN,并将结果返回为布尔张量。

这个函数遵循来自 numpy.isnan 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.isnan.html

issparse(a)[源]

检查输入张量是否为稀疏张量。

此函数遵循来自 scipy.sparse.issparse 的API

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.issparse.html

kl_div(p, q, mass=False, eps=1e-16)[源]

计算(广义)Kullback-Leibler散度。

此函数遵循来自 scipy.stats.entropy 的 API。

参数 eps 用于避免数值错误,并添加在日志中。

\[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\]

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.entropy.html

linspace(start, stop, num, type_as=None)[源]

在给定区间内返回指定数量的均匀间隔的值。

此函数遵循来自 numpy.linspace 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.linspace.html

log(a)[源]

逐元素计算自然对数。

该函数遵循来自 numpy.log 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.log.html

logsumexp(a, axis=None)[源]

计算输入元素指数和的对数。

此函数遵循来自 scipy.special.logsumexp 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.logsumexp.html

matmul(a, b)[源]

两个数组的矩阵乘积。

见: https://numpy.org/doc/stable/reference/generated/numpy.matmul.html#numpy.matmul

max(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

此函数遵循来自 numpy.amax 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.amax.html

maximum(a, b)[源]

返回数组元素的逐元素最大值。

此函数遵循来自 numpy.maximum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.maximum.html

mean(a, axis=None)[源]

计算张量沿给定维度的算术平均值。

此函数遵循来自 numpy.mean 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.mean.html

median(a, axis=None)[源]

计算张量在给定维度上的中位数。

此函数遵循来自 numpy.median 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.median.html

meshgrid(a, b)[源]

从坐标向量返回坐标矩阵(Numpy 约定)。

该函数遵循numpy.meshgrid的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.meshgrid.html

min(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

这个函数遵循来自 numpy.amin 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.amin.html

minimum(a, b)[源]

返回数组元素的逐元素最小值。

该函数遵循来自 numpy.minimum 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.minimum.html

nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None)[源]

将NaN替换为零,将无穷大替换为大型有限数字或用户定义的数字。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.nan_to_num.html#numpy.nan_to_num

norm(a, axis=None, keepdims=False)[源]

计算矩阵的弗罗贝尼乌斯范数。

此函数遵循来自 numpy.linalg.norm 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.norm.html

ones(shape, type_as=None)[源]

创建一个全为一的张量。

此函数遵循来自 numpy.ones 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.ones.html

outer(a, b)[源]

计算两个向量之间的外积。

此函数遵循来自 numpy.outer 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.outer.html

power(a, exponents)[源]

第一个张量的元素逐个提升到第二个张量的幂。

该函数遵循来自 numpy.power 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.power.html

prod(a, axis=0)[源]

返回所有元素的乘积。

查看: https://numpy.org/doc/stable/reference/generated/numpy.prod.html

qr(a)[源]

返回QR分解

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.qr.html

rand(*size, type_as=None)[源]

生成均匀随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

randn(*size, type_as=None)[源]

生成正态高斯随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

repeat(a, repeats, axis=None)[源]

重复张量的元素。

此函数遵循来自 numpy.repeat 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.repeat.html

reshape(a, shape)[源]

不改变数据的情况下,给张量赋予新的形状。

该函数遵循来自 numpy.reshape 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.reshape.html

searchsorted(a, v, side='left')[源]

找到应该插入元素以保持给定张量中的顺序的索引。

此函数遵循来自 numpy.searchsorted 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.searchsorted.html

seed(seed=None)[源]

设置随机生成器的种子。

这个函数遵循来自 numpy.random.seed 的 API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.seed.html

set_gradients(val, inputs, grads)[源]

定义相对于输入的值 val 的梯度

sign(a)[源]

返回一个元素逐个指示一个数字的符号。

此函数遵循来自 numpy.sign 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.sign.html

solve(a, b)[源]

求解线性矩阵方程或线性标量方程组。

此函数遵循来自 numpy.linalg.solve 的 API。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.solve.html

sort(a, axis=-1)[源]

返回一个排序后的张量副本。

此函数遵循来自 numpy.sort 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.sort.html

sort2(a, axis=-1)[源]

返回排序后的数组和排序数组的索引

查看: https://pytorch.org/docs/stable/generated/torch.sort.html

sqrt(a)[源]

返回张量的非负平方根,逐元素进行。

此函数遵循来自 numpy.sqrt 的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.sqrt.html

sqrtm(a)[源]

计算矩阵的平方根。 需要输入对称的半正定。

这个函数遵循scipy.linalg.sqrtm的API,允许批处理。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.sqrtm.html

squeeze(a, axis=None)[源]

从a中移除长度为一的轴。

此函数遵循来自 numpy.squeeze 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.squeeze.html

stack(arrays, axis=0)[源]

在新的维度上连接一系列张量。

此函数遵循来自 numpy.stack 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.stack.html

std(a, axis=None)[源]

计算给定维度上张量的标准差。

此函数遵循来自 numpy.std 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.std.html

sum(a, axis=None, keepdims=False)[源]

对给定维度的张量元素求和。

该函数遵循来自 numpy.sum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.sum.html

take_along_axis(arr, indices, axis)[源]

沿给定维度收集张量的元素。

此函数遵循来自 numpy.take_along_axis 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.take_along_axis.html

tile(a, reps)[源]

通过重复给定次数的数字构建数组

见: https://numpy.org/doc/stable/reference/generated/numpy.tile.html

tocsr(a)[源]

将此矩阵转换为压缩稀疏行格式。

此函数遵循来自 scipy.sparse.coo_matrix.tocsr 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.tocsr.html

todense(a)[源]

将稀疏张量转换为密集张量。

此函数遵循来自 scipy.sparse.csr_matrix.toarray 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.toarray.html

trace(a)[源]

返回数组沿对角线的和。

这个函数遵循来自 numpy.trace 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.trace.html

transpose(a, axes=None)[源]

返回一个张量,该张量是a的转置版本。给定的维度dim0和dim1被交换。

见: https://numpy.org/doc/stable/reference/generated/numpy.transpose.html

unique(a, return_inverse=False)[源]

查找给定张量的唯一元素。

此函数遵循来自 numpy.unique 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.unique.html

where(condition, x=None, y=None)[源]

根据条件从 x 或 y 中返回选定的元素。

此函数遵循来自 numpy.where 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.where.html

zero_pad(a, pad_width, value=0)[源]

用给定的值(默认是0)填充一个张量。

此函数遵循来自 numpy.pad 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.pad.html

zeros(shape, type_as=None)[源]

创建一个满是零的张量。

该函数遵循来自 numpy.zeros 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.zeros.html

class ot.backend.TensorflowBackend[源]
abs(a)[源]

逐元素计算绝对值。

此函数遵循来自 numpy.absolute 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.absolute.html

allclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False)[源]

如果两个数组在容差范围内逐元素相等,则返回 True。

此函数遵循来自 numpy.allclose 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.allclose.html

any(a)[源]

测试沿给定维度的任何张量元素是否评估为真。

此函数遵循来自 numpy.any 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.any.html

arange(stop, start=0, step=1, type_as=None)[源]

返回特定区间内均匀间隔的值。

此函数遵循来自 numpy.arange 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.arange.html

argmax(a, axis=None)[源]

返回张量在给定维度上的最大值的索引。

这个函数遵循来自 numpy.argmax 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.argmax.html

argmin(a, axis=None)[源]

返回张量在给定维度上的最小值的索引。

此函数遵循来自 numpy.argmin 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.argmin.html

argsort(a, axis=-1)[源]

返回将张量排序的索引。

此函数遵循来自 numpy.argsort 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.argsort.html

array_equal(a, b)[源]

如果两个数组具有相同的形状和元素,则返回True,否则返回False。

此函数遵循numpy.array_equal的API。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.array_equal.html

assert_same_dtype_device(a, b)[源]

检查两个给定输入是否具有相同的数据类型以及相同的设备

atan2(a, b)[源]

逐元素反正切

见: https://numpy.org/doc/stable/reference/generated/numpy.arctan2.html

bitsize(type_as)[源]

给定张量的数据类型所使用的比特数。

clip(a, a_min, a_max)[源]

限制张量中的值。

此函数遵循numpy.clip的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.clip.html

concatenate(arrays, axis=0)[源]

沿着现有维度连接一系列张量。

此函数遵循来自 numpy.concatenate 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.concatenate.html

coo_matrix(data, rows, cols, shape=None, type_as=None)[源]

创建一个稀疏张量,采用坐标格式。

此函数遵循来自 scipy.sparse.coo_matrix 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.html

copy(a)[源]

返回给定张量的副本。

这个函数遵循来自 numpy.copy 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.copy.html

cumsum(a, axis=None)[源]

返回给定维度上张量元素的累计和。

这个函数遵循来自 numpy.cumsum 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.cumsum.html

det(x)[源]

计算数组的行列式。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.det.html

device_type(type_as)[源]

根据给定张量所在设备返回CPU或GPU。

diag(a, k=0)[源]

提取或构造对角张量。

该函数遵循来自 numpy.diag 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.diag.html

dot(a, b)[源]

返回两个张量的点积。

此函数遵循来自 numpy.dot 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.dot.html

dtype_device(a)[源]

返回给定张量的 dtype 和设备。

eigh(a)[源]

计算对称张量的特征值和特征向量。

此函数遵循来自 scipy.linalg.eigh 的 API。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigh.html

einsum(subscripts, *operands)[源]

对操作数评估爱因斯坦求和约定。

该函数遵循来自 numpy.einsum 的API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.einsum.html

eliminate_zeros(a, threshold=0.0)[源]

从稀疏张量中移除小于给定阈值的条目。

此函数遵循来自 scipy.sparse.csr_matrix.eliminate_zeros 的 API

查看: https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.sparse.csr_matrix.eliminate_zeros.html

exp(a)[源]

逐元素计算指数值。

此函数遵循来自 numpy.exp 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.exp.html

eye(N, M=None, type_as=None)[源]

创建给定大小的单位矩阵。

该函数遵循来自 numpy.eye 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.eye.html

flip(a, axis=None)[源]

沿给定维度反转张量中元素的顺序。

此函数遵循来自 numpy.flip 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.flip.html

floor(a)[源]

返回输入的元素的下限

见: https://numpy.org/doc/stable/reference/generated/numpy.floor.html

full(shape, fill_value, type_as=None)[源]

创建一个具有给定形状的张量,并用给定值填充。

该函数遵循来自 numpy.full 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.full.html

inv(a)[源]

计算矩阵的逆。

此函数遵循来自 scipy.linalg.inv 的 API。

请查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.inv.html

is_floating_point(a)[源]

返回输入是否由浮点数组成

isfinite(a)[源]

逐元素测试有限性(非无限和非数字)。

该函数遵循来自 numpy.isfinite 的API。

查看: https://numpy.org/doc/stable/reference/generated/numpy.isfinite.html

isinf(a)[源]

逐元素测试正无穷大或负无穷大,并返回布尔张量作为结果。

此函数遵循来自 numpy.isinf 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.isinf.html

isnan(a)[源]

逐元素测试是否为NaN,并将结果返回为布尔张量。

这个函数遵循来自 numpy.isnan 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.isnan.html

issparse(a)[源]

检查输入张量是否为稀疏张量。

此函数遵循来自 scipy.sparse.issparse 的API

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.issparse.html

kl_div(p, q, mass=False, eps=1e-16)[源]

计算(广义)Kullback-Leibler散度。

此函数遵循来自 scipy.stats.entropy 的 API。

参数 eps 用于避免数值错误,并添加在日志中。

\[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\]

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.entropy.html

linspace(start, stop, num, type_as=None)[源]

在给定区间内返回指定数量的均匀间隔的值。

此函数遵循来自 numpy.linspace 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.linspace.html

log(a)[源]

逐元素计算自然对数。

该函数遵循来自 numpy.log 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.log.html

logsumexp(a, axis=None)[源]

计算输入元素指数和的对数。

此函数遵循来自 scipy.special.logsumexp 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.logsumexp.html

matmul(a, b)[源]

两个数组的矩阵乘积。

见: https://numpy.org/doc/stable/reference/generated/numpy.matmul.html#numpy.matmul

max(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

此函数遵循来自 numpy.amax 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.amax.html

maximum(a, b)[源]

返回数组元素的逐元素最大值。

此函数遵循来自 numpy.maximum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.maximum.html

mean(a, axis=None)[源]

计算张量沿给定维度的算术平均值。

此函数遵循来自 numpy.mean 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.mean.html

median(a, axis=None)[源]

计算张量在给定维度上的中位数。

此函数遵循来自 numpy.median 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.median.html

meshgrid(a, b)[源]

从坐标向量返回坐标矩阵(Numpy 约定)。

该函数遵循numpy.meshgrid的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.meshgrid.html

min(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

这个函数遵循来自 numpy.amin 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.amin.html

minimum(a, b)[源]

返回数组元素的逐元素最小值。

该函数遵循来自 numpy.minimum 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.minimum.html

nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None)[源]

将NaN替换为零,将无穷大替换为大型有限数字或用户定义的数字。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.nan_to_num.html#numpy.nan_to_num

norm(a, axis=None, keepdims=False)[源]

计算矩阵的弗罗贝尼乌斯范数。

此函数遵循来自 numpy.linalg.norm 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.norm.html

ones(shape, type_as=None)[源]

创建一个全为一的张量。

此函数遵循来自 numpy.ones 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.ones.html

outer(a, b)[源]

计算两个向量之间的外积。

此函数遵循来自 numpy.outer 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.outer.html

power(a, exponents)[源]

第一个张量的元素逐个提升到第二个张量的幂。

该函数遵循来自 numpy.power 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.power.html

prod(a, axis=0)[源]

返回所有元素的乘积。

查看: https://numpy.org/doc/stable/reference/generated/numpy.prod.html

qr(a)[源]

返回QR分解

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.qr.html

rand(*size, type_as=None)[源]

生成均匀随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

randn(*size, type_as=None)[源]

生成正态高斯随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

repeat(a, repeats, axis=None)[源]

重复张量的元素。

此函数遵循来自 numpy.repeat 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.repeat.html

reshape(a, shape)[源]

不改变数据的情况下,给张量赋予新的形状。

该函数遵循来自 numpy.reshape 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.reshape.html

searchsorted(a, v, side='left')[源]

找到应该插入元素以保持给定张量中的顺序的索引。

此函数遵循来自 numpy.searchsorted 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.searchsorted.html

seed(seed=None)[源]

设置随机生成器的种子。

这个函数遵循来自 numpy.random.seed 的 API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.seed.html

set_gradients(val, inputs, grads)[源]

定义相对于输入的值 val 的梯度

sign(a)[源]

返回一个元素逐个指示一个数字的符号。

此函数遵循来自 numpy.sign 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.sign.html

solve(a, b)[源]

求解线性矩阵方程或线性标量方程组。

此函数遵循来自 numpy.linalg.solve 的 API。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.solve.html

sort(a, axis=-1)[源]

返回一个排序后的张量副本。

此函数遵循来自 numpy.sort 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.sort.html

sort2(a, axis=-1)[源]

返回排序后的数组和排序数组的索引

查看: https://pytorch.org/docs/stable/generated/torch.sort.html

sqrt(a)[源]

返回张量的非负平方根,逐元素进行。

此函数遵循来自 numpy.sqrt 的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.sqrt.html

sqrtm(a)[源]

计算矩阵的平方根。 需要输入对称的半正定。

这个函数遵循scipy.linalg.sqrtm的API,允许批处理。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.sqrtm.html

squeeze(a, axis=None)[源]

从a中移除长度为一的轴。

此函数遵循来自 numpy.squeeze 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.squeeze.html

stack(arrays, axis=0)[源]

在新的维度上连接一系列张量。

此函数遵循来自 numpy.stack 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.stack.html

std(a, axis=None)[源]

计算给定维度上张量的标准差。

此函数遵循来自 numpy.std 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.std.html

sum(a, axis=None, keepdims=False)[源]

对给定维度的张量元素求和。

该函数遵循来自 numpy.sum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.sum.html

take_along_axis(arr, indices, axis)[源]

沿给定维度收集张量的元素。

此函数遵循来自 numpy.take_along_axis 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.take_along_axis.html

tile(a, reps)[源]

通过重复给定次数的数字构建数组

见: https://numpy.org/doc/stable/reference/generated/numpy.tile.html

tocsr(a)[源]

将此矩阵转换为压缩稀疏行格式。

此函数遵循来自 scipy.sparse.coo_matrix.tocsr 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.tocsr.html

todense(a)[源]

将稀疏张量转换为密集张量。

此函数遵循来自 scipy.sparse.csr_matrix.toarray 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.toarray.html

trace(a)[源]

返回数组沿对角线的和。

这个函数遵循来自 numpy.trace 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.trace.html

transpose(a, axes=None)[源]

返回一个张量,该张量是a的转置版本。给定的维度dim0和dim1被交换。

见: https://numpy.org/doc/stable/reference/generated/numpy.transpose.html

unique(a, return_inverse=False)[源]

查找给定张量的唯一元素。

此函数遵循来自 numpy.unique 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.unique.html

where(condition, x=None, y=None)[源]

根据条件从 x 或 y 中返回选定的元素。

此函数遵循来自 numpy.where 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.where.html

zero_pad(a, pad_width, value=0)[源]

用给定的值(默认是0)填充一个张量。

此函数遵循来自 numpy.pad 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.pad.html

zeros(shape, type_as=None)[源]

创建一个满是零的张量。

该函数遵循来自 numpy.zeros 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.zeros.html

class ot.backend.TorchBackend[源]

后端的PyTorch实现

  • __name__ 是 “torch”

  • __type__ 是 torch.Tensor

abs(a)[源]

逐元素计算绝对值。

此函数遵循来自 numpy.absolute 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.absolute.html

allclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False)[源]

如果两个数组在容差范围内逐元素相等,则返回 True。

此函数遵循来自 numpy.allclose 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.allclose.html

any(a)[源]

测试沿给定维度的任何张量元素是否评估为真。

此函数遵循来自 numpy.any 的 API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.any.html

arange(stop, start=0, step=1, type_as=None)[源]

返回特定区间内均匀间隔的值。

此函数遵循来自 numpy.arange 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.arange.html

argmax(a, axis=None)[源]

返回张量在给定维度上的最大值的索引。

这个函数遵循来自 numpy.argmax 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.argmax.html

argmin(a, axis=None)[源]

返回张量在给定维度上的最小值的索引。

此函数遵循来自 numpy.argmin 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.argmin.html

argsort(a, axis=-1)[源]

返回将张量排序的索引。

此函数遵循来自 numpy.argsort 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.argsort.html

array_equal(a, b)[源]

如果两个数组具有相同的形状和元素,则返回True,否则返回False。

此函数遵循numpy.array_equal的API。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.array_equal.html

assert_same_dtype_device(a, b)[源]

检查两个给定输入是否具有相同的数据类型以及相同的设备

atan2(a, b)[源]

逐元素反正切

见: https://numpy.org/doc/stable/reference/generated/numpy.arctan2.html

bitsize(type_as)[源]

给定张量的数据类型所使用的比特数。

clip(a, a_min, a_max)[源]

限制张量中的值。

此函数遵循numpy.clip的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.clip.html

concatenate(arrays, axis=0)[源]

沿着现有维度连接一系列张量。

此函数遵循来自 numpy.concatenate 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.concatenate.html

coo_matrix(data, rows, cols, shape=None, type_as=None)[源]

创建一个稀疏张量,采用坐标格式。

此函数遵循来自 scipy.sparse.coo_matrix 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.html

copy(a)[源]

返回给定张量的副本。

这个函数遵循来自 numpy.copy 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.copy.html

cumsum(a, axis=None)[源]

返回给定维度上张量元素的累计和。

这个函数遵循来自 numpy.cumsum 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.cumsum.html

det(x)[源]

计算数组的行列式。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.det.html

device_type(type_as)[源]

根据给定张量所在设备返回CPU或GPU。

diag(a, k=0)[源]

提取或构造对角张量。

该函数遵循来自 numpy.diag 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.diag.html

dot(a, b)[源]

返回两个张量的点积。

此函数遵循来自 numpy.dot 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.dot.html

dtype_device(a)[源]

返回给定张量的 dtype 和设备。

eigh(a)[源]

计算对称张量的特征值和特征向量。

此函数遵循来自 scipy.linalg.eigh 的 API。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigh.html

einsum(subscripts, *operands)[源]

对操作数评估爱因斯坦求和约定。

该函数遵循来自 numpy.einsum 的API

请参见: https://numpy.org/doc/stable/reference/generated/numpy.einsum.html

eliminate_zeros(a, threshold=0.0)[源]

从稀疏张量中移除小于给定阈值的条目。

此函数遵循来自 scipy.sparse.csr_matrix.eliminate_zeros 的 API

查看: https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.sparse.csr_matrix.eliminate_zeros.html

exp(a)[源]

逐元素计算指数值。

此函数遵循来自 numpy.exp 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.exp.html

eye(N, M=None, type_as=None)[源]

创建给定大小的单位矩阵。

该函数遵循来自 numpy.eye 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.eye.html

flip(a, axis=None)[源]

沿给定维度反转张量中元素的顺序。

此函数遵循来自 numpy.flip 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.flip.html

floor(a)[源]

返回输入的元素的下限

见: https://numpy.org/doc/stable/reference/generated/numpy.floor.html

full(shape, fill_value, type_as=None)[源]

创建一个具有给定形状的张量,并用给定值填充。

该函数遵循来自 numpy.full 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.full.html

inv(a)[源]

计算矩阵的逆。

此函数遵循来自 scipy.linalg.inv 的 API。

请查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.inv.html

is_floating_point(a)[源]

返回输入是否由浮点数组成

isfinite(a)[源]

逐元素测试有限性(非无限和非数字)。

该函数遵循来自 numpy.isfinite 的API。

查看: https://numpy.org/doc/stable/reference/generated/numpy.isfinite.html

isinf(a)[源]

逐元素测试正无穷大或负无穷大,并返回布尔张量作为结果。

此函数遵循来自 numpy.isinf 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.isinf.html

isnan(a)[源]

逐元素测试是否为NaN,并将结果返回为布尔张量。

这个函数遵循来自 numpy.isnan 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.isnan.html

issparse(a)[源]

检查输入张量是否为稀疏张量。

此函数遵循来自 scipy.sparse.issparse 的API

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.issparse.html

kl_div(p, q, mass=False, eps=1e-16)[源]

计算(广义)Kullback-Leibler散度。

此函数遵循来自 scipy.stats.entropy 的 API。

参数 eps 用于避免数值错误,并添加在日志中。

\[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\]

查看: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.entropy.html

linspace(start, stop, num, type_as=None)[源]

在给定区间内返回指定数量的均匀间隔的值。

此函数遵循来自 numpy.linspace 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.linspace.html

log(a)[源]

逐元素计算自然对数。

该函数遵循来自 numpy.log 的API

请查看: https://numpy.org/doc/stable/reference/generated/numpy.log.html

logsumexp(a, axis=None)[源]

计算输入元素指数和的对数。

此函数遵循来自 scipy.special.logsumexp 的 API

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.logsumexp.html

matmul(a, b)[源]

两个数组的矩阵乘积。

见: https://numpy.org/doc/stable/reference/generated/numpy.matmul.html#numpy.matmul

max(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

此函数遵循来自 numpy.amax 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.amax.html

maximum(a, b)[源]

返回数组元素的逐元素最大值。

此函数遵循来自 numpy.maximum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.maximum.html

mean(a, axis=None)[源]

计算张量沿给定维度的算术平均值。

此函数遵循来自 numpy.mean 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.mean.html

median(a, axis=None)[源]

计算张量在给定维度上的中位数。

此函数遵循来自 numpy.median 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.median.html

meshgrid(a, b)[源]

从坐标向量返回坐标矩阵(Numpy 约定)。

该函数遵循numpy.meshgrid的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.meshgrid.html

min(a, axis=None, keepdims=False)[源]

返回数组的最大值或在给定维度上的最大值。

这个函数遵循来自 numpy.amin 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.amin.html

minimum(a, b)[源]

返回数组元素的逐元素最小值。

该函数遵循来自 numpy.minimum 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.minimum.html

nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None)[源]

将NaN替换为零,将无穷大替换为大型有限数字或用户定义的数字。

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.nan_to_num.html#numpy.nan_to_num

norm(a, axis=None, keepdims=False)[源]

计算矩阵的弗罗贝尼乌斯范数。

此函数遵循来自 numpy.linalg.norm 的 API

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.norm.html

ones(shape, type_as=None)[源]

创建一个全为一的张量。

此函数遵循来自 numpy.ones 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.ones.html

outer(a, b)[源]

计算两个向量之间的外积。

此函数遵循来自 numpy.outer 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.outer.html

power(a, exponents)[源]

第一个张量的元素逐个提升到第二个张量的幂。

该函数遵循来自 numpy.power 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.power.html

prod(a, axis=0)[源]

返回所有元素的乘积。

查看: https://numpy.org/doc/stable/reference/generated/numpy.prod.html

qr(a)[源]

返回QR分解

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.qr.html

rand(*size, type_as=None)[源]

生成均匀随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

randn(*size, type_as=None)[源]

生成正态高斯随机数。

此函数遵循来自 numpy.random.rand 的API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.rand.html

repeat(a, repeats, axis=None)[源]

重复张量的元素。

此函数遵循来自 numpy.repeat 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.repeat.html

reshape(a, shape)[源]

不改变数据的情况下,给张量赋予新的形状。

该函数遵循来自 numpy.reshape 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.reshape.html

searchsorted(a, v, side='left')[源]

找到应该插入元素以保持给定张量中的顺序的索引。

此函数遵循来自 numpy.searchsorted 的 API

请参阅: https://numpy.org/doc/stable/reference/generated/numpy.searchsorted.html

seed(seed=None)[源]

设置随机生成器的种子。

这个函数遵循来自 numpy.random.seed 的 API

查看: https://numpy.org/doc/stable/reference/random/generated/numpy.random.seed.html

set_gradients(val, inputs, grads)[源]

定义相对于输入的值 val 的梯度

sign(a)[源]

返回一个元素逐个指示一个数字的符号。

此函数遵循来自 numpy.sign 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.sign.html

solve(a, b)[源]

求解线性矩阵方程或线性标量方程组。

此函数遵循来自 numpy.linalg.solve 的 API。

参见: https://numpy.org/doc/stable/reference/generated/numpy.linalg.solve.html

sort(a, axis=-1)[源]

返回一个排序后的张量副本。

此函数遵循来自 numpy.sort 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.sort.html

sort2(a, axis=-1)[源]

返回排序后的数组和排序数组的索引

查看: https://pytorch.org/docs/stable/generated/torch.sort.html

sqrt(a)[源]

返回张量的非负平方根,逐元素进行。

此函数遵循来自 numpy.sqrt 的api

查看: https://numpy.org/doc/stable/reference/generated/numpy.sqrt.html

sqrtm(a)[源]

计算矩阵的平方根。 需要输入对称的半正定。

这个函数遵循scipy.linalg.sqrtm的API,允许批处理。

见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.sqrtm.html

squeeze(a, axis=None)[源]

从a中移除长度为一的轴。

此函数遵循来自 numpy.squeeze 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.squeeze.html

stack(arrays, axis=0)[源]

在新的维度上连接一系列张量。

此函数遵循来自 numpy.stack 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.stack.html

std(a, axis=None)[源]

计算给定维度上张量的标准差。

此函数遵循来自 numpy.std 的 API

见: https://numpy.org/doc/stable/reference/generated/numpy.std.html

sum(a, axis=None, keepdims=False)[源]

对给定维度的张量元素求和。

该函数遵循来自 numpy.sum 的 API

查看: https://numpy.org/doc/stable/reference/generated/numpy.sum.html

take_along_axis(arr, indices, axis)[源]

沿给定维度收集张量的元素。

此函数遵循来自 numpy.take_along_axis 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.take_along_axis.html

tile(a, reps)[源]

通过重复给定次数的数字构建数组

见: https://numpy.org/doc/stable/reference/generated/numpy.tile.html

tocsr(a)[源]

将此矩阵转换为压缩稀疏行格式。

此函数遵循来自 scipy.sparse.coo_matrix.tocsr 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.coo_matrix.tocsr.html

todense(a)[源]

将稀疏张量转换为密集张量。

此函数遵循来自 scipy.sparse.csr_matrix.toarray 的 API

请参见: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.toarray.html

trace(a)[源]

返回数组沿对角线的和。

这个函数遵循来自 numpy.trace 的API。

见: https://numpy.org/doc/stable/reference/generated/numpy.trace.html

transpose(a, axes=None)[源]

返回一个张量,该张量是a的转置版本。给定的维度dim0和dim1被交换。

见: https://numpy.org/doc/stable/reference/generated/numpy.transpose.html

unique(a, return_inverse=False)[源]

查找给定张量的唯一元素。

此函数遵循来自 numpy.unique 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.unique.html

where(condition, x=None, y=None)[源]

根据条件从 x 或 y 中返回选定的元素。

此函数遵循来自 numpy.where 的API

见: https://numpy.org/doc/stable/reference/generated/numpy.where.html

zero_pad(a, pad_width, value=0)[源]

用给定的值(默认是0)填充一个张量。

此函数遵循来自 numpy.pad 的API

查看: https://numpy.org/doc/stable/reference/generated/numpy.pad.html

zeros(shape, type_as=None)[源]

创建一个满是零的张量。

该函数遵循来自 numpy.zeros 的api

见: https://numpy.org/doc/stable/reference/generated/numpy.zeros.html

ot.backend.get_available_backend_implementations()[源]

返回可用的后端实现列表。

ot.backend.get_backend(*args)[源]

返回一个输入数组列表的正确后端

接受参数中的None条目,并忽略它们

如果所有数组不来自相同的后端,也会引发TypeError

ot.backend.get_backend_list()[源]

返回所有可用后端的实例。

请注意,此函数强制所有检测到的实现被实例化,即使之前未使用特定的后端。请小心,因为后端的实例化可能导致副作用,例如 GPU 内存的预分配。有关更多详细信息,请参阅文档。如果您只需要知道哪些实现是可用的,请使用 :py:func:`ot.backend.get_available_backend_implementations,该函数不会强制创建后端对象的实例。

ot.backend.to_numpy(*args)[源]

从任何兼容的后端返回numpy数组