def switch(self, gen_mode:bool=None):
        "Switch the model, if `gen_mode` is provided, in the desired mode."
        self.gen_mode = (not self.gen_mode) if gen_mode is None else gen_mode
        self.opt.opt = self.opt_gen.opt if self.gen_mode else self.opt_critic.opt
        self._set_trainable()
        self.model.switch(gen_mode)
        self.loss_func.switch(gen_mode)
def switch ( self , gen_mode : bool = None ) : self . gen_mode = ( not self . gen_mode ) if gen_mode is None else gen_mode self . opt . opt = self . opt_gen . opt if self . gen_mode else self . opt_critic . opt self . _set_trainable ( ) self . model . switch ( gen_mode ) self . loss_func . switch ( gen_mode )
Switch the model, if `gen_mode` is provided, in the desired mode.