Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameError: name 'cls_pc_raw' is not defined #19

Open
pmff96 opened this issue Aug 27, 2021 · 2 comments
Open

NameError: name 'cls_pc_raw' is not defined #19

pmff96 opened this issue Aug 27, 2021 · 2 comments

Comments

@pmff96
Copy link

pmff96 commented Aug 27, 2021

Hello, when I run this code I get the following error: "NameError: name 'cls_pc_raw' is not defined". I'm not sure if it helps but here is the entire debug message.

checkpoints: log/pointnet_cls/20210827-1421
PARAMETER ...
Namespace(augment=False, batch_size=24, data_dir='ModelNet40', decay_rate=0.0001, epoch=250, epoch_per_save=5, learning_rate=0.001, learning_rate_a=0.001, log_dir='log/pointnet_cls/20210827-1421', lr_decay=0.5, model_name='pointnet', no_decay=False, noise_dim=1024, num_points=1024, optimizer='Adam', pretrain=None, restore=False, use_normal=False, y_rotated=True)
Load dataset ...
The number of training data is: 9840
The number of test data is: 2468
No existing Augment, starting training from scratch...
Epoch 1 (1/250):
0% 0/410 [00:00<?, ?it/s]
Traceback (most recent call last):
File "train_PA.py", line 29, in
model.train()
File "/content/PointAugment/Augment/model.py", line 162, in train
aug_feat, ispn=ispn)
File "/content/PointAugment/Common/loss_utils.py", line 63, in cls_loss
parameters = torch.max(torch.tensor(NUM).cuda(), torch.exp(1.0-cls_pc_raw)**2).cuda()
NameError: name 'cls_pc_raw' is not defined

@laomeng0703
Copy link

Hi, I probably know how to fix this.
As shown below, in the place of the cls_loss function in the original loss_utils.py file, the definitions of cls_pc_raw and cls_aug_raw are replaced by underscores. I think just change the two underscores to the above two variable names.

def cls_loss(pred, pred_aug, gold, pc_tran, aug_tran, pc_feat, aug_feat, ispn = True):

    mse_fn = torch.nn.MSELoss(reduce=True, size_average=True)
    cls_pc, _ = cal_loss_raw(pred, gold)
    cls_aug, _ = cal_loss_raw(pred_aug, gold)
  
    if ispn:
        cls_pc = cls_pc + 0.001*mat_loss(pc_tran)
        cls_aug = cls_aug + 0.001*mat_loss(aug_tran)
    feat_diff = 10.0*mse_fn(pc_feat,aug_feat)
    parameters = torch.max(torch.tensor(NUM).cuda(), torch.exp(1.0-cls_pc_raw)**2).cuda()
    cls_diff = (torch.abs(cls_pc_raw - cls_aug_raw) * (parameters*2)).mean()
    cls_loss = cls_pc + cls_aug  + feat_diff# + cls_diff
    return cls_loss

@kkmm54
Copy link

kkmm54 commented Nov 20, 2023

`def cls_loss(pred, pred_aug, gold, pc_tran, aug_tran, pc_feat, aug_feat, ispn = True):

mse_fn = torch.nn.MSELoss(reduce=True, size_average=True)
cls_pc, cls_pc_raw= cal_loss_raw(pred, gold)
cls_aug, cls_aug_raw= cal_loss_raw(pred_aug, gold)

if ispn:
    cls_pc = cls_pc + 0.001*mat_loss(pc_tran)
    cls_aug = cls_aug + 0.001*mat_loss(aug_tran)
feat_diff = 10.0*mse_fn(pc_feat,aug_feat)
parameters = torch.max(torch.tensor(NUM).cuda(), torch.exp(1.0-cls_pc_raw)**2).cuda()
cls_diff = (torch.abs(cls_pc_raw - cls_aug_raw) * (parameters*2)).mean()
cls_loss = cls_pc + cls_aug  + feat_diff# + cls_diff
return cls_loss`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants