4/11/2022

torch repeat example

 Refer to code

..

batch_size=100
input_seq=140
input_dim=5
rand_input = torch.rand(batch_size, input_seq, input_dim)

repeat_output = rand_input.repeat(1, 1, 1)
print(f'input :{rand_input.shape}, repeat:{repeat_output.shape}')

repeat_output = rand_input.repeat(1, 10, 1)
print(f'input :{rand_input.shape}, repeat:{repeat_output.shape}')

repeat_output = rand_input.repeat(1, 1, 10)
print(f'input :{rand_input.shape}, repeat:{repeat_output.shape}')

repeat_output = rand_input.repeat(10, 1, 1)
print(f'input :{rand_input.shape}, repeat:{repeat_output.shape}')

..

>>

input :torch.Size([100, 140, 5]), repeat:torch.Size([100, 140, 5])
input :torch.Size([100, 140, 5]), repeat:torch.Size([100, 1400, 5])
input :torch.Size([100, 140, 5]), repeat:torch.Size([100, 140, 50])
input :torch.Size([100, 140, 5]), repeat:torch.Size([1000, 140, 5])



Thank you.
www.marearts.com