Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

what is the correct shape for TSM expected? #204

Open
mbilalshaikh opened this issue Sep 19, 2021 · 1 comment
Open

what is the correct shape for TSM expected? #204

mbilalshaikh opened this issue Sep 19, 2021 · 1 comment

Comments

@mbilalshaikh
Copy link

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$

@junjun1023
Copy link

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

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

No branches or pull requests

2 participants