MCPcopy Create free account
hub / github.com/JunlinHan/DCLGAN / __init__

Method __init__

models/base_model.py:18–44  ·  view source on GitHub ↗

Initialize the BaseModel class. Parameters: opt (Option class)-- stores all the experiment flags; needs to be a subclass of BaseOptions When creating your custom class, you need to implement your own initialization. In this fucntion, you should first call <BaseM

(self, opt)

Source from the content-addressed store, hash-verified

16 """
17
18 def __init__(self, opt):
19 """Initialize the BaseModel class.
20
21 Parameters:
22 opt (Option class)-- stores all the experiment flags; needs to be a subclass of BaseOptions
23
24 When creating your custom class, you need to implement your own initialization.
25 In this fucntion, you should first call <BaseModel.__init__(self, opt)>
26 Then, you need to define four lists:
27 -- self.loss_names (str list): specify the training losses that you want to plot and save.
28 -- self.model_names (str list): specify the images that you want to display and save.
29 -- self.visual_names (str list): define networks used in our training.
30 -- self.optimizers (optimizer list): define and initialize optimizers. You can define one optimizer for each network. If two networks are updated at the same time, you can use itertools.chain to group them. See cycle_gan_model.py for an example.
31 """
32 self.opt = opt
33 self.gpu_ids = opt.gpu_ids
34 self.isTrain = opt.isTrain
35 self.device = torch.device('cuda:{}'.format(self.gpu_ids[0])) if self.gpu_ids else torch.device('cpu') # get device name: CPU or GPU
36 self.save_dir = os.path.join(opt.checkpoints_dir, opt.name) # save all the checkpoints to save_dir
37 if opt.preprocess != 'scale_width': # with [scale_width], input images might have different sizes, which hurts the performance of cudnn.benchmark.
38 torch.backends.cudnn.benchmark = True
39 self.loss_names = []
40 self.model_names = []
41 self.visual_names = []
42 self.optimizers = []
43 self.image_paths = []
44 self.metric = 0 # used for learning rate policy 'plateau'
45
46 @staticmethod
47 def dict_grad_hook_factory(add_func=lambda x: x):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected