Open m-hajiabadi opened 5 months ago
Hi Morteza, thank you for bringing up the issue. I am a bit busy today and will try to get back to you later today.
I am still waiting for your review and reply. This code has problems such as: problems in indentations and variable referenced before assignment.
I am still waiting for your review and reply. This code has problems such as problems in indentations and variables referenced before the assignment.
Hi Morteza, I was trying to figure out the 3d gradient problem you mentioned. However, the HPC I used is now under maintenance so I was not able to try it out for now. So apart from the problem in the gradient loss calculation, can you specify also where exactly 'problems in indentations and variable referenced before assignment' so I can sort them out all together once the HPC is available?
Ok, I list all the problems I faced in the code.
1) TabError: inconsistent use of tabs and spaces in indentation in models/networks.py :
Traceback (most recent call last):
File "/kaggle/working/OCT2Confocal_3DCycleGAN/train.py", line 22, in <module>
from options.train_options import TrainOptions
File "/kaggle/working/OCT2Confocal_3DCycleGAN/options/train_options.py", line 1, in <module>
from .base_options import BaseOptions
File "/kaggle/working/OCT2Confocal_3DCycleGAN/options/base_options.py", line 5, in <module>
import models
File "/kaggle/working/OCT2Confocal_3DCycleGAN/models/__init__.py", line 22, in <module>
from models.base_model import BaseModel
File "/kaggle/working/OCT2Confocal_3DCycleGAN/models/base_model.py", line 5, in <module>
from . import networks
File "/kaggle/working/OCT2Confocal_3DCycleGAN/models/networks.py", line 431
model += [nn.Conv3d(ngf, output_nc, kernel_size=(7,7,7), padding=0)]
TabError: inconsistent use of tabs and spaces in indentation
After fix the problem 1, I faced the problem 2. 2) TabError: inconsistent use of tabs and spaces in indentation in models/cycle_gan_model.py:
Traceback (most recent call last):
File "/kaggle/working/OCT2Confocal_3DCycleGAN/train.py", line 28, in <module>
opt = TrainOptions().parse() # get training options
File "/kaggle/working/OCT2Confocal_3DCycleGAN/options/base_options.py", line 118, in parse
opt = self.gather_options()
File "/kaggle/working/OCT2Confocal_3DCycleGAN/options/base_options.py", line 78, in gather_options
model_option_setter = models.get_option_setter(model_name)
File "/kaggle/working/OCT2Confocal_3DCycleGAN/models/__init__.py", line 50, in get_option_setter
model_class = find_model_using_name(model_name)
File "/kaggle/working/OCT2Confocal_3DCycleGAN/models/__init__.py", line 33, in find_model_using_name
modellib = importlib.import_module(model_filename)
File "/opt/conda/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 879, in exec_module
File "<frozen importlib._bootstrap_external>", line 1017, in get_code
File "<frozen importlib._bootstrap_external>", line 947, in source_to_code
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/kaggle/working/OCT2Confocal_3DCycleGAN/models/cycle_gan_model.py", line 158
lambda_GL = self.opt.lambda_GL
TabError: inconsistent use of tabs and spaces in indentation
After fix the problem 2, I faced the problem 3. 3) UnboundLocalError: local variable 'A' referenced before assignment in data/unaligned_dataset.py:
Traceback (most recent call last):
File "/kaggle/working/OCT2Confocal_3DCycleGAN/train.py", line 44, in <module>
for i, data in enumerate(dataset): # inner loop within one epoch
File "/kaggle/working/OCT2Confocal_3DCycleGAN/data/__init__.py", line 91, in __iter__
for i, data in enumerate(self.dataloader):
File "/opt/conda/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 630, in __next__
data = self._next_data()
File "/opt/conda/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 1345, in _next_data
return self._process_data(data)
File "/opt/conda/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 1371, in _process_data
data.reraise()
File "/opt/conda/lib/python3.10/site-packages/torch/_utils.py", line 694, in reraise
raise exception
UnboundLocalError: Caught UnboundLocalError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/opt/conda/lib/python3.10/site-packages/torch/utils/data/_utils/worker.py", line 308, in _worker_loop
data = fetcher.fetch(index)
File "/opt/conda/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py", line 51, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/opt/conda/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py", line 51, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/kaggle/working/OCT2Confocal_3DCycleGAN/data/unaligned_dataset.py", line 104, in __getitem__
A = A[:, r_x:r_x+self.opt.crop_size, r_y:r_y+self.opt.crop_size]
UnboundLocalError: local variable 'A' referenced before assignment
And so on...
I am still waiting for your review and reply!
RuntimeError: expected stride to be a single integer value or a list of 2 values to match the convolution dimensions, but got stride=[1, 1, 1]
I got the following error:
Traceback (most recent call last): File "/kaggle/working/OCT2Confocal_3DCycleGAN/train.py", line 52, in
model.optimize_parameters() # calculate loss functions, get gradients, update network weights
File "/kaggle/working/OCT2Confocal_3DCycleGAN/models/cycle_gan_model.py", line 208, in optimize_parameters
self.backward_G() # calculate gradients for G_A and G_B
File "/kaggle/working/OCT2Confocal_3DCycleGAN/models/cycle_gan_model.py", line 193, in backward_G
self.loss_GL_A = networks.cal_gradient_loss_3d(self.real_A, self.fake_A, self.device) * lambda_GL
File "/kaggle/working/OCT2Confocal_3DCycleGAN/models/networks.py", line 327, in cal_gradient_loss_3d
grad_x_fake = F.conv3d(fake_data, filter_x, padding=1, groups=channels)
RuntimeError: expected stride to be a single integer value or a list of 4 values to match the convolution dimensions, but got stride=[1, 1, 1]
After this error I modify the line 237 in netwroks.py from
grad_x_fake = F.conv3d(fake_data, filter_x, padding=1, groups=channels)
tograd_x_fake = F.conv3d(fake_data, filter_x, padding=1, groups=channels, stride=1)
andgrad_x_fake = F.conv3d(fake_data, filter_x, padding=1, groups=channels, stride=(1,1,1))
but the error remains.Traceback (most recent call last): File "/kaggle/working/OCT2Confocal_3DCycleGAN/train.py", line 52, in
model.optimize_parameters() # calculate loss functions, get gradients, update network weights
File "/kaggle/working/OCT2Confocal_3DCycleGAN/models/cycle_gan_model.py", line 208, in optimize_parameters
self.backward_G() # calculate gradients for G_A and G_B
File "/kaggle/working/OCT2Confocal_3DCycleGAN/models/cycle_gan_model.py", line 193, in backward_G
self.loss_GL_A = networks.cal_gradient_loss_3d(self.real_A, self.fake_A, self.device) * lambda_GL
File "/kaggle/working/OCT2Confocal_3DCycleGAN/models/networks.py", line 327, in cal_gradient_loss_3d
grad_x_fake = F.conv3d(fake_data, filter_x, padding=1, groups=channels, stride=1)
RuntimeError: expected stride to be a single integer value or a list of 4 values to match the convolution dimensions, but got stride=[1, 1, 1]
Does anyone have any suggestions?