unet-multiclass-pytorch icon indicating copy to clipboard operation
unet-multiclass-pytorch copied to clipboard

Looking for Solution for 'UNet' object has no attribute 'module' error

Open Parikshit01 opened this issue 1 year ago • 0 comments

While running the train.py file, i'm getting the following error. Kindly let me know how to resolve it.

aaa@aaa:~/unet-multiclass-pytorch$ python3 train.py -e 100 -l 0.01 -b 16 -f patches_s96 /usr/lib/python3/dist-packages/scipy/init.py:146: UserWarning: A NumPy version >=1.17.3 and <1.25.0 is required for this version of SciPy (detected version 1.26.4 warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}"

Starting training: Epochs: 100 Batch size: 16 Learning rate: 0.01 Training size: 5512 Validation size: 612 Checkpoints: True Device: cuda

Starting epoch 1/100. epoch = 1, iteration = 0/344, loss = 1.05950 epoch = 1, iteration = 1/344, loss = 1.04739 epoch = 1, iteration = 2/344, loss = 1.02806 epoch = 1, iteration = 3/344, loss = 1.01785 epoch = 1, iteration = 4/344, loss = 1.01207 epoch = 1, iteration = 5/344, loss = 0.99240 ..... epoch = 1, iteration = 339/344, loss = 0.57131 epoch = 1, iteration = 340/344, loss = 0.57237 epoch = 1, iteration = 341/344, loss = 0.57103 epoch = 1, iteration = 342/344, loss = 0.56907 epoch = 1, iteration = 343/344, loss = 0.56743 /home/parikshit/.local/lib/python3.10/site-packages/torch/optim/lr_scheduler.py:402: UserWarning: To get the last learning rate computed by the scheduler, please use get_last_lr(). warnings.warn("To get the last learning rate computed by the scheduler, " Epoch finished ! Loss: 0.62, lr:[0.01] Class IoU: 0.992 0.786 0.909 | Mean IoU: 0.896 Traceback (most recent call last): File "/home/parikshit/unet-multiclass-pytorch/train.py", line 152, in train_net(train_loader, val_loader, net, device, epochs=args.epochs, batch_size=args.batchsize, lr=args.lr) File "/home/parikshit/unet-multiclass-pytorch/train.py", line 97, in train_net state_dict = net.module.state_dict() File "/home/parikshit/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1688, in getattr raise AttributeError(f"'{type(self).name}' object has no attribute '{name}'") AttributeError: 'UNet' object has no attribute 'module'. Did you mean: 'modules'?

Parikshit01 avatar Feb 22 '24 10:02 Parikshit01