Cerenaut / pt-aha

AHA implemented in PyTorch. New features are being implemented here (not in the TF version).
Apache License 2.0
0 stars 2 forks source link

aha_config Error ? #19

Closed anhhuyalex closed 2 years ago

anhhuyalex commented 2 years ago

Hello,

When I run python oneshot_cls.py --config definitions/aha_config.json on PyTorch version 1.9.1+cu111 I obtain the following error

Traceback (most recent call last):
  File "oneshot_cls.py", line 373, in <module>
    main()
  File "oneshot_cls.py", line 130, in main
    model = CLS(image_shape, config, device=device, writer=writer).to(device)
  File "/gpfs/loomis/project/turk-browne/an633/pt-aha/cls_module/cls_module/cls.py", line 43, in __init__
    self.build()
  File "/gpfs/loomis/project/turk-browne/an633/pt-aha/cls_module/cls_module/cls.py", line 71, in build
    writer=self.writer)
  File "/gpfs/loomis/project/turk-browne/an633/pt-aha/cls_module/cls_module/memory/interface.py", line 24, in __init__
    self.build()
  File "/gpfs/loomis/project/turk-browne/an633/pt-aha/cls_module/cls_module/memory/ltm/visual_component.py", line 21, in build
    vc = SparseAutoencoder(self.input_shape, self.config).to(self.device)
  File "/gpfs/loomis/project/turk-browne/an633/cerenaut-pt-core/cerenaut_pt_core/components/sparse_autoencoder.py", line 55, in __init__
    self.build()
  File "/gpfs/loomis/project/turk-browne/an633/cerenaut-pt-core/cerenaut_pt_core/components/sparse_autoencoder.py", line 97, in build
    padding=self.config['encoder_padding'])
  File "/gpfs/loomis/project/turk-browne/an633/conda_envs/unsup_plastic/lib/python3.7/site-packages/torch/nn/modules/conv.py", line 432, in __init__
    False, _pair(0), groups, bias, padding_mode, **factory_kwargs)
  File "/gpfs/loomis/project/turk-browne/an633/conda_envs/unsup_plastic/lib/python3.7/site-packages/torch/nn/modules/conv.py", line 94, in __init__
    raise ValueError("padding='same' is not supported for strided convolutions")
ValueError: padding='same' is not supported for strided convolutions

It appears that the issue is the settings for the ltm

"stride": 5,
  "eval_stride": 1,
  "encoder_padding": "same",
  "decoder_padding": "same",

When replaced with "encoder_padding": 0 and "decoder_padding": 0, the problem goes away.

abdel commented 2 years ago

@anhhuyalex Sorry for the late response. The reason for this error is that at the time, PyTorch did not have same padding implementation until PyTorch 1.9. So we had a custom implementation of same padding implemented.

So at the moment, pt-aha does not work as expected with PyTorch 1.9. We're planning on updating this in the near future to bring it up to date with the most recent PyTorch versions.

In the meantime, you could try using PyTorch 1.8 or lower.