提交 6b2bcbcc 编写于 作者: 绝不原创的飞龙's avatar 绝不原创的飞龙

2024-02-05 13:49:23

上级 7877c989
......@@ -3,11 +3,13 @@
prefs:
- PREF_H1
type: TYPE_NORMAL
zh: torch.futures
- en: 原文:[https://pytorch.org/docs/stable/futures.html](https://pytorch.org/docs/stable/futures.html)
id: totrans-1
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: 原文:[https://pytorch.org/docs/stable/futures.html](https://pytorch.org/docs/stable/futures.html)
- en: This package provides a [`Future`](#torch.futures.Future "torch.futures.Future")
type that encapsulates an asynchronous execution and a set of utility functions
to simplify operations on [`Future`](#torch.futures.Future "torch.futures.Future")
......@@ -16,6 +18,8 @@
id: totrans-2
prefs: []
type: TYPE_NORMAL
zh: 此软件包提供了一个[`Future`](#torch.futures.Future "torch.futures.Future")类型,封装了异步执行和一组实用函数,以简化对[`Future`](#torch.futures.Future
"torch.futures.Future")对象的操作。目前,[`Future`](#torch.futures.Future "torch.futures.Future")类型主要由[分布式RPC框架](rpc.html#distributed-rpc-framework)使用。
- en: '[PRE0]'
id: totrans-3
prefs: []
......@@ -27,14 +31,18 @@
id: totrans-4
prefs: []
type: TYPE_NORMAL
zh: 封装了对可调用对象的异步执行的`torch._C.Future`的包装器,例如[`rpc_async()`](rpc.html#torch.distributed.rpc.rpc_async
"torch.distributed.rpc.rpc_async")。它还公开了一组API来添加回调函数和设置结果。
- en: Warning
id: totrans-5
prefs: []
type: TYPE_NORMAL
zh: 警告
- en: GPU support is a beta feature, subject to changes.
id: totrans-6
prefs: []
type: TYPE_NORMAL
zh: GPU支持是一个测试功能,可能会发生变化。
- en: '[PRE1]'
id: totrans-7
prefs: []
......@@ -50,6 +58,8 @@
id: totrans-8
prefs: []
type: TYPE_NORMAL
zh: 将给定的回调函数附加到此`Future`,当`Future`完成时将运行该回调。可以向同一个`Future`添加多个回调,但不能保证它们将以何种顺序执行。回调必须接受一个参数,即对此`Future`的引用。回调函数可以使用[`value()`](#torch.futures.Future.value
"torch.futures.Future.value")方法获取值。请注意,如果此`Future`已经完成,给定的回调将内联运行。
- en: We recommend that you use the [`then()`](#torch.futures.Future.then "torch.futures.Future.then")
method as it provides a way to synchronize after your callback has completed.
`add_done_callback` can be cheaper if your callback does not return anything.
......@@ -58,24 +68,30 @@
id: totrans-9
prefs: []
type: TYPE_NORMAL
zh: 我们建议您使用[`then()`](#torch.futures.Future.then "torch.futures.Future.then")方法,因为它提供了在回调完成后同步的方法。如果您的回调不返回任何内容,`add_done_callback`可能更便宜。但是[`then()`](#torch.futures.Future.then
"torch.futures.Future.then")和`add_done_callback`在底层使用相同的回调注册API。
- en: With respect to GPU tensors, this method behaves in the same way as [`then()`](#torch.futures.Future.then
"torch.futures.Future.then").
id: totrans-10
prefs: []
type: TYPE_NORMAL
zh: 就GPU张量而言,此方法的行为与[`then()`](#torch.futures.Future.then "torch.futures.Future.then")相同。
- en: Parameters
id: totrans-11
prefs: []
type: TYPE_NORMAL
zh: 参数
- en: '**callback** (`Future`) a `Callable` that takes in one argument, which is
the reference to this `Future`.'
id: totrans-12
prefs: []
type: TYPE_NORMAL
zh: '**callback** (`Future`) 一个接受一个参数(即对此`Future`的引用)的`Callable`。'
- en: Note
id: totrans-13
prefs: []
type: TYPE_NORMAL
zh: 注意
- en: Note that if the callback function throws, either through the original future
being completed with an exception and calling `fut.wait()`, or through other code
in the callback, error handling must be carefully taken care of. For example,
......@@ -85,10 +101,12 @@
id: totrans-14
prefs: []
type: TYPE_NORMAL
zh: 请注意,如果回调函数抛出异常,无论是通过原始未来完成异常并调用`fut.wait()`,还是通过回调中的其他代码,都必须小心处理错误处理。例如,如果此回调稍后完成其他未来,那些未来不会被标记为已完成并带有错误,用户需要独立处理完成/等待这些未来。
- en: 'Example::'
id: totrans-15
prefs: []
type: TYPE_NORMAL
zh: '示例::'
- en: '[PRE2]'
id: totrans-16
prefs: []
......@@ -104,6 +122,7 @@
id: totrans-18
prefs: []
type: TYPE_NORMAL
zh: 如果此`Future`已完成,则返回`True`。如果`Future`有结果或异常,则已完成。
- en: If the value contains tensors that reside on GPUs, `Future.done()` will return
`True` even if the asynchronous kernels that are populating those tensors haven’t
yet completed running on the device, because at such stage the result is already
......@@ -112,14 +131,18 @@
id: totrans-19
prefs: []
type: TYPE_NORMAL
zh: 如果值包含在GPU上的张量,即使异步内核尚未在设备上完成运行,`Future.done()`将返回`True`,因为在这个阶段结果已经可用,只要执行适当的同步(参见[`wait()`](#torch.futures.Future.wait
"torch.futures.Future.wait"))。
- en: Return type
id: totrans-20
prefs: []
type: TYPE_NORMAL
zh: 返回类型
- en: '[bool](https://docs.python.org/3/library/functions.html#bool "(in Python v3.12)")'
id: totrans-21
prefs: []
type: TYPE_NORMAL
zh: '[bool](https://docs.python.org/3/library/functions.html#bool "(in Python v3.12)")'
- en: '[PRE4]'
id: totrans-22
prefs: []
......@@ -131,19 +154,24 @@
id: totrans-23
prefs: []
type: TYPE_NORMAL
zh: 为此`Future`设置异常,这将标记此`Future`为已完成并触发所有附加的回调。请注意,当在此`Future`上调用wait()/value()时,此处设置的异常将内联引发。
- en: Parameters
id: totrans-24
prefs: []
type: TYPE_NORMAL
zh: 参数
- en: '**result** ([*BaseException*](https://docs.python.org/3/library/exceptions.html#BaseException
"(in Python v3.12)")) the exception for this `Future`.'
id: totrans-25
prefs: []
type: TYPE_NORMAL
zh: '**result** ([*BaseException*](https://docs.python.org/3/library/exceptions.html#BaseException
"(in Python v3.12)")) 此`Future`的异常。'
- en: 'Example::'
id: totrans-26
prefs: []
type: TYPE_NORMAL
zh: '示例::'
- en: '[PRE5]'
id: totrans-27
prefs: []
......@@ -160,6 +188,7 @@
id: totrans-29
prefs: []
type: TYPE_NORMAL
zh: 设置此`Future`的结果,这将标记此`Future`为已完成并触发所有附加的回调。请注意,`Future`不能被标记为已完成两次。
- en: If the result contains tensors that reside on GPUs, this method can be called
even if the asynchronous kernels that are populating those tensors haven’t yet
completed running on the device, provided that the streams on which those kernels
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
- en: torch.linalg
id: totrans-0
prefs:
- PREF_H1
type: TYPE_NORMAL
zh: torch.linalg
- en: 原文:[https://pytorch.org/docs/stable/linalg.html](https://pytorch.org/docs/stable/linalg.html)
id: totrans-1
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: 原文:[https://pytorch.org/docs/stable/linalg.html](https://pytorch.org/docs/stable/linalg.html)
- en: Common linear algebra operations.
id: totrans-2
prefs: []
type: TYPE_NORMAL
zh: 常见线性代数操作。
- en: See [Linear algebra (torch.linalg)](notes/numerical_accuracy.html#linear-algebra-stability)
for some common numerical edge-cases.
id: totrans-3
prefs: []
type: TYPE_NORMAL
zh: 查看[线性代数(torch.linalg)](notes/numerical_accuracy.html#linear-algebra-stability)以获取一些常见的数值边界情况。
- en: '## Matrix Properties'
id: totrans-4
prefs: []
type: TYPE_NORMAL
zh: '## 矩阵属性'
- en: '| [`norm`](generated/torch.linalg.norm.html#torch.linalg.norm "torch.linalg.norm")
| Computes a vector or matrix norm. |'
id: totrans-5
prefs: []
type: TYPE_TB
zh: '| [`norm`](generated/torch.linalg.norm.html#torch.linalg.norm "torch.linalg.norm")
| 计算向量或矩阵范数。 |'
- en: '| [`vector_norm`](generated/torch.linalg.vector_norm.html#torch.linalg.vector_norm
"torch.linalg.vector_norm") | Computes a vector norm. |'
id: totrans-6
prefs: []
type: TYPE_TB
zh: '| [`vector_norm`](generated/torch.linalg.vector_norm.html#torch.linalg.vector_norm
"torch.linalg.vector_norm") | 计算向量范数。 |'
- en: '| [`matrix_norm`](generated/torch.linalg.matrix_norm.html#torch.linalg.matrix_norm
"torch.linalg.matrix_norm") | Computes a matrix norm. |'
id: totrans-7
prefs: []
type: TYPE_TB
zh: '| [`matrix_norm`](generated/torch.linalg.matrix_norm.html#torch.linalg.matrix_norm
"torch.linalg.matrix_norm") | 计算矩阵范数。 |'
- en: '| [`diagonal`](generated/torch.linalg.diagonal.html#torch.linalg.diagonal "torch.linalg.diagonal")
| Alias for [`torch.diagonal()`](generated/torch.diagonal.html#torch.diagonal
"torch.diagonal") with defaults `dim1`= -2, `dim2`= -1. |'
id: totrans-8
prefs: []
type: TYPE_TB
zh: '| [`diagonal`](generated/torch.linalg.diagonal.html#torch.linalg.diagonal "torch.linalg.diagonal")
| [`torch.diagonal()`](generated/torch.diagonal.html#torch.diagonal "torch.diagonal")的别名,默认参数
`dim1`= -2, `dim2`= -1。 |'
- en: '| [`det`](generated/torch.linalg.det.html#torch.linalg.det "torch.linalg.det")
| Computes the determinant of a square matrix. |'
id: totrans-9
prefs: []
type: TYPE_TB
zh: '| [`det`](generated/torch.linalg.det.html#torch.linalg.det "torch.linalg.det")
| 计算方阵的行列式。 |'
- en: '| [`slogdet`](generated/torch.linalg.slogdet.html#torch.linalg.slogdet "torch.linalg.slogdet")
| Computes the sign and natural logarithm of the absolute value of the determinant
of a square matrix. |'
id: totrans-10
prefs: []
type: TYPE_TB
zh: '| [`slogdet`](generated/torch.linalg.slogdet.html#torch.linalg.slogdet "torch.linalg.slogdet")
| 计算方阵行列式的符号和自然对数的绝对值。 |'
- en: '| [`cond`](generated/torch.linalg.cond.html#torch.linalg.cond "torch.linalg.cond")
| Computes the condition number of a matrix with respect to a matrix norm. |'
id: totrans-11
prefs: []
type: TYPE_TB
zh: '| [`cond`](generated/torch.linalg.cond.html#torch.linalg.cond "torch.linalg.cond")
| 计算矩阵相对于矩阵范数的条件数。 |'
- en: '| [`matrix_rank`](generated/torch.linalg.matrix_rank.html#torch.linalg.matrix_rank
"torch.linalg.matrix_rank") | Computes the numerical rank of a matrix. |'
id: totrans-12
prefs: []
type: TYPE_TB
zh: '| [`matrix_rank`](generated/torch.linalg.matrix_rank.html#torch.linalg.matrix_rank
"torch.linalg.matrix_rank") | 计算矩阵的数值秩。 |'
- en: Decompositions
id: totrans-13
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 分解
- en: '| [`cholesky`](generated/torch.linalg.cholesky.html#torch.linalg.cholesky "torch.linalg.cholesky")
| Computes the Cholesky decomposition of a complex Hermitian or real symmetric
positive-definite matrix. |'
id: totrans-14
prefs: []
type: TYPE_TB
zh: '| [`cholesky`](generated/torch.linalg.cholesky.html#torch.linalg.cholesky "torch.linalg.cholesky")
| 计算复共轭Hermitian或实对称正定矩阵的Cholesky分解。 |'
- en: '| [`qr`](generated/torch.linalg.qr.html#torch.linalg.qr "torch.linalg.qr")
| Computes the QR decomposition of a matrix. |'
id: totrans-15
prefs: []
type: TYPE_TB
zh: '| [`qr`](generated/torch.linalg.qr.html#torch.linalg.qr "torch.linalg.qr")
| 计算矩阵的QR分解。 |'
- en: '| [`lu`](generated/torch.linalg.lu.html#torch.linalg.lu "torch.linalg.lu")
| Computes the LU decomposition with partial pivoting of a matrix. |'
id: totrans-16
prefs: []
type: TYPE_TB
zh: '| [`lu`](generated/torch.linalg.lu.html#torch.linalg.lu "torch.linalg.lu")
| 计算具有部分主元的矩阵LU分解。 |'
- en: '| [`lu_factor`](generated/torch.linalg.lu_factor.html#torch.linalg.lu_factor
"torch.linalg.lu_factor") | Computes a compact representation of the LU factorization
with partial pivoting of a matrix. |'
id: totrans-17
prefs: []
type: TYPE_TB
zh: '| [`lu_factor`](generated/torch.linalg.lu_factor.html#torch.linalg.lu_factor
"torch.linalg.lu_factor") | 计算具有部分主元的矩阵LU分解的紧凑表示。 |'
- en: '| [`eig`](generated/torch.linalg.eig.html#torch.linalg.eig "torch.linalg.eig")
| Computes the eigenvalue decomposition of a square matrix if it exists. |'
id: totrans-18
prefs: []
type: TYPE_TB
zh: '| [`eig`](generated/torch.linalg.eig.html#torch.linalg.eig "torch.linalg.eig")
| 计算方阵的特征值分解(如果存在)。 |'
- en: '| [`eigvals`](generated/torch.linalg.eigvals.html#torch.linalg.eigvals "torch.linalg.eigvals")
| Computes the eigenvalues of a square matrix. |'
id: totrans-19
prefs: []
type: TYPE_TB
zh: '| [`eigvals`](generated/torch.linalg.eigvals.html#torch.linalg.eigvals "torch.linalg.eigvals")
| 计算方阵的特征值。 |'
- en: '| [`eigh`](generated/torch.linalg.eigh.html#torch.linalg.eigh "torch.linalg.eigh")
| Computes the eigenvalue decomposition of a complex Hermitian or real symmetric
matrix. |'
id: totrans-20
prefs: []
type: TYPE_TB
zh: '| [`eigh`](generated/torch.linalg.eigh.html#torch.linalg.eigh "torch.linalg.eigh")
| 计算复共轭Hermitian或实对称矩阵的特征值分解。 |'
- en: '| [`eigvalsh`](generated/torch.linalg.eigvalsh.html#torch.linalg.eigvalsh "torch.linalg.eigvalsh")
| Computes the eigenvalues of a complex Hermitian or real symmetric matrix. |'
id: totrans-21
prefs: []
type: TYPE_TB
zh: '| [`eigvalsh`](generated/torch.linalg.eigvalsh.html#torch.linalg.eigvalsh "torch.linalg.eigvalsh")
| 计算复共轭Hermitian或实对称矩阵的特征值。 |'
- en: '| [`svd`](generated/torch.linalg.svd.html#torch.linalg.svd "torch.linalg.svd")
| Computes the singular value decomposition (SVD) of a matrix. |'
id: totrans-22
prefs: []
type: TYPE_TB
zh: '| [`svd`](generated/torch.linalg.svd.html#torch.linalg.svd "torch.linalg.svd")
| 计算矩阵的奇异值分解(SVD)。 |'
- en: '| [`svdvals`](generated/torch.linalg.svdvals.html#torch.linalg.svdvals "torch.linalg.svdvals")
| Computes the singular values of a matrix. |'
id: totrans-23
prefs: []
type: TYPE_TB
zh: '| [`svdvals`](generated/torch.linalg.svdvals.html#torch.linalg.svdvals "torch.linalg.svdvals")
| 计算矩阵的奇异值。 |'
- en: '## Solvers'
id: totrans-24
prefs: []
type: TYPE_NORMAL
zh: '## 求解器'
- en: '| [`solve`](generated/torch.linalg.solve.html#torch.linalg.solve "torch.linalg.solve")
| Computes the solution of a square system of linear equations with a unique solution.
|'
id: totrans-25
prefs: []
type: TYPE_TB
zh: '| [`solve`](generated/torch.linalg.solve.html#torch.linalg.solve "torch.linalg.solve")
| 计算具有唯一解的方阵线性方程组的解。 |'
- en: '| [`solve_triangular`](generated/torch.linalg.solve_triangular.html#torch.linalg.solve_triangular
"torch.linalg.solve_triangular") | Computes the solution of a triangular system
of linear equations with a unique solution. |'
id: totrans-26
prefs: []
type: TYPE_TB
zh: '| [`solve_triangular`](generated/torch.linalg.solve_triangular.html#torch.linalg.solve_triangular
"torch.linalg.solve_triangular") | 计算具有唯一解的三角线性方程组的解。 |'
- en: '| [`lu_solve`](generated/torch.linalg.lu_solve.html#torch.linalg.lu_solve "torch.linalg.lu_solve")
| Computes the solution of a square system of linear equations with a unique solution
given an LU decomposition. |'
id: totrans-27
prefs: []
type: TYPE_TB
zh: '| [`lu_solve`](generated/torch.linalg.lu_solve.html#torch.linalg.lu_solve "torch.linalg.lu_solve")
| 在给定LU分解的情况下计算具有唯一解的方阵线性方程组的解。 |'
- en: '| [`lstsq`](generated/torch.linalg.lstsq.html#torch.linalg.lstsq "torch.linalg.lstsq")
| Computes a solution to the least squares problem of a system of linear equations.
| ## Inverses'
id: totrans-28
prefs: []
type: TYPE_NORMAL
zh: '| [`lstsq`](generated/torch.linalg.lstsq.html#torch.linalg.lstsq "torch.linalg.lstsq")
| 计算线性方程组的最小二乘解。 | ## 逆运算'
- en: '| [`inv`](generated/torch.linalg.inv.html#torch.linalg.inv "torch.linalg.inv")
| Computes the inverse of a square matrix if it exists. |'
id: totrans-29
prefs: []
type: TYPE_TB
zh: '| [`inv`](generated/torch.linalg.inv.html#torch.linalg.inv "torch.linalg.inv")
| 计算方阵的逆矩阵(如果存在)。 |'
- en: '| [`pinv`](generated/torch.linalg.pinv.html#torch.linalg.pinv "torch.linalg.pinv")
| Computes the pseudoinverse (Moore-Penrose inverse) of a matrix. |'
id: totrans-30
prefs: []
type: TYPE_TB
zh: '| [`pinv`](generated/torch.linalg.pinv.html#torch.linalg.pinv "torch.linalg.pinv")
| 计算矩阵的伪逆(Moore-Penrose 逆)。 |'
- en: Matrix Functions
id: totrans-31
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 矩阵函数
- en: '| [`matrix_exp`](generated/torch.linalg.matrix_exp.html#torch.linalg.matrix_exp
"torch.linalg.matrix_exp") | Computes the matrix exponential of a square matrix.
|'
id: totrans-32
prefs: []
type: TYPE_TB
zh: '| [`matrix_exp`](generated/torch.linalg.matrix_exp.html#torch.linalg.matrix_exp
"torch.linalg.matrix_exp") | 计算方阵的矩阵指数。 |'
- en: '| [`matrix_power`](generated/torch.linalg.matrix_power.html#torch.linalg.matrix_power
"torch.linalg.matrix_power") | Computes the n-th power of a square matrix for
an integer n. |'
id: totrans-33
prefs: []
type: TYPE_TB
zh: '| [`matrix_power`](generated/torch.linalg.matrix_power.html#torch.linalg.matrix_power
"torch.linalg.matrix_power") | 计算整数 n 的方阵的 n 次幂。 |'
- en: Matrix Products
id: totrans-34
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 矩阵乘积
- en: '| [`cross`](generated/torch.linalg.cross.html#torch.linalg.cross "torch.linalg.cross")
| Computes the cross product of two 3-dimensional vectors. |'
id: totrans-35
prefs: []
type: TYPE_TB
zh: '| [`cross`](generated/torch.linalg.cross.html#torch.linalg.cross "torch.linalg.cross")
| 计算两个三维向量的叉积。 |'
- en: '| [`matmul`](generated/torch.linalg.matmul.html#torch.linalg.matmul "torch.linalg.matmul")
| Alias for [`torch.matmul()`](generated/torch.matmul.html#torch.matmul "torch.matmul")
|'
id: totrans-36
prefs: []
type: TYPE_TB
zh: '| [`matmul`](generated/torch.linalg.matmul.html#torch.linalg.matmul "torch.linalg.matmul")
| [`torch.matmul()`](generated/torch.matmul.html#torch.matmul "torch.matmul")
的别名 |'
- en: '| [`vecdot`](generated/torch.linalg.vecdot.html#torch.linalg.vecdot "torch.linalg.vecdot")
| Computes the dot product of two batches of vectors along a dimension. |'
id: totrans-37
prefs: []
type: TYPE_TB
zh: '| [`vecdot`](generated/torch.linalg.vecdot.html#torch.linalg.vecdot "torch.linalg.vecdot")
| 计算沿着维度的两批向量的点积。 |'
- en: '| [`multi_dot`](generated/torch.linalg.multi_dot.html#torch.linalg.multi_dot
"torch.linalg.multi_dot") | Efficiently multiplies two or more matrices by reordering
the multiplications so that the fewest arithmetic operations are performed. |'
id: totrans-38
prefs: []
type: TYPE_TB
zh: '| [`multi_dot`](generated/torch.linalg.multi_dot.html#torch.linalg.multi_dot
"torch.linalg.multi_dot") | 通过重新排列乘法,使得执行最少的算术运算,高效地将两个或多个矩阵相乘。 |'
- en: '| [`householder_product`](generated/torch.linalg.householder_product.html#torch.linalg.householder_product
"torch.linalg.householder_product") | Computes the first n columns of a product
of Householder matrices. |'
id: totrans-39
prefs: []
type: TYPE_TB
zh: '| [`householder_product`](generated/torch.linalg.householder_product.html#torch.linalg.householder_product
"torch.linalg.householder_product") | 计算 Householder 矩阵的前 n 列的乘积。 |'
- en: Tensor Operations
id: totrans-40
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 张量操作
- en: '| [`tensorinv`](generated/torch.linalg.tensorinv.html#torch.linalg.tensorinv
"torch.linalg.tensorinv") | Computes the multiplicative inverse of [`torch.tensordot()`](generated/torch.tensordot.html#torch.tensordot
"torch.tensordot"). |'
id: totrans-41
prefs: []
type: TYPE_TB
zh: '| [`tensorinv`](generated/torch.linalg.tensorinv.html#torch.linalg.tensorinv
"torch.linalg.tensorinv") | 计算 [`torch.tensordot()`](generated/torch.tensordot.html#torch.tensordot
"torch.tensordot") 的乘法逆。 |'
- en: '| [`tensorsolve`](generated/torch.linalg.tensorsolve.html#torch.linalg.tensorsolve
"torch.linalg.tensorsolve") | Computes the solution X to the system torch.tensordot(A,
X) = B. |'
id: totrans-42
prefs: []
type: TYPE_TB
zh: '| [`tensorsolve`](generated/torch.linalg.tensorsolve.html#torch.linalg.tensorsolve
"torch.linalg.tensorsolve") | 计算系统 torch.tensordot(A, X) = B 的解 X。 |'
- en: Misc
id: totrans-43
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 其他
- en: '| [`vander`](generated/torch.linalg.vander.html#torch.linalg.vander "torch.linalg.vander")
| Generates a Vandermonde matrix. |'
id: totrans-44
prefs: []
type: TYPE_TB
zh: '| [`vander`](generated/torch.linalg.vander.html#torch.linalg.vander "torch.linalg.vander")
| 生成 Vandermonde 矩阵。 |'
- en: Experimental Functions
id: totrans-45
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 实验性功能
- en: '| [`cholesky_ex`](generated/torch.linalg.cholesky_ex.html#torch.linalg.cholesky_ex
"torch.linalg.cholesky_ex") | Computes the Cholesky decomposition of a complex
Hermitian or real symmetric positive-definite matrix. |'
id: totrans-46
prefs: []
type: TYPE_TB
zh: '| [`cholesky_ex`](generated/torch.linalg.cholesky_ex.html#torch.linalg.cholesky_ex
"torch.linalg.cholesky_ex") | 计算复 Hermite 或实对称正定矩阵的 Cholesky 分解。 |'
- en: '| [`inv_ex`](generated/torch.linalg.inv_ex.html#torch.linalg.inv_ex "torch.linalg.inv_ex")
| Computes the inverse of a square matrix if it is invertible. |'
id: totrans-47
prefs: []
type: TYPE_TB
zh: '| [`inv_ex`](generated/torch.linalg.inv_ex.html#torch.linalg.inv_ex "torch.linalg.inv_ex")
| 计算方阵的逆矩阵(如果可逆)。 |'
- en: '| [`solve_ex`](generated/torch.linalg.solve_ex.html#torch.linalg.solve_ex "torch.linalg.solve_ex")
| A version of [`solve()`](generated/torch.linalg.solve.html#torch.linalg.solve
"torch.linalg.solve") that does not perform error checks unless `check_errors`=
True. |'
id: totrans-48
prefs: []
type: TYPE_TB
zh: '| [`solve_ex`](generated/torch.linalg.solve_ex.html#torch.linalg.solve_ex "torch.linalg.solve_ex")
| [`solve()`](generated/torch.linalg.solve.html#torch.linalg.solve "torch.linalg.solve")
的一个版本,除非 `check_errors`= True,否则不执行错误检查。 |'
- en: '| [`lu_factor_ex`](generated/torch.linalg.lu_factor_ex.html#torch.linalg.lu_factor_ex
"torch.linalg.lu_factor_ex") | This is a version of [`lu_factor()`](generated/torch.linalg.lu_factor.html#torch.linalg.lu_factor
"torch.linalg.lu_factor") that does not perform error checks unless `check_errors`=
True. |'
id: totrans-49
prefs: []
type: TYPE_TB
zh: '| [`lu_factor_ex`](generated/torch.linalg.lu_factor_ex.html#torch.linalg.lu_factor_ex
"torch.linalg.lu_factor_ex") | 这是 [`lu_factor()`](generated/torch.linalg.lu_factor.html#torch.linalg.lu_factor
"torch.linalg.lu_factor") 的一个版本,除非 `check_errors`= True,否则不执行错误检查。 |'
- en: '| [`ldl_factor`](generated/torch.linalg.ldl_factor.html#torch.linalg.ldl_factor
"torch.linalg.ldl_factor") | Computes a compact representation of the LDL factorization
of a Hermitian or symmetric (possibly indefinite) matrix. |'
id: totrans-50
prefs: []
type: TYPE_TB
zh: '| [`ldl_factor`](generated/torch.linalg.ldl_factor.html#torch.linalg.ldl_factor
"torch.linalg.ldl_factor") | 计算 Hermite 或对称(可能不定)矩阵的 LDL 分解的紧凑表示。 |'
- en: '| [`ldl_factor_ex`](generated/torch.linalg.ldl_factor_ex.html#torch.linalg.ldl_factor_ex
"torch.linalg.ldl_factor_ex") | This is a version of [`ldl_factor()`](generated/torch.linalg.ldl_factor.html#torch.linalg.ldl_factor
"torch.linalg.ldl_factor") that does not perform error checks unless `check_errors`=
True. |'
id: totrans-51
prefs: []
type: TYPE_TB
zh: '| [`ldl_factor_ex`](generated/torch.linalg.ldl_factor_ex.html#torch.linalg.ldl_factor_ex
"torch.linalg.ldl_factor_ex") | 这是 [`ldl_factor()`](generated/torch.linalg.ldl_factor.html#torch.linalg.ldl_factor
"torch.linalg.ldl_factor") 的一个版本,除非 `check_errors`= True,否则不执行错误检查。 |'
- en: '| [`ldl_solve`](generated/torch.linalg.ldl_solve.html#torch.linalg.ldl_solve
"torch.linalg.ldl_solve") | Computes the solution of a system of linear equations
using the LDL factorization. |'
id: totrans-52
prefs: []
type: TYPE_TB
zh: '| [`ldl_solve`](generated/torch.linalg.ldl_solve.html#torch.linalg.ldl_solve
"torch.linalg.ldl_solve") | 使用 LDL 分解计算线性方程组的解。 |'
- en: torch.monitor
id: totrans-0
prefs:
- PREF_H1
type: TYPE_NORMAL
zh: torch.monitor
- en: 原文:[https://pytorch.org/docs/stable/monitor.html](https://pytorch.org/docs/stable/monitor.html)
id: totrans-1
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: 原文:[https://pytorch.org/docs/stable/monitor.html](https://pytorch.org/docs/stable/monitor.html)
- en: Warning
id: totrans-2
prefs: []
type: TYPE_NORMAL
zh: 警告
- en: This module is a prototype release, and its interfaces and functionality may
change without warning in future PyTorch releases.
id: totrans-3
prefs: []
type: TYPE_NORMAL
zh: 此模块是原型版本,其接口和功能可能在未来的PyTorch版本中发生变化而没有警告。
- en: '`torch.monitor` provides an interface for logging events and counters from
PyTorch.'
id: totrans-4
prefs: []
type: TYPE_NORMAL
zh: '`torch.monitor`提供了一个接口,用于从PyTorch记录事件和计数器。'
- en: The stat interfaces are designed to be used for tracking high level metrics
that are periodically logged out to be used for monitoring system performance.
Since the stats aggregate with a specific window size you can log to them from
critical loops with minimal performance impact.
id: totrans-5
prefs: []
type: TYPE_NORMAL
zh: 统计接口旨在用于跟踪定期记录的高级指标,以用于监视系统性能。由于统计数据与特定窗口大小聚合,因此可以从关键循环中记录它们,对性能影响最小。
- en: For more infrequent events or values such as loss, accuracy, usage tracking
the event interface can be directly used.
id: totrans-6
prefs: []
type: TYPE_NORMAL
zh: 对于更不频繁的事件或值,如损失、准确性、使用跟踪,可以直接使用事件接口。
- en: Event handlers can be registered to handle the events and pass them to an external
event sink.
id: totrans-7
prefs: []
type: TYPE_NORMAL
zh: 事件处理程序可以注册以处理事件并将其传递给外部事件接收器。
- en: '## API Reference'
id: totrans-8
prefs: []
type: TYPE_NORMAL
zh: '## API参考'
- en: '[PRE0]'
id: totrans-9
prefs: []
type: TYPE_PRE
zh: '[PRE0]'
- en: These are types of aggregations that can be used to accumulate stats.
id: totrans-10
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: 这些是可用于累积统计数据的聚合类型。
- en: 'Members:'
id: totrans-11
prefs: []
type: TYPE_NORMAL
zh: 成员:
- en: 'VALUE :'
id: totrans-12
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: VALUE:
- en: ''
id: totrans-13
prefs:
- PREF_BQ
type: TYPE_NORMAL
- en: VALUE returns the last value to be added.
id: totrans-14
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: VALUE返回最后添加的值。
- en: ''
id: totrans-15
prefs:
- PREF_BQ
type: TYPE_NORMAL
- en: 'MEAN :'
id: totrans-16
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: MEAN:
- en: ''
id: totrans-17
prefs:
- PREF_BQ
type: TYPE_NORMAL
- en: MEAN computes the arithmetic mean of all the added values.
id: totrans-18
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: MEAN计算所有添加值的算术平均值。
- en: ''
id: totrans-19
prefs:
- PREF_BQ
type: TYPE_NORMAL
- en: 'COUNT :'
id: totrans-20
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: COUNT:
- en: ''
id: totrans-21
prefs:
- PREF_BQ
type: TYPE_NORMAL
- en: COUNT returns the total number of added values.
id: totrans-22
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: COUNT返回添加值的总数。
- en: ''
id: totrans-23
prefs:
- PREF_BQ
type: TYPE_NORMAL
- en: 'SUM :'
id: totrans-24
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: SUM:
- en: ''
id: totrans-25
prefs:
- PREF_BQ
type: TYPE_NORMAL
- en: SUM returns the sum of the added values.
id: totrans-26
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: SUM返回添加值的总和。
- en: ''
id: totrans-27
prefs:
- PREF_BQ
type: TYPE_NORMAL
- en: 'MAX :'
id: totrans-28
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: MAX:
- en: ''
id: totrans-29
prefs:
- PREF_BQ
type: TYPE_NORMAL
- en: MAX returns the max of the added values.
id: totrans-30
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: MAX返回添加值的最大值。
- en: ''
id: totrans-31
prefs:
- PREF_BQ
type: TYPE_NORMAL
- en: 'MIN :'
id: totrans-32
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: MIN:
- en: ''
id: totrans-33
prefs:
- PREF_BQ
type: TYPE_NORMAL
- en: MIN returns the min of the added values.
id: totrans-34
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: MIN返回添加值的最小值。
- en: '[PRE1]'
id: totrans-35
prefs: []
type: TYPE_PRE
zh: '[PRE1]'
- en: '[PRE2]'
id: totrans-36
prefs: []
type: TYPE_PRE
zh: '[PRE2]'
- en: Stat is used to compute summary statistics in a performant way over fixed intervals.
Stat logs the statistics as an Event once every `window_size` duration. When the
window closes the stats are logged via the event handlers as a `torch.monitor.Stat`
event.
id: totrans-37
prefs: []
type: TYPE_NORMAL
zh: Stat用于以高效的方式在固定间隔内计算摘要统计信息。Stat每隔`window_size`持续时间记录一次统计信息作为事件。当窗口关闭时,统计信息将通过事件处理程序作为`torch.monitor.Stat`事件记录。
- en: '`window_size` should be set to something relatively high to avoid a huge number
of events being logged. Ex: 60s. Stat uses millisecond precision.'
id: totrans-38
prefs: []
type: TYPE_NORMAL
zh: '`window_size`应设置为相对较高的值,以避免记录大量事件。例如:60秒。Stat使用毫秒精度。'
- en: If `max_samples` is set, the stat will cap the number of samples per window
by discarding add calls once `max_samples` adds have occurred. If it’s not set,
all `add` calls during the window will be included. This is an optional field
to make aggregations more directly comparable across windows when the number of
samples might vary.
id: totrans-39
prefs: []
type: TYPE_NORMAL
zh: 如果设置了`max_samples`,则统计数据将通过在发生`max_samples`次添加后丢弃添加调用来限制每个窗口的样本数量。如果未设置,窗口期间的所有`add`调用都将被包括在内。当样本数量可能变化时,这是一个可选字段,使聚合更直接可比较。
- en: When the Stat is destructed it will log any remaining data even if the window
hasn’t elapsed.
id: totrans-40
prefs: []
type: TYPE_NORMAL
zh: 当Stat被销毁时,即使窗口尚未过去,也会记录任何剩余数据。
- en: '[PRE3]'
id: totrans-41
prefs: []
type: TYPE_PRE
zh: '[PRE3]'
- en: Constructs the `Stat`.
id: totrans-42
prefs: []
type: TYPE_NORMAL
zh: 构造`Stat`。
- en: '[PRE4]'
id: totrans-43
prefs: []
type: TYPE_PRE
zh: '[PRE4]'
- en: Adds a value to the stat to be aggregated according to the configured stat type
and aggregations.
id: totrans-44
prefs: []
type: TYPE_NORMAL
zh: 将一个值添加到要根据配置的统计类型和聚合进行聚合的统计数据中。
- en: '[PRE5]'
id: totrans-45
prefs: []
type: TYPE_PRE
zh: '[PRE5]'
- en: Number of data points that have currently been collected. Resets once the event
has been logged.
id: totrans-46
prefs: []
type: TYPE_NORMAL
zh: 当前已收集的数据点数量。一旦事件已记录,将重置。
- en: '[PRE6]'
id: totrans-47
prefs: []
type: TYPE_PRE
zh: '[PRE6]'
- en: Returns the current value of the stat, primarily for testing purposes. If the
stat has logged and no additional values have been added this will be zero.
id: totrans-48
prefs: []
type: TYPE_NORMAL
zh: 返回统计数据的当前值,主要用于测试目的。如果统计数据已记录且未添加任何额外值,则该值将为零。
- en: '[PRE7]'
id: totrans-49
prefs: []
type: TYPE_PRE
zh: '[PRE7]'
- en: The name of the stat that was set during creation.
id: totrans-50
prefs: []
type: TYPE_NORMAL
zh: 在创建时设置的统计名称。
- en: '[PRE8]'
id: totrans-51
prefs: []
type: TYPE_PRE
zh: '[PRE8]'
- en: data_value_t is one of `str`, `float`, `int`, `bool`.
id: totrans-52
prefs: []
type: TYPE_NORMAL
zh: data_value_t是`str`、`float`、`int`、`bool`之一。
- en: '[PRE9]'
id: totrans-53
prefs: []
type: TYPE_PRE
zh: '[PRE9]'
- en: Event represents a specific typed event to be logged. This can represent high-level
data points such as loss or accuracy per epoch or more low-level aggregations
such as through the Stats provided through this library.
id: totrans-54
prefs: []
type: TYPE_NORMAL
zh: Event表示要记录的特定类型事件。这可以表示每个时代的损失或准确性等高级数据点,或者通过此库提供的统计数据进行更低级别的聚合。
- en: All Events of the same type should have the same name so downstream handlers
can correctly process them.
id: totrans-55
prefs: []
type: TYPE_NORMAL
zh: 所有相同类型的事件应具有相同的名称,以便下游处理程序可以正确处理它们。
- en: '[PRE10]'
id: totrans-56
prefs: []
type: TYPE_PRE
zh: '[PRE10]'
- en: Constructs the `Event`.
id: totrans-57
prefs: []
type: TYPE_NORMAL
zh: 构造`Event`。
- en: '[PRE11]'
id: totrans-58
prefs: []
type: TYPE_PRE
zh: '[PRE11]'
- en: The structured data contained within the `Event`.
id: totrans-59
prefs: []
type: TYPE_NORMAL
zh: 包含在`Event`中的结构化数据。
- en: '[PRE12]'
id: totrans-60
prefs: []
type: TYPE_PRE
zh: '[PRE12]'
- en: The name of the `Event`.
id: totrans-61
prefs: []
type: TYPE_NORMAL
zh: '`Event`的名称。'
- en: '[PRE13]'
id: totrans-62
prefs: []
type: TYPE_PRE
zh: '[PRE13]'
- en: The timestamp when the `Event` happened.
id: totrans-63
prefs: []
type: TYPE_NORMAL
zh: 事件发生时的时间戳。
- en: '[PRE14]'
id: totrans-64
prefs: []
type: TYPE_PRE
zh: '[PRE14]'
- en: EventHandlerHandle is a wrapper type returned by `register_event_handler` used
to unregister the handler via `unregister_event_handler`. This cannot be directly
initialized.
id: totrans-65
prefs: []
type: TYPE_NORMAL
zh: EventHandlerHandle是由`register_event_handler`返回的包装类型,用于通过`unregister_event_handler`取消注册处理程序。不能直接初始化。
- en: '[PRE15]'
id: totrans-66
prefs: []
type: TYPE_PRE
zh: '[PRE15]'
- en: log_event logs the specified event to all of the registered event handlers.
It’s up to the event handlers to log the event out to the corresponding event
sink.
id: totrans-67
prefs: []
type: TYPE_NORMAL
zh: log_event将指定的事件记录到所有已注册的事件处理程序中。由事件处理程序负责将事件记录到相应的事件接收器。
- en: If there are no event handlers registered this method is a no-op.
id: totrans-68
prefs: []
type: TYPE_NORMAL
zh: 如果没有注册事件处理程序,则此方法不执行任何操作。
- en: '[PRE16]'
id: totrans-69
prefs: []
type: TYPE_PRE
zh: '[PRE16]'
- en: register_event_handler registers a callback to be called whenever an event is
logged via `log_event`. These handlers should avoid blocking the main thread since
that may interfere with training as they run during the `log_event` call.
id: totrans-70
prefs: []
type: TYPE_NORMAL
zh: register_event_handler注册一个回调,每当通过`log_event`记录事件时都会调用该回调。这些处理程序应避免阻塞主线程,因为这可能会干扰训练,因为它们在`log_event`调用期间运行。
- en: '[PRE17]'
id: totrans-71
prefs: []
type: TYPE_PRE
zh: '[PRE17]'
- en: unregister_event_handler unregisters the `EventHandlerHandle` returned after
calling `register_event_handler`. After this returns the event handler will no
longer receive events.
id: totrans-72
prefs: []
type: TYPE_NORMAL
zh: unregister_event_handler取消注册在调用`register_event_handler`后返回的`EventHandlerHandle`。完成后,事件处理程序将不再接收事件。
- en: '[PRE18]'
id: totrans-73
prefs: []
type: TYPE_PRE
zh: '[PRE18]'
- en: TensorboardEventHandler is an event handler that will write known events to
the provided SummaryWriter.
id: totrans-74
prefs: []
type: TYPE_NORMAL
zh: TensorboardEventHandler是一个事件处理程序,将已知事件写入提供的SummaryWriter。
- en: This currently only supports `torch.monitor.Stat` events which are logged as
scalars.
id: totrans-75
prefs: []
type: TYPE_NORMAL
zh: 目前仅支持作为标量记录的`torch.monitor.Stat`事件。
- en: Example
id: totrans-76
prefs: []
type: TYPE_NORMAL
zh: 示例
- en: '[PRE19]'
id: totrans-77
prefs: []
type: TYPE_PRE
zh: '[PRE19]'
- en: '[PRE20]'
id: totrans-78
prefs: []
type: TYPE_PRE
zh: '[PRE20]'
- en: Constructs the `TensorboardEventHandler`.
id: totrans-79
prefs: []
type: TYPE_NORMAL
zh: 构造`TensorboardEventHandler`。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册