Apply the same CNN to a list of images simultaneously

Hi all,

Assuming I have a input tensor with shape B x N x C x H x W, I want to apply the same CNN model f across the dimension N.

For now, I use for-loop to go over it.

out = []
for i in range(N):
    out.append(self.conv(input[:, i])

I was wondering if there is any elegant way to do this.


1 Like

I work with spatio temporal data and implement stuff like you. My N is the temporal dimension. I have not found any other way than use a loop. Hope some1 can suggest some vectorization style approach

You can check Pytorch source code for some better implementation