PointAugment icon indicating copy to clipboard operation
PointAugment copied to clipboard

NameError: name 'cls_pc_raw' is not defined

Open pmff96 opened this issue 3 years ago • 2 comments

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

pmff96 avatar Aug 27 '21 14:08 pmff96

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

laomeng0703 avatar Jun 22 '22 11:06 laomeng0703

`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`

kkmm54 avatar Nov 20 '23 02:11 kkmm54