Closed freefreeway closed 6 years ago
Hi @freefreeway , thanks for your running our project. Our project environment is Python 3.6, PyTorch 0.4.0. Is your environment identical with ours?
Well, sorry to bother you but I have just solved it while running it based on the correct environment. Thank you once again~
Glad to hear that you can run our codes in the correct environment.
As for the weight initialization of bilinear interpolation in Deconv Layer, the codes you selected are actually redundant, sorry.
(m,k,h,w)
, the shape of deconv layer, in our FCN model, has the relationship that m=k, h=w
. So the codes can be simplified to one line mod.weight.data[range(m), range(k), :, :] = filt
or just mod.weight.data[:, :, :, :] = filt
. filt shape is (h,w)
, and it uses broadcasting.
You can try it in Pytorch 0.3.0, though I'm not sure it will work.
Thanks to your detailed explanation so that I can run it correctly. Besides, I have installed pytorch 0.4.0. Thanks a lot~
Hi~ Thank you very much for providing the code. I have tried to reproduce the result according to the README file as well as your paper. However, there's a problem while training. ( After finishing initializing successfully. ) I run the manuscript but it says just like this:
X 5455 {'S': 10000, 'I': 30000, 'J': 40000} Traceback (most recent call last): File "training.py", line 67, in <module> crop_prob=crop_prob, crop_sample_batch=crop_sample_batch) File "/home/frw/NIH/project/RSTN/model.py", line 196, in __init__ self.coarse_model = FCN8s(n_class) File "/home/frw/NIH/project/RSTN/model.py", line 73, in __init__ self._initialize_weights() File "/home/frw/NIH/project/RSTN/model.py", line 91, in _initialize_weights mod.weight.data[range(k * i, k * i + r), range(r), :, :] = filt RuntimeError: invalid argument 4: Number of indices should be equal to source:size(dim) at /pytorch/torch/lib/TH/generic/THTensorMath.c:322 Y 9612 {'S': 10000, 'I': 30000, 'J': 40000} Traceback (most recent call last): File "training.py", line 67, in <module> crop_prob=crop_prob, crop_sample_batch=crop_sample_batch) File "/home/frw/NIH/project/RSTN/model.py", line 196, in __init__ self.coarse_model = FCN8s(n_class) File "/home/frw/NIH/project/RSTN/model.py", line 73, in __init__ self._initialize_weights() File "/home/frw/NIH/project/RSTN/model.py", line 91, in _initialize_weights mod.weight.data[range(k * i, k * i + r), range(r), :, :] = filt RuntimeError: invalid argument 4: Number of indices should be equal to source:size(dim) at /pytorch/torch/lib/TH/generic/THTensorMath.c:322 Z 5162 {'S': 10000, 'I': 30000, 'J': 40000} Traceback (most recent call last): File "training.py", line 67, in <module> crop_prob=crop_prob, crop_sample_batch=crop_sample_batch) File "/home/frw/NIH/project/RSTN/model.py", line 196, in __init__ self.coarse_model = FCN8s(n_class) File "/home/frw/NIH/project/RSTN/model.py", line 73, in __init__ self._initialize_weights() File "/home/frw/NIH/project/RSTN/model.py", line 91, in _initialize_weights mod.weight.data[range(k * i, k * i + r), range(r), :, :] = filt RuntimeError: invalid argument 4: Number of indices should be equal to source:size(dim) at /pytorch/torch/lib/TH/generic/THTensorMath.c:322
It says that "Number of indices should be equal to source:size(dim)", so I refer to the code and found as follows in model._initialize_weights:
for i in range((m - 1) // k + 1): r = min(k * (i + 1), m) - k * i mod.weight.data[range(k * i, k * i + r), range(r), :, :] = filt
and found mod.weight.data.shape is ( 3, 3, 4, 4 ) while filt is ( 4, 4 ), I guess it lead to the error. But I wonder if the conjecture is right and how can I solve the problem. Thanks advanced.