def __init__(self, use_cuda, load_model, model_folder, train_directory, validation_directory, builder, loss_fn, args, multi_gpu=True):
    self.use_cuda = use_cuda
    self.load_model = load_model
    self.model_folder = model_folder
    self.validation_directory = validation_directory
    self.train_directory = train_directory
    self.args = args
    self.builder = builder
    self.loss_fn = loss_fn
    self.logdir = join(model_folder, 'logs')
    self.writer = SummaryWriter(self.logdir)
    self.logger = Logger(self.args.log_file)
    self.itr = 0
    self.model = self.create_model()
    if multi_gpu:
        self.model = torch.nn.DataParallel(self.model, device_ids=range(torch.cuda.device_count()))
    validation_builder = builder(self.args.n_views, validation_directory, IMAGE_SIZE, self.args, toRot=True, sample_size=SAMPLE_SIZE)
    validation_set = [validation_builder.build_set() for i in range(VAL_SEQS)]
    validation_set = ConcatDataset(validation_set)
    self.len_validation_set = len(validation_set)
    del validation_builder
    self.validation_loader = DataLoader(validation_set, batch_size=8, shuffle=False, pin_memory=self.use_cuda)
    self.validation_calls = 0
    self.triplet_builder = builder(self.args.n_views, train_directory, IMAGE_SIZE, self.args, toRot=True, sample_size=SAMPLE_SIZE)
    self.training_queue = multiprocessing.Queue(1)
    dataset_builder_process = multiprocessing.Process(target=self.build_set, args=(self.training_queue, self.triplet_builder, self.logger), daemon=True)
    dataset_builder_process.start()
    self.optimizer = optim.Adam(self.model.parameters(), lr=0.001, betas=(0.9, 0.999), eps=1e-08)
    self.learning_rate_scheduler = lr_scheduler.ReduceLROnPlateau(self.optimizer, 'min')
def __init__(self, use_cuda, load_model, model_folder, train_directory, validation_directory, builder, loss_fn, args, multi_gpu=True):
    self.use_cuda = use_cuda
    self.load_model = load_model
    self.model_folder = model_folder
    self.validation_directory = validation_directory
    self.train_directory = train_directory
    self.args = args
    self.builder = builder
    self.loss_fn = loss_fn
    self.logdir = join(model_folder, 'logs')
    self.writer = SummaryWriter(self.logdir)
    self.logger = Logger(self.args.log_file)
    self.itr = 0
    self.model = self.create_model()
    if multi_gpu:
        self.model = torch.nn.DataParallel(self.model, device_ids=range(torch.cuda.device_count()))
    validation_builder = builder(self.args.n_views, validation_directory, IMAGE_SIZE, self.args, toRot=True, sample_size=SAMPLE_SIZE)
    validation_set = [validation_builder.build_set() for i in range(VAL_SEQS)]
    validation_set = ConcatDataset(validation_set)
    self.len_validation_set = len(validation_set)
    del validation_builder
    self.validation_loader = DataLoader(validation_set, batch_size=8, shuffle=False, pin_memory=self.use_cuda)
    self.validation_calls = 0
    self.triplet_builder = builder(self.args.n_views, train_directory, IMAGE_SIZE, self.args, toRot=True, sample_size=SAMPLE_SIZE)
    self.training_queue = multiprocessing.Queue(1)
    dataset_builder_process = multiprocessing.Process(target=self.build_set, args=(self.training_queue, self.triplet_builder, self.logger), daemon=True)
    dataset_builder_process.start()
    self.optimizer = optim.Adam(self.model.parameters(), lr=0.001, betas=(0.9, 0.999), eps=1e-08)
    self.learning_rate_scheduler = lr_scheduler.ReduceLROnPlateau(self.optimizer, 'min')