Output result:
Matrix A Shape: torch.Size([10, 20])Matrix B Shape: torch.Size([20, 30])Matrix C Shape: torch.Size([30, 40])Matrix D Shape: torch.Size([40, 50])Result Shape: torch.Size([10, 50])
Example - Using a List
import torch
# Matrix List
matrices =[torch.randn(10,20),
torch.randn(20,30),
torch.randn(30,40)]
# Using Lists as Arguments
result = torch.chain_matmul(*matrices)
print("Result Shape:", result.shape)
YouTip