Stack matrices of repeating nature

I want to stack matrices A, B, C,…,C. Here C is repeated 20 times. Please may I know an efficient way to do it?
Please help

2 Likes

Use repeat and stack e.g. for 2d matrices:

torch.stack([A,B,*C.unsqueeze(0).repeat(20,1,1)])
3 Likes