Torch - repeat tensor like numpy repeat -


i trying repeat tensor in torch in 2 ways. example repeating tensor {1,2,3,4} 3 times both ways yield;

{1,2,3,4,1,2,3,4,1,2,3,4} {1,1,1,2,2,2,3,3,3,4,4,4} 

there built in torch:repeattensor function generate first of 2 (like numpy.tile()) can't find 1 latter (like numpy.repeat()). i'm sure call sort on first give second think might computationally expensive larger arrays?

thanks.

a = torch.tensor{1,2,3,4} 

to {1,2,3,4,1,2,3,4,1,2,3,4} repeat tensor thrice in 1st dimension:

a:repeattensor(3) 

to {1,1,1,2,2,2,3,3,3,4,4,4} add dimension tensor , repeat thrice in 2nd dimension 4 x 3 tensor, can flatten.

b = a:reshape(4,1):repeattensor(1,3) b:view(b:nelement()) 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -