def __init__(self, dataset, decoder, encoder=None, encoder_latent=None, p0_z=None, device=None): super().__init__() if p0_z is None: p0_z = dist.Normal(torch.tensor([]), torch.tensor([])) self.decoder = decoder.to(device) if encoder_latent is not None: self.encoder_latent = encoder_latent.to(device) else: self.encoder_latent = None if encoder is not None: self.encoder = encoder.to(device) else: self.encoder = None # init category_center category_count = len(dataset.metadata) self.category_count = category_count self.category_centers = torch.zeros(category_count, decoder.c_dim).to(device) self.pre_category_centers = torch.rand(category_count, decoder.c_dim).to(device) self._device = device self.p0_z = p0_z
def __init__(self, cfg, decoder, encoder=None, dann_discriminator=None, encoder_latent=None, p0_z=None, device=None): super().__init__() if p0_z is None: p0_z = dist.Normal(torch.tensor([]), torch.tensor([])) self.decoder = decoder.to(device) if encoder_latent is not None: self.encoder_latent = encoder_latent.to(device) else: self.encoder_latent = None if encoder is not None: self.encoder = encoder.to(device) else: self.encoder = None if dann_discriminator is not None: self.dann_discriminator = dann_discriminator.to(device) else: self.dann_discriminator = None self._device = device self.p0_z = p0_z
def __init__( self, dataset, decoder1, decoder2, decoder3, encoder=None, encoder_latent=None, p0_z=None, device=None, use_local_feature=False, logits2_ratio=1., logits1_ratio=1., local_feature_mask=False, ): super().__init__() if p0_z is None: p0_z = dist.Normal(torch.tensor([]), torch.tensor([])) self.decoder1 = decoder1.to(device) self.decoder2 = decoder2.to(device) self.decoder3 = decoder3.to(device) self.use_local_feature = use_local_feature self.local_feature_mask = local_feature_mask if self.local_feature_mask: print('using local feature predict mask') if encoder_latent is not None: self.encoder_latent = encoder_latent.to(device) else: self.encoder_latent = None if encoder is not None: self.encoder = encoder.to(device) else: self.encoder = None # init category_center category_count = len(dataset.metadata) self.category_count = category_count self._device = device self.p0_z = p0_z self.logits2_ratio = logits2_ratio self.logits1_ratio = logits1_ratio