kulikovv / dognet

A Deep Architecture for Synapse Detection in Multiplexed Fluorescence Images
GNU General Public License v3.0
14 stars 4 forks source link

Issues running run_prism.py #3

Open bethac07 opened 4 years ago

bethac07 commented 4 years ago

I installed and tried to run python run_prism.py, and got the following output/error:

['synapsin-1', 'PSD-95', 'VGLUT1', 'bassoon']
['synapsin-1', 'PSD-95', 'VGLUT1', 'bassoon', 'MAP2']
['synapsin-1', 'PSD-95', 'VGLUT1', 'bassoon', 'MAP2']
['synapsin-1', 'PSD-95', 'VGLUT1', 'bassoon', 'MAP2']
CUDA is not detected, running on CPU.
(tensor([247.9281]), (10, 1, 64, 64), 4096, 153.0, 1.0)
BCELoss()
Training started!
Traceback (most recent call last):
  File "run_prism.py", line 84, in <module>
    net,errors = dognet.train_routine(net,gen,n_iter=3000,margin=5)
  File "../dognet/training.py", line 195, in train_routine
    p, _ = detector(vx)
  File "/usr/local/lib/python2.7/site-packages/torch/nn/modules/module.py", line 541, in __call__
    result = self.forward(*input, **kwargs)
  File "../dognet/networks.py", line 63, in forward
    y = self.conv1(x)
  File "/usr/local/lib/python2.7/site-packages/torch/nn/modules/module.py", line 541, in __call__
    result = self.forward(*input, **kwargs)
  File "../dognet/dogs.py", line 23, in forward
    filters = self.A.get_filter() - self.B.get_filter()
  File "../dognet/gaussians.py", line 90, in get_filter
    filters = amplitude * (- ((self.xes + self.yes)* s ** 2)/2).exp()
RuntimeError: The size of tensor a (4) must match the size of tensor b (16) at non-singleton dimension 2

Inference doesn't seem to work either; if I comment out lines 84/85 I get the following:

['synapsin-1', 'PSD-95', 'VGLUT1', 'bassoon']
['synapsin-1', 'PSD-95', 'VGLUT1', 'bassoon', 'MAP2']
['synapsin-1', 'PSD-95', 'VGLUT1', 'bassoon', 'MAP2']
['synapsin-1', 'PSD-95', 'VGLUT1', 'bassoon', 'MAP2']
CUDA is not detected, running on CPU.
processing PRISM dataset
Traceback (most recent call last):
  File "run_prism.py", line 92, in <module>
    y = inference(net,normalize(x,get_normparams(rep21.data))) 
  File "run_prism.py", line 50, in inference
    res,inter = net(vx)
  File "/usr/local/lib/python2.7/site-packages/torch/nn/modules/module.py", line 541, in __call__
    result = self.forward(*input, **kwargs)
  File "../dognet/networks.py", line 63, in forward
    y = self.conv1(x)
  File "/usr/local/lib/python2.7/site-packages/torch/nn/modules/module.py", line 541, in __call__
    result = self.forward(*input, **kwargs)
  File "../dognet/dogs.py", line 23, in forward
    filters = self.A.get_filter() - self.B.get_filter()
  File "../dognet/gaussians.py", line 90, in get_filter
    filters = amplitude * (- ((self.xes + self.yes)* s ** 2)/2).exp()
RuntimeError: The size of tensor a (4) must match the size of tensor b (16) at non-singleton dimension 2

OSX 10.14.6, Python 2.7.17, selected packages from pip freeze below (happy to elaborate further)

jupyter==1.0.0
jupyter-client==5.2.3
jupyter-console==5.2.0
jupyter-core==4.4.0
matplotlib==2.2.4
numpy==1.15.4
scikit-image==0.14.0
scikit-learn==0.19.0
scipy==1.1.0
torch==1.3.1
torchvision==0.4.2
kulikovvictor commented 4 years ago

Seems the problem is with the input tensor. Could you please insert that line of code to show the shape of the impute tensors before training? x,y = gen(10) print(x.shape,y.shape)

the output should be (10, 3, 64, 64) (10, 1, 64, 64)

bethac07 commented 4 years ago

((10, 4, 64, 64), (10, 1, 64, 64))

xintangg commented 4 years ago

hi Beth,

Have you solved this problem? I also came across it.

kulikovvictor commented 4 years ago

in gaussians.py, correct line 59:

self.amplitude = Parameter(torch.randn(in_channels*n_gaussian).float(), requires_grad=True)