parser.add_argument('--model', default="MobileNetV2_skip", help='MobileNetV2_skip') args = parser.parse_args() from models.ilsvrc import mobilenetv2_skip, mobilenetv2 #from models.cifar100 import mobilenetv2_skip dic_model = {'MobileNetV2_skip': mobilenetv2_skip.MobileNetV2_skip} if args.model not in dic_model: print("The model is currently not supported") sys.exit() trainloader = utils.get_traindata('ILSVRC2012', args.dataset_path, batch_size=args.batch_size, download=True, num_workers=16) testloader = utils.get_testdata('ILSVRC2012', args.dataset_path, batch_size=args.batch_size, num_workers=16) #args.visible_device sets which cuda devices to be used" os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" os.environ["CUDA_VISIBLE_DEVICES"] = args.visible_device device = 'cuda' # parallelize class MyDataParallel(nn.DataParallel):
help='A path to dataset directory') parser.add_argument('--model', default="MobileNetV2_skip", help='MobileNetV2_skip') args = parser.parse_args() from models.cifar100 import mobilenetv2_skip #from models.cifar100 import mobilenetv2_skip dic_model = {'MobileNetV2_skip': mobilenetv2_skip.MobileNetV2_skip} if args.model not in dic_model: print("The model is currently not supported") sys.exit() trainloader = utils.get_traindata('CIFAR100', args.dataset_path, batch_size=args.batch_size, download=True) testloader = utils.get_testdata('CIFAR100', args.dataset_path, batch_size=args.batch_size) #args.visible_device sets which cuda devices to be used" os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" os.environ["CUDA_VISIBLE_DEVICES"] = args.visible_device device = 'cuda' net = dic_model[args.model](num_classes=100) net = net.to(device) #CrossEntropyLoss for accuracy loss criterion criterion = nn.CrossEntropyLoss()