MCPcopy Create free account
hub / github.com/chenhaoxing/HDNet / __init__

Method __init__

models/base_model.py:17–43  ·  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

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected