nn.JoinTable() in new dimension?

340 views
Skip to first unread message

Johnny ho

unread,
Nov 2, 2015, 9:42:15 PM11/2/15
to torch7
Let say I have a table of 3 tenor.

{
1: double Tensor of 100x20x30
2:double Tensor of 100x20x30
3:double Tensor of 100x20x30
}

I want to join these tensors and make a tensor of 3x100x20x30. I know nn.JoinTable can do something like 300x20x30 (in dim 1), but it cannot create a new dimension, any ideas on how to do this?

alban desmaison

unread,
Nov 3, 2015, 4:06:16 AM11/3/15
to torch7
You should use view to add one dimension to your tensor to get 1x100x20x30 so you can use the nn.JoinTable module.
In this case you can either use the view function on your tensor before feeding them to the network https://github.com/torch/torch7/blob/master/doc/tensor.md#result-viewresult-tensor-sizes
Or you can use the nn.View module in your network to add a dimension https://github.com/torch/nn/blob/master/doc/simple.md#nn.View

Johnny ho

unread,
Nov 3, 2015, 11:35:11 AM11/3/15
to torch7
Thanks! I will try that.

liangjz

unread,
Dec 26, 2015, 7:46:29 AM12/26/15
to torch7
what if i have a 2 dims tensor T[m,n], T want to turn it into T[1,m,n], but i don't know what m,n  are, can i finish this operate by applying a simple nn layer ?

在 2015年11月3日星期二 UTC+8下午5:06:16,alban desmaison写道:

abc123

unread,
Dec 26, 2015, 2:48:59 PM12/26/15
to torch7
You can use nn.Replicate() if you don't know the dimensions apriori.
nn.Replicate(1,1) will work.
Reply all
Reply to author
Forward
0 new messages