PyTorch-Wavelet-Toolbox icon indicating copy to clipboard operation
PyTorch-Wavelet-Toolbox copied to clipboard

3D doesn't work

Open mahfuzalhasan opened this issue 1 year ago • 1 comments

I have tried to pass tensor of shape B,C,D,H,W but internally it adds a dimension after B. So the tensor becomes B,1,C,D,H,W. Then it fails to conv3d. Is there anyway to resolve this?

mahfuzalhasan avatar Apr 04 '24 20:04 mahfuzalhasan

Dear @mahfuzalhasan ,

running,

import ptwt
import torch
data = torch.randn(1,2,64,64,64)
print([(key, coeff.shape) for key, coeff in ptwt.wavedec3(data, wavelet="haar", level=5)[-1].items()])

prints

[('aad', torch.Size([1, 2, 32, 32, 32])), ('ada', torch.Size([1, 2, 32, 32, 32])), ('add', torch.Size([1, 2, 32, 32, 32])), ('daa', torch.Size([1, 2, 32, 32, 32])), ('dad', torch.Size([1, 2, 32, 32, 32])), ('dda', torch.Size([1, 2, 32, 32, 32])), ('ddd', torch.Size([1, 2, 32, 32, 32]))]

I don't see the extra dimension here. Could you please provide a minimal code example, which allows the reproduction of your problem?

v0lta avatar Apr 07 '24 11:04 v0lta

Greetings Volta,

Sorry that I got disconnected before rsolving the issue. The error that I am getting running the same code you provided is the following:

../lib/python3.8/site-packages/ptwt/conv_transform_3.py", line 159, in wavedec3
    res = torch.nn.functional.conv3d(res_lll, dec_filt, stride=2)
RuntimeError: Expected 4D (unbatched) or 5D (batched) input to conv3d, but got input of size: [1, 1, 2, 64, 64, 64].

Can you please tell me what should I do to resolve this? I am using ptwt 0.1.6

mahfuzalhasan avatar Jun 17 '24 23:06 mahfuzalhasan

Dear @mahfuzalhasan, version 0.1.7 introduced support for multi-dimensional inputs. Please update your installation to a more recent version by typing

pip install --upgrade ptwt

.

v0lta avatar Jun 18 '24 09:06 v0lta

To upgrade, you must install a more recent version of Python. With the 0.1.7 release, we dropped support for Python version 3.8.

v0lta avatar Jun 18 '24 09:06 v0lta

I am closing this due to a lack of activity. Feel free to reopen.

v0lta avatar Jun 26 '24 12:06 v0lta