def test_core50_ni_benchmark(self): if "FAST_TEST" in os.environ: pass else: benchmark = CORe50(scenario="ni") for experience in benchmark.train_stream: pass
def test_core50_ni_scenario(self): if "FAST_TEST" in os.environ: pass else: scenario = CORe50(scenario="ni") for experience in scenario.train_stream: pass
def test_core50_ni_scenario(self): if "FAST_TEST" in os.environ: pass else: scenario = CORe50(scenario="ni") for task_info in scenario: pass
def test_core50_nc_scenario(self): benchmark_instance = CORe50(scenario='nc') self.assertEqual(1, len(benchmark_instance.test_stream)) classes_in_test = benchmark_instance.\ classes_in_experience['test'][0] self.assertSetEqual( set(range(50)), set(classes_in_test))
def test_core50_nc_benchmark(self): if "FAST_TEST" in os.environ: pass else: benchmark_instance = CORe50(scenario="nc") self.assertEqual(1, len(benchmark_instance.test_stream)) classes_in_test = benchmark_instance.classes_in_experience["test"][ 0] self.assertSetEqual(set(range(50)), set(classes_in_test))
def main(args): # Device config device = torch.device(f"cuda:{args.cuda}" if torch.cuda.is_available() and args.cuda >= 0 else "cpu") print('device ', device) # --------- # --- TRANSFORMATIONS _mu = [0.485, 0.456, 0.406] # imagenet normalization _std = [0.229, 0.224, 0.225] transform = transforms.Compose([ transforms.Resize((224, 224)), transforms.ToTensor(), transforms.Normalize(mean=_mu, std=_std) ]) # --------- # --- SCENARIO CREATION scenario = CORe50(scenario=args.scenario, train_transform=transform, eval_transform=transform) # --------- eval_plugin = EvaluationPlugin( loss_metrics(epoch=True, experience=True, stream=True), accuracy_metrics(epoch=True, experience=True, stream=True), forgetting_metrics(experience=True, stream=True), loggers=[InteractiveLogger()] ) criterion = torch.nn.CrossEntropyLoss() model = SLDAResNetModel(device=device, arch='resnet18', imagenet_pretrained=args.imagenet_pretrained) # CREATE THE STRATEGY INSTANCE cl_strategy = StreamingLDA(model, criterion, args.feature_size, args.n_classes, eval_mb_size=args.batch_size, train_mb_size=args.batch_size, train_epochs=1, shrinkage_param=args.shrinkage, streaming_update_sigma=args.plastic_cov, device=device, evaluator=eval_plugin) warnings.warn( "The Deep SLDA example is not perfectly aligned with " "the paper implementation since it does not use a base " "initialization phase and instead starts streming from " "pre-trained weights.") # TRAINING LOOP print('Starting experiment...') for i, exp in enumerate(scenario.train_stream): # fit SLDA model to batch (one sample at a time) cl_strategy.train(exp) # evaluate model on test data cl_strategy.eval(scenario.test_stream)
def test_core50_ni_benchmark(self): benchmark = CORe50(scenario="ni") for experience in benchmark.train_stream: pass