PyTorch torch.matrix_exp 函数

约 314 字 更新于 2026-11-18 5iyo.com

PyTorch torch.matrix_exp 函数


torch.matrix_exp 是 PyTorch 中用于计算矩阵指数的函数。

函数定义

torch.matrix_exp(input)

使用示例

实例

import torch

# 创建方阵
A = torch.tensor([[1.0, 0.0], [0.0, 1.0]])

# 计算矩阵指数
exp_A = torch.matrix_exp(A)
print("矩阵指数:")
print(exp_A)

输出结果为:

矩阵指数:
tensor([[2.7183, 0.0000],
        [0.0000, 2.7183]])