def __init__(self, model): model.eval() self.model = model self.correct = 0 class Stat: def __init__(self, d, dnm): self.domain = d self.name = dnm self.width = 0 self.max_eps = 0 self.safe = 0 self.proved = 0 self.time = 0 self.domains = [ Stat(h.parseValues(domains,d), h.catStrs(d)) for d in args.test_domain ]
default=None, help='use regularization') parser.add_argument("--gpu_id", type=str, default=None, help="specify gpu id, None for all") parser.add_argument("--decay-fir", type=bool, default=False, help="decay the first Mix domain") args = parser.parse_args() if args.gpu_id is not None: os.environ["CUDA_VISIBLE_DEVICES"] = args.gpu_id largest_domain = max([len(h.catStrs(d)) for d in (args.domain)]) largest_test_domain = max([len(h.catStrs(d)) for d in (args.test_domain)]) args.log_interval = int(50000 / (args.batch_size * args.log_freq)) h.max_c_for_norm = args.max_norm if h.use_cuda: torch.cuda.manual_seed(1 + args.seed) else: torch.manual_seed(args.seed) train_loader = h.loadDataset(args.dataset, args.batch_size, True, False) val_loader = h.loadDataset(args.dataset, args.batch_size, True, False, True) test_loader = h.loadDataset(args.dataset, args.test_batch_size, False, False)
parser.add_argument('-n', '--net', choices = h.getMethodNames(models), action = 'append' , default=[], help='picks which net to use for training') # one net for now parser.add_argument('-D', '--dataset', choices = [n for (n,k) in inspect.getmembers(datasets, inspect.isclass) if issubclass(k, Dataset)] , default="MNIST", help='picks which dataset to use.') parser.add_argument('-o', '--out', default="out/", help='picks which net to use for training') parser.add_argument('--dont-write', type=h.str2bool, nargs='?', const=True, default=False, help='dont write anywhere if this flag is on') parser.add_argument('--test-size', type=int, default=2000, help='number of examples to test with') parser.add_argument('-r', '--regularize', type=float, default=None, help='use regularization') args = parser.parse_args() largest_domain = max([len(h.catStrs(d)) for d in (args.domain)] ) largest_test_domain = max([len(h.catStrs(d)) for d in (args.test_domain)] ) args.log_interval = int(50000 / (args.batch_size * args.log_freq)) h.max_c_for_norm = args.max_norm if h.use_cuda: torch.cuda.manual_seed(1 + args.seed) else: torch.manual_seed(args.seed) train_loader = h.loadDataset(args.dataset, args.batch_size, True, False) test_loader = h.loadDataset(args.dataset, args.test_batch_size, False, False) input_dims = train_loader.dataset[0][0].size()