temporal-shift-module icon indicating copy to clipboard operation
temporal-shift-module copied to clipboard

what is the correct shape for TSM expected?

Open mbilalshaikh opened this issue 3 years ago • 1 comments

params = [] for child in list(model.children())[:-1]: params.extend(list(child.parameters())) model.avg_pool = nn.Identity() print(len(X),X.shape) # shape of x: [N, T, C, H, W] d = torch.rand((64,8,3,256,256),dtype=torch.float32).to(device) preds = model(d,8)

File "/home/muhammadbsheikh/anaconda3/envs/open-mmlab2/lib/python3.7/site-packages/torch/nn/functional.py", line 1370, in linear ret = torch.addmm(bias, input, weight.t()) RuntimeError: size mismatch, m1: [64 x 1572864], m2: [2048 x 101] at /pytorch/aten/src/THC/generic/THCTensorMathBlas.cu:290 (open-mmlab2) muhammadbsheikh@LambdaBlade:~/workspace/projects/AV_HAR_MBS$

mbilalshaikh avatar Sep 19 '21 23:09 mbilalshaikh

Hi, according the implementation of TSM,

  @staticmethod
  def shift(x, n_segment, fold_div=3, inplace=False):
      nt, c, h, w = x.size()
      n_batch = nt // n_segment
      x = x.view(n_batch, n_segment, c, h, w)

input tensor size should be (n_batch * n_segment, C, H, W), and (N*T, C, H, W) in your case

junjun1023 avatar Mar 29 '22 01:03 junjun1023