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

decoder input shape #3

Open
entalent opened this issue Jun 11, 2019 · 4 comments
Open

decoder input shape #3

entalent opened this issue Jun 11, 2019 · 4 comments

Comments

@entalent
Copy link

When running resnet.py, there is following error:

Traceback (most recent call last):
  File "/home/wentian/.pycharm_helpers/pydev/pydevd.py", line 1741, in <module>
    main()
  File "/home/wentian/.pycharm_helpers/pydev/pydevd.py", line 1735, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/home/wentian/.pycharm_helpers/pydev/pydevd.py", line 1135, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/home/wentian/.pycharm_helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/home/wentian/work/caption_t_r_2/src/test.py", line 359, in <module>
    pred = autoencoder(inputs)
  File "/home/wentian/library/miniconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/wentian/work/caption_t_r_2/src/test.py", line 262, in forward
    x = self.decoder(x)
  File "/home/wentian/library/miniconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/wentian/work/caption_t_r_2/src/test.py", line 213, in forward
    x = F.relu(self.bn3(x))
  File "/home/wentian/library/miniconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/wentian/library/miniconda3/lib/python3.6/site-packages/torch/nn/modules/batchnorm.py", line 45, in forward
    self._check_input_dim(input)
  File "/home/wentian/library/miniconda3/lib/python3.6/site-packages/torch/nn/modules/batchnorm.py", line 193, in _check_input_dim
    .format(input.dim()))
ValueError: expected 4D input (got 2D input)

At line 262, the shape of x is (11, 48).

@arnaghosh
Copy link
Owner

Hi,
What is the batchsize for the input you passed?
You need to pass the input to the autoencoder as (batchSize, n_channels, x_size, y_size).

@tjusxh
Copy link

tjusxh commented Oct 31, 2019

maybe BatchNormalization2d cause the error.

@helloicyvodka
Copy link

change the BatchNorm2d to BatchNorm1d in Decoder

@arnaghosh
Copy link
Owner

I think you are right. I don't remember why I had BatchNorm2d in decoder. It could be something specific to what I was trying to achieve but BatchNorm1d seems to be the correct choice.
Thanks :)

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

4 participants