Split Tensor

12 views
Skip to first unread message

Tuấn Nguyễn Anh Hoàng

unread,
Sep 29, 2016, 10:46:28 PM9/29/16
to torch7
Hi all,

I want to create a model which includes a module that can split a mini-batch input into 2 unequal parts, specifically 1/5 and 4/5.
Currently, I use nn.Narrow. However,  this requires the batch size known at the model-create time. Which reduces the flexibility in the training phase.

local splitFeatureModule = nn.ConcatTable()

splitFeatureModule
:add(nn.Narrow(1, 1, batchSize/5))        
splitFeatureModule
:add(nn.Narrow(1, batchSize/5 + 1, -1))

Is there any way to create a module which has the same function but independence to the batch size?

Any idea is always appreciated. Thank you very much.

Have a great day all. 

Best regards

soumith

unread,
Sep 30, 2016, 8:20:35 AM9/30/16
to torch7 on behalf of Tuấn Nguyễn Anh Hoàng
torch.chunk does this

--
You received this message because you are subscribed to the Google Groups "torch7" group.
To unsubscribe from this group and stop receiving emails from it, send an email to torch7+unsubscribe@googlegroups.com.
To post to this group, send email to tor...@googlegroups.com.
Visit this group at https://groups.google.com/group/torch7.
For more options, visit https://groups.google.com/d/optout.

Tuấn Nguyễn Anh Hoàng

unread,
Sep 30, 2016, 8:36:44 AM9/30/16
to torch7
Thank you very much.
torch.chunk can do quite the same task, however, it is not a module. 


On Friday, September 30, 2016 at 8:20:35 PM UTC+8, smth chntla wrote:
torch.chunk does this

On Thu, Sep 29, 2016 at 10:46 PM, Tuấn Nguyễn Anh Hoàng via torch7 <torch7+APn2wQdUwFKOqDMio0QkML4VotH3jmhAzEj3NDWpHoJX0L_5-p7YOeo7k@googlegroups.com> wrote:
Hi all,

I want to create a model which includes a module that can split a mini-batch input into 2 unequal parts, specifically 1/5 and 4/5.
Currently, I use nn.Narrow. However,  this requires the batch size known at the model-create time. Which reduces the flexibility in the training phase.

local splitFeatureModule = nn.ConcatTable()

splitFeatureModule
:add(nn.Narrow(1, 1, batchSize/5))        
splitFeatureModule
:add(nn.Narrow(1, batchSize/5 + 1, -1))

Is there any way to create a module which has the same function but independence to the batch size?

Any idea is always appreciated. Thank you very much.

Have a great day all. 

Best regards

--
You received this message because you are subscribed to the Google Groups "torch7" group.
To unsubscribe from this group and stop receiving emails from it, send an email to torch7+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages