msdnet icon indicating copy to clipboard operation
msdnet copied to clipboard

"Train a Network For Regression" demos fail with NoneType AttributeError

Open mdoube opened this issue 2 years ago • 0 comments

Describe the bug Example 01: Train a network for regression and Example 05: Train a network for regression (tomography) fail with AttributeError: 'NoneType' object has no attribute 'deriv'

It looks like loss in train.pyis never instantiated and remains None, leading to a null pointer exception-like error (I am coming from a Java background).

L66 def __init__(self, network, loss = None, a = 0.001, b1 = 0.9, b2 = 0.999, e = 10**-8): L73 self.loss = loss L85 err = self.loss.deriv(out, tar) <- this line throws the NoneType error

To Reproduce Steps to reproduce the behavior:

  1. Set up msdnet in a new conda environment
conda config --add channels conda-forge
conda create --name tomo msdnet
conda activate tomo
  1. Install dependencies
  2. Run Supplementary 02: Generate data for tomography examples
  3. Run :~$ python3 train_regr_tomography.py
  4. See error:
Traceback (most recent call last):
  File "/home/mdoube/train_regr_tomography.py", line 93, in <module>
    msdnet.train.train(n, t, val, bprov, 'tomo_regr_params.h5',loggers=[consolelog,filelog,imagelog], val_every=len(datsv))
  File "/home/mdoube/miniconda3/envs/tomo/lib/python3.10/site-packages/msdnet/train.py", line 187, in train
    trainalg.step(network, batch)
  File "/home/mdoube/miniconda3/envs/tomo/lib/python3.10/site-packages/msdnet/train.py", line 85, in step
    err = self.loss.deriv(out, tar)
AttributeError: 'NoneType' object has no attribute 'deriv'

Expected behavior Script completes and training continues until it is stopped manually

Desktop (please complete the following information):

  • Dell 7920 workstation with NVIDIA RTX A4000 GPU
  • OS: Ubuntu 20.04
  • CUDA 11.8.0
  • NVIDIA driver 525.85.12
  • Miniconda 23.1.0
  • Python 3.10.8
  • ASTRA 2.1.0
  • tomopy 1.12.2

Additional context tomopy and ASTRA are working properly. This demo completed successfully.

mdoube avatar Feb 03 '23 07:02 mdoube