liruihui / PointAugment

Code for PointAugment: an Auto-Augmentation Framework for Point Cloud Classification, CVPR 2020 (Oral)
Other
210 stars 29 forks source link

NameError: name 'cls_pc_raw' is not defined #19

Open pmff96 opened 3 years ago

pmff96 commented 3 years ago

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 commented 2 years ago

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 commented 1 year ago

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