本文簡要介紹python語言中 torch.kron
的用法。
用法:
torch.kron(input, other, *, out=None) → Tensor
計算
input
和other
的克羅內克積,用 表示。如果
input
是 張量且other
是 張量,則結果將是具有以下條目的 張量:其中 為 。如果一個張量的維數比另一個少,則它不會被壓縮,直到它具有相同的維數。
支持實值和complex-valued 輸入。
注意
如上所述,此函數將兩個矩陣的 Kronecker 積的典型定義推廣到兩個張量。當
input
是 矩陣並且other
是 矩陣時,結果將是 塊矩陣:其中
input
是 和other
是 。例子:
>>> mat1 = torch.eye(2) >>> mat2 = torch.ones(2, 2) >>> torch.kron(mat1, mat2) tensor([[1., 1., 0., 0.], [1., 1., 0., 0.], [0., 0., 1., 1.], [0., 0., 1., 1.]]) >>> mat1 = torch.eye(2) >>> mat2 = torch.arange(1, 5).reshape(2, 2) >>> torch.kron(mat1, mat2) tensor([[1., 2., 0., 0.], [3., 4., 0., 0.], [0., 0., 1., 2.], [0., 0., 3., 4.]])
相關用法
- Python PyTorch kaiming_normal_用法及代碼示例
- Python PyTorch kthvalue用法及代碼示例
- Python PyTorch keypointrcnn_resnet50_fpn用法及代碼示例
- Python PyTorch kaiming_uniform_用法及代碼示例
- Python PyTorch frexp用法及代碼示例
- Python PyTorch jvp用法及代碼示例
- Python PyTorch cholesky用法及代碼示例
- Python PyTorch vdot用法及代碼示例
- Python PyTorch ELU用法及代碼示例
- Python PyTorch ScaledDotProduct.__init__用法及代碼示例
- Python PyTorch gumbel_softmax用法及代碼示例
- Python PyTorch get_tokenizer用法及代碼示例
- Python PyTorch saved_tensors_hooks用法及代碼示例
- Python PyTorch positive用法及代碼示例
- Python PyTorch renorm用法及代碼示例
- Python PyTorch AvgPool2d用法及代碼示例
- Python PyTorch MaxUnpool3d用法及代碼示例
- Python PyTorch Bernoulli用法及代碼示例
- Python PyTorch Tensor.unflatten用法及代碼示例
- Python PyTorch Sigmoid用法及代碼示例
- Python PyTorch Tensor.register_hook用法及代碼示例
- Python PyTorch ShardedEmbeddingBagCollection.named_parameters用法及代碼示例
- Python PyTorch sqrt用法及代碼示例
- Python PyTorch PackageImporter.id用法及代碼示例
- Python PyTorch column_stack用法及代碼示例
注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torch.kron。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。