def __init__(self, model_name, learning_rate=0.01, iteration=100, reconstruction_loss_weight=1.0, perceptual_loss_weight=5e-05, regularization_loss_weight=2.0, logger=None):
    'Initializes the inverter.\n\n    NOTE: Only Adam optimizer is supported in the optimization process.\n\n    Args:\n      model_name: Name of the model on which the inverted is based. The model\n        should be first registered in `models/model_settings.py`.\n      logger: Logger to record the log message.\n      learning_rate: Learning rate for optimization. (default: 1e-2)\n      iteration: Number of iterations for optimization. (default: 100)\n      reconstruction_loss_weight: Weight for reconstruction loss. Should always\n        be a positive number. (default: 1.0)\n      perceptual_loss_weight: Weight for perceptual loss. 0 disables perceptual\n        loss. (default: 5e-5)\n      regularization_loss_weight: Weight for regularization loss from encoder.\n        This is essential for in-domain inversion. However, this loss will\n        automatically ignored if the generative model does not include a valid\n        encoder. 0 disables regularization loss. (default: 2.0)\n    '
    self.logger = logger
    self.model_name = model_name
    self.gan_type = 'stylegan'
    self.G = StyleGANGenerator(self.model_name, self.logger)
    self.E = StyleGANEncoder(self.model_name, self.logger)
    self.F = PerceptualModel(min_val=self.G.min_val, max_val=self.G.max_val)
    self.encode_dim = [self.G.num_layers, self.G.w_space_dim]
    self.run_device = self.G.run_device
    assert (list(self.encode_dim) == list(self.E.encode_dim))
    assert (self.G.gan_type == self.gan_type)
    assert (self.E.gan_type == self.gan_type)
    self.learning_rate = learning_rate
    self.iteration = iteration
    self.loss_pix_weight = reconstruction_loss_weight
    self.loss_feat_weight = perceptual_loss_weight
    self.loss_reg_weight = regularization_loss_weight
    assert (self.loss_pix_weight > 0)
Initializes the inverter.

NOTE: Only Adam optimizer is supported in the optimization process.

Args:
  model_name: Name of the model on which the inverted is based. The model
    should be first registered in `models/model_settings.py`.
  logger: Logger to record the log message.
  learning_rate: Learning rate for optimization. (default: 1e-2)
  iteration: Number of iterations for optimization. (default: 100)
  reconstruction_loss_weight: Weight for reconstruction loss. Should always
    be a positive number. (default: 1.0)
  perceptual_loss_weight: Weight for perceptual loss. 0 disables perceptual
    loss. (default: 5e-5)
  regularization_loss_weight: Weight for regularization loss from encoder.
    This is essential for in-domain inversion. However, this loss will
    automatically ignored if the generative model does not include a valid
    encoder. 0 disables regularization loss. (default: 2.0)
def __init__(self, model_name, learning_rate=0.01, iteration=100, reconstruction_loss_weight=1.0, perceptual_loss_weight=5e-05, regularization_loss_weight=2.0, logger=None):
    'Initializes the inverter.\n\n    NOTE: Only Adam optimizer is supported in the optimization process.\n\n    Args:\n      model_name: Name of the model on which the inverted is based. The model\n        should be first registered in `models/model_settings.py`.\n      logger: Logger to record the log message.\n      learning_rate: Learning rate for optimization. (default: 1e-2)\n      iteration: Number of iterations for optimization. (default: 100)\n      reconstruction_loss_weight: Weight for reconstruction loss. Should always\n        be a positive number. (default: 1.0)\n      perceptual_loss_weight: Weight for perceptual loss. 0 disables perceptual\n        loss. (default: 5e-5)\n      regularization_loss_weight: Weight for regularization loss from encoder.\n        This is essential for in-domain inversion. However, this loss will\n        automatically ignored if the generative model does not include a valid\n        encoder. 0 disables regularization loss. (default: 2.0)\n    '
    self.logger = logger
    self.model_name = model_name
    self.gan_type = 'stylegan'
    self.G = StyleGANGenerator(self.model_name, self.logger)
    self.E = StyleGANEncoder(self.model_name, self.logger)
    self.F = PerceptualModel(min_val=self.G.min_val, max_val=self.G.max_val)
    self.encode_dim = [self.G.num_layers, self.G.w_space_dim]
    self.run_device = self.G.run_device
    assert (list(self.encode_dim) == list(self.E.encode_dim))
    assert (self.G.gan_type == self.gan_type)
    assert (self.E.gan_type == self.gan_type)
    self.learning_rate = learning_rate
    self.iteration = iteration
    self.loss_pix_weight = reconstruction_loss_weight
    self.loss_feat_weight = perceptual_loss_weight
    self.loss_reg_weight = regularization_loss_weight
    assert (self.loss_pix_weight > 0)