infinity7428 / hANMCL

48 stars 9 forks source link

Error of training (New code) #20

Open yuan738 opened 1 year ago

yuan738 commented 1 year ago

Traceback (most recent call last): File "train.py", line 22, in <module> from model.utils.metaclm import SupConLoss ModuleNotFoundError: No module named 'model.utils.metaclm'

I didn't find metaclm.py in the folder lib/model/utils/. Maybe something went wrong while preparing my environment?

Looking forward to your answer, thank you!

infinity7428 commented 1 year ago

I uploaded the code again. Let me know if you have any problems.

yuan738 commented 1 year ago

Hi, I adjusted the hyperparameters of each loss, and the loss is still nan. Is there any other hyperparameter that can be adjusted?

parser = argparse.ArgumentParser(description='Train a Fast R-CNN network')
# net and dataset
parser.add_argument('--dataset', dest='dataset', help='training dataset', default='coco_base', type=str)
parser.add_argument('--net', dest='net', help='vgg16, res101', default='hanmcl', type=str)
parser.add_argument('--flip', dest='use_flip', help='use flipped data or not', default=False, action='store_true')
# optimizer
parser.add_argument('--o', dest='optimizer', help='training optimizer', default="adam", type=str)
parser.add_argument('--lr', dest='lr', help='starting learning rate', default=0.001, type=float)
parser.add_argument('--lr_decay_step', dest='lr_decay_step', help='step to do learning rate decay, unit is epoch', default=1000, type=int)
parser.add_argument('--lr_decay_gamma', dest='lr_decay_gamma', help='learning rate decay ratio', default=0.1, type=float)
# train&finetuning setting
parser.add_argument('--nw', dest='num_workers', help='number of worker to load data', default=10, type=int)
parser.add_argument('--ls', dest='large_scale', help='whether use large imag scale', action='store_true')                      
parser.add_argument('--mGPUs', dest='mGPUs', help='whether use multiple GPUs', action='store_true')
parser.add_argument('--bs', dest='batch_size', help='batch_size', default=4, type=int)
parser.add_argument('--start_epoch', dest='start_epoch', help='starting epoch', default=1, type=int)
parser.add_argument('--epochs', dest='max_epochs', help='number of epochs to train', default=12, type=int)
parser.add_argument('--disp_interval', dest='disp_interval', help='number of iterations to display', default=1, type=int)
parser.add_argument('--save_dir', dest='save_dir', help='directory to save models', default="models", type=str)
parser.add_argument('--ascale', dest='ascale', help='number of anchor scale', default=4, type=int)
# parser.add_argument('--ft', dest='finetune', help='finetune mode', default=False, action='store_true')
parser.add_argument('--eval', dest='eval', help='evaluation mode', default=False, action='store_true')
parser.add_argument('--onc', dest='old_n_classes', help='number of classes of the source domain', default=81, type=int)
# inference setting
parser.add_argument('--eval_dir', dest='eval_dir', help='output directory of evaluation', default=None, type=str)
# few shot
parser.add_argument('--fs', dest='fewshot', help='few-shot setting', default=True, action='store_true')
parser.add_argument('--way', dest='way', help='num of support way', default=2, type=int)
parser.add_argument('--shot', dest='shot', help='num of support shot', default=3, type=int)
parser.add_argument('--sup_dir', dest='sup_dir', help='directory of support images', default='coco/seed1/30shot_image_novel', type=str)
# load checkpoints
parser.add_argument('--r', dest='resume', help='resume checkpoint or not', action='store_true', default=False)
parser.add_argument('--load_dir', dest='load_dir', help='directory to load models', default="models", type=str)
parser.add_argument('--checkepoch', dest='checkepoch', help='checkepoch to load model', default=1, type=int)
parser.add_argument('--checkpoint', dest='checkpoint', help='checkpoint to load model', default=0, type=str)
# logger
parser.add_argument('--dlog', dest='dlog', help='disable the logger', default=False, action='store_true')
parser.add_argument('--imlog', dest='imlog', help='save im in the logger', default=False, action='store_true')
# seed_ft
parser.add_argument('--sup', dest='ft_sup', help='directory of support images', default='seed1/1shot_image_novel', type=str)
parser.add_argument('--seed', dest='seed', help='num of support seed', default='seed1', type=str)
parser.add_argument('--shots', dest='shots', help='num of support shots', default='1shots', type=str)
infinity7428 commented 1 year ago

Are you using your own dataset? It might help to adjust learning rate (--lr).

yuan738 commented 1 year ago

I used coco. I also thought about adjusting the learning rate to 0.0001 and now the code is running. Thank you.