AlessioGalluccio / FastFlow

an implementation of the architecture of FastFlow (Jiawei Yu et al.)
MIT License
40 stars 13 forks source link

RuntimeError: Node 'conv_high_res_0' resp. TypeError: conv2d(): argument 'padding' #12

Open stvogel opened 2 years ago

stvogel commented 2 years ago

Thanks for providing your code for FastFlow. I try to train it but I got the following error:

Traceback (most recent call last):
  File "./FastFlow/FrEIA/framework/graph_inn.py", line 300, in forward
    mod_out = node.module(mod_in, rev=rev, jac=jac)
  File "~/.pyenv/versions/3.8.12/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "./FastFlow/FrEIA/modules/all_in_one_block.py", line 248, in forward
    a1 = self.subnet(x1c)
  File "~/.pyenv/versions/3.8.12/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "~/.pyenv/versions/3.8.12/lib/python3.8/site-packages/torch/nn/modules/container.py", line 119, in forward
    input = module(input)
  File "~/.pyenv/versions/3.8.12/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "~/.pyenv/versions/3.8.12/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 399, in forward
    return self._conv_forward(input, self.weight, self.bias)
  File "~/.pyenv/versions/3.8.12/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 395, in _conv_forward
    return F.conv2d(input, weight, bias, self.stride,
TypeError: conv2d(): argument 'padding' (position 5) must be tuple of ints, not str

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "main.py", line 29, in <module>
    model = train(train_loader, test_loader)
  File "./FastFlow/train.py", line 86, in train
    z, log_jac_det = model(inputs)
  File "~/.pyenv/versions/3.8.12/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "./FastFlow/model.py", line 133, in forward
    z, log_jac_det = self.nf(feat_s)
  File "~/.pyenv/versions/3.8.12/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "./FastFlow/FrEIA/framework/graph_inn.py", line 302, in forward
    raise RuntimeError(f"{node} encountered an error.") from e
RuntimeError: Node 'conv_high_res_0': [(24, 24, 768)] -> AllInOneBlock -> [(24, 24, 768)] encountered an error.

I'm not sure what's the error here. I assumed it was the padding-problem (which was a problem between version of torch before 1.8) I'm using torch 1.8 but I cannot find any padding-problems.

Did someone else got this error?

AlessioGalluccio commented 2 years ago

Hi @stvogel, I use torch 1.10.0 and I never got that error. Did you modify the code in some way? If there is a way to solve this issue, I'm ready to fix the code. Best, Alessio

stvogel commented 2 years ago

Hi @AlessioGalluccio,

ahh torch 1.10.0 did the trick. Thanks a lot for your hint. Maybe this version should be added to the requirements.txt.

AlessioGalluccio commented 2 years ago

That's a great idea. I updated it. Thank you very much. Best, Alessio

gaowq2017 commented 2 years ago

Hi @AlessioGalluccio, I haven't update the version of torch and the code can run. The detial as follow:

image Only change this way.

Wangj688 commented 2 years ago

hi, i can't find the file to modify

hondazeon commented 2 years ago

Hi, @Wangj688 The code fragment @gaowq2017 mentioned is in model.py. It worked fine with torch1.8.2 on windows10.