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

train 2D Xnet question #18

Open
Ystartff opened this issue Apr 3, 2024 · 2 comments
Open

train 2D Xnet question #18

Ystartff opened this issue Apr 3, 2024 · 2 comments

Comments

@Ystartff
Copy link

Ystartff commented Apr 3, 2024

Hello! I would like to know how your mean and std are calculated if training other datasets, because I see that in semi-supervised learning, the unlabelled and labelled files contain L and H files.

@Ystartff
Copy link
Author

Ystartff commented Apr 6, 2024

Hello, my problem is that when I do onehot coding the previous batches target.shape is (2,128,128,2) but the later batches have (2,128,128,256). A problem with the code prompts me to
Traceback (most recent call last):
File "train_semi_XNet.py", line 255, in
loss_train_sup1 = criterion(pred_train_sup1, mask_train_sup)
File "/home/panxue/anaconda3/envs/wave/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/mnt/data/panxue/PX/XNet-main/loss/loss_function.py", line 132, in forward
return self._base_forward(output, target_one_hot, valid_mask)
File "/mnt/data/panxue/PX/XNet-main/loss/loss_function.py", line 100, in _base_forward
dice_loss = dice(predict[:, i], target[..., i], valid_mask)
IndexError: index 2 is out of bounds for dimension 1 with size 2
Traceback (most recent call last):
File "train_semi_XNet.py", line 255, in
loss_train_sup1 = criterion(pred_train_sup1, mask_train_sup)
File "/home/panxue/anaconda3/envs/wave/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/mnt/data/panxue/PX/XNet-main/loss/loss_function.py", line 132, in forward
return self._base_forward(output, target_one_hot, valid_mask)
File "/mnt/data/panxue/PX/XNet-main/loss/loss_function.py", line 100, in _base_forward
dice_loss = dice(predict[:, i], target[..., i], valid_mask)
IndexError: index 2 is out of bounds for dimension 1 with size 2

@Yanfeng-Zhou
Copy link
Owner

Hello!

  1. I have written the corresponding code for the calculation of mean and std, but have not uploaded it. I will consider updating the code. In fact, the calculation of mean and std is very simple: calculate the mean and standard deviation of the individual pixel values of all images in the training data.
  2. IndexError: index 2 is out of bounds for dimension 1 with size 2. This error most likely comes from you not processing the mask (the foreground pixel in the mask before processing is 255). For binary semantic segmentation problems, the foreground pixel in the mask should be 1.

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

2 participants