model_type = args.model_type batch_size = args.bs iters = args.iters eps = args.eps n = args.n norm = args.norm custom_best = args.custom_best fake_relu = (model_arch != 'vgg19') analysis = args.analysis delta_analysis = args.delta_analysis analysis_start = args.analysis_start random_restarts = args.random_restarts # Load model if args.dataset == 'cifar10': constants = utils.CIFAR10() elif args.dataset == 'imagenet': constants = utils.ImageNet1000() else: print("Invalid Dataset Specified") ds = constants.get_dataset() # Load model model = constants.get_model(model_type, model_arch) # Get stats for neuron activations senses = constants.get_deltas(model_type, model_arch) (mean, std) = constants.get_stats(model_type, model_arch) _, test_loader = ds.make_loaders(batch_size=batch_size, workers=8, only_val=True,
delta_values = logits[actual_label] - logits delta_values /= weights - weights[actual_label] delta_values[actual_label] = np.inf return delta_values if __name__ == "__main__": import sys model_arch = sys.argv[1] model_type = sys.argv[2] dataset = sys.argv[3] filename = sys.argv[4] if dataset == 'cifar10': dx = utils.CIFAR10() batch_size = 1024 elif dataset == 'imagenet': batch_size = 256 dx = utils.ImageNet1000() else: raise ValueError("Dataset not supported") ds = dx.get_dataset() model = dx.get_model(model_type, model_arch) _, test_loader = ds.make_loaders(batch_size=batch_size, workers=8, only_val=True, fixed_test_order=True)