美文网首页
TensorFLow 函数翻译 — tf.matmul()

TensorFLow 函数翻译 — tf.matmul()

作者: HabileBadger | 来源:发表于2016-12-23 21:13 被阅读35431次

    tf.matmul(a, b, transpose_a=False, transpose_b=False, adjoint_a=False, adjoint_b=False, a_is_sparse=False, b_is_sparse=False, name=None)###


    Multiplies matrix a by matrix b, producing a * b.

    将矩阵a 乘于 矩阵b。

    The inputs must be matrices (or tensors of rank > 2, representing batches of matrices), with matching inner dimensions, possibly after transposition.
    Both matrices must be of the same type. The supported types are: float16, float32, float64, int32, complex64, complex128.

    输入必须是矩阵(或者是张量秩 >2的张量,表示成批的矩阵),并且其在转置之后有相匹配的矩阵尺寸。
    两个矩阵必须都是同样的类型,支持的类型如下:float16, float32, float64, int32, complex64, complex128。

    Either matrix can be transposed or adjointed (conjugated and transposed) on the fly by setting one of the corresponding flag to True. These are False by default.

    任意一个矩阵都可以通过设置被转置 或 adjointed(共轭和转置)为真时进行对应的操作。两个参数都默认为假

    If one or both of the matrices contain a lot of zeros, a more efficient multiplication algorithm can be used by setting the corresponding a_is_sparse or b_is_sparse flag to True.
    These are False by default. This optimization is only available for plain matrices (rank-2 tensors) with datatypes bfloat16 or float32.

    如果一个或两个矩阵都包含大量的零,当**a_is_sparse b_is_sparse **设置为真时,会使用一个更有效率的乘法公式。
    他们都默认设置为假。这个优化规则只能适用于类型为bfloat16 或 bfloat32 的平面矩阵(等级2的张量)。

    For example:
    # 2-D tensor aa = tf.constant([1, 2, 3, 4, 5, 6], shape=[2, 3]) => [[1. 2. 3.] [4. 5. 6.]]
    # 2-D tensor bb = tf.constant([7, 8, 9, 10, 11, 12], shape=[3, 2]) => [[7. 8.] [9. 10.] [11. 12.]]c = tf.matmul(a, b) => [[58 64] [139 154]]
    # 3-D tensor aa = tf.constant(np.arange(1,13), shape=[2, 2, 3]) => [[[ 1. 2. 3.] [ 4. 5. 6.]], [[ 7. 8. 9.] [10. 11. 12.]]]
    # 3-D tensor bb = tf.constant(np.arange(13,25), shape=[2, 3, 2]) => [[[13. 14.] [15. 16.] [17. 18.]], [[19. 20.] [21. 22.] [23. 24.]]]c = tf.matmul(a, b) => [[[ 94 100] [229 244]], [[508 532] [697 730]]]

    例如:
    # 2-D tensor \a` a = tf.constant([1, 2, 3, 4, 5, 6], shape=[2, 3]) => [[1. 2. 3.] [4. 5. 6.]]# 2-D tensor `b` b = tf.constant([7, 8, 9, 10, 11, 12], shape=[3, 2]) => [[7. 8.] [9. 10.] [11. 12.]]c = tf.matmul(a, b) => [[58 64] [139 154]]# 3-D tensor `a` a = tf.constant(np.arange(1,13), shape=[2, 2, 3]) => [[[ 1. 2. 3.] [ 4. 5. 6.]], [[ 7. 8. 9.] [10. 11. 12.]]]# 3-D tensor `b` b = tf.constant(np.arange(13,25), shape=[2, 3, 2]) => [[[13. 14.] [15. 16.] [17. 18.]], [[19. 20.] [21. 22.] [23. 24.]]]c = tf.matmul(a, b) => [[[ 94 100] [229 244]], [[508 532] [697 730]]] `

    Args:
    a: Tensor of type float16, float32, float64, int32, complex64, complex128 and rank > 1.
    b: Tensor with same type and rank as a.
    transpose_a: If True, a is transposed before multiplication.
    transpose_b: If True, b is transposed before multiplication.
    adjoint_a: If True, a is conjugated and transposed before multiplication.
    adjoint_b: If True, b is conjugated and transposed before multiplication.
    a_is_sparse: If True, a is treated as a sparse matrix.
    b_is_sparse: If True, b is treated as a sparse matrix.
    name: Name for the operation (optional).

    参数:
    a: 一个类型为 float16, float32, float64, int32, complex64, complex128 且张量秩 > 1 的张量。
    b: 一个类型跟张量a相同的张量。
    transpose_a: 如果为真, a则在进行乘法计算前进行转置。
    transpose_b: 如果为真, b则在进行乘法计算前进行转置。
    adjoint_a: 如果为真, a则在进行乘法计算前进行共轭和转置。
    adjoint_b: 如果为真, b则在进行乘法计算前进行共轭和转置。
    a_is_sparse: 如果为真, a会被处理为稀疏矩阵。
    b_is_sparse: 如果为真, b会被处理为稀疏矩阵。
    name: 操作的名字(可选参数)

    Returns:

    A Tensor of the same type as a and b where each inner-most matrix is the product of the corresponding matrices in a and b, e.g. if all transpose or adjoint attributes areFalse: output[..., :, :] = a[..., :, :] * b[..., :, :] ,

    返回值:
    一个跟张量a和张量b类型一样的张量且最内部矩阵是a和b中的相应矩阵的乘积。如果所有的转置或adjoint参数都为假,则公式为output[..., :, :] = a[..., :, :] * b[..., :, :] ,

    Raises:
    ValueError: If transpose_a and adjoint_a, or transpose_b and adjoint_b are both set to True.

    引发错误:
    ValueError: 如果transpose_aadjoint_a, 或 transpose_badjoint_b 都被设置为真

    相关文章

      网友评论

          本文标题:TensorFLow 函数翻译 — tf.matmul()

          本文链接:https://www.haomeiwen.com/subject/lsakvttx.html