Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save RonRichman/326da7ccb459d892457f4f742d71a0f2 to your computer and use it in GitHub Desktop.
Save RonRichman/326da7ccb459d892457f4f742d71a0f2 to your computer and use it in GitHub Desktop.
t1 <- torch_tensor(array(1:50, dim = c(2, 25)))
t1[1,]
batch_size <- 2
no_embeds = 5
embed_dim = 5
t1_reshape <- torch_unsqueeze(t1,3)
t1_reshape2 <- torch_reshape(t1_reshape,c(batch_size, no_embeds, embed_dim))
t1_reshape3 <- torch_transpose(t1_reshape2,2,1)
t1_reshape
t1_reshape2[1,,]
t1_reshape3[,1,]
t1_reshape4 <- torch_transpose(t1_reshape3,1,2)
t1_reshape5 <- torch_reshape(t1_reshape4, c(batch_size, no_embeds*embed_dim))
#t1_reshape6 <- torch_squeeze(t1_reshape5,dim = 3)
t1_reshape5[1,]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment