Skip to content

Conversation

@rs9000
Copy link

@rs9000 rs9000 commented Jan 22, 2019

Hi,
Need a fix to handle models which require multiple inputs.
My fix is very ungly, but the idea is iterate on input list and add mini-batch only if it required.

#Iterate bag of inputs
for i in range(len(self.inputs)):
# Add mini-batch dim if not exist
if len(self.inputs[i].size()) == 1:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if I am wrong, if the inputs is a tensor with shape >2 then it won't have the batch dim in the first. So you want to be able to pass multiple inputs to your model at once, am I right?

Copy link
Author

@rs9000 rs9000 Jan 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to pass as input an array which contains tensors that already have the mini batch size.

Many models require two inputs, vqa for example, require image and question.
They are usually packed into an array where input[0] is the image and input[1] is the question.

My fix want iterate over the input array and for each tensor we add mini-batch only if the shape is equal to 1. Because tensors with shape > 1 I suppose already have a mini-batch size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants