cvlab-yonsei / MNAD

An official implementation of "Learning Memory-guided Normality for Anomaly Detection" (CVPR 2020) in PyTorch.
333 stars 82 forks source link

NameError: name 'loss_pixel' is not defined #23

Closed Smallwhite999 closed 3 years ago

Smallwhite999 commented 3 years ago

I followed the steps in the readme and reported the error as follows: /home/anaconda3/envs/MNAD/lib/python3.6/site-packages/torch/optim/lr_scheduler.py:134: UserWarning: Detected call of lr_scheduler.step() before optimizer.step(). In PyTorch 1.1.0 and later, you should call them in the opposite order: optimizer.step() before lr_scheduler.step(). Failure to do this will result in PyTorch skipping the first value of the learning rate schedule. See more details at https://pytorch.org/docs/stable/optim.html#how-to-adjust-learning-rate "https://pytorch.org/docs/stable/optim.html#how-to-adjust-learning-rate", UserWarning) Traceback (most recent call last): File "Train.py", line 148, in print('Loss: Prediction {:.6f}/ Compactness {:.6f}/ Separateness {:.6f}'.format(loss_pixel.item(), compactness_loss.item(), separateness_loss.item())) NameError: name 'loss_pixel' is not defined

How to solve it? Thank you

hyunjp commented 3 years ago

Hi, That error may come from the wrong assignment for the argparse "--method". Please check it again (You need to put it as "--method pred" or "--method recon"). Thank you.

Wjz1203 commented 2 years ago

How did you finally solve this problem?

huyi1998 commented 2 years ago

Did you solve it?