MCPcopy Create free account
hub / github.com/AlayaLab/Hive / forward

Method forward

models/flowsep/diffusers/models/autoencoder_kl.py:304–330  ·  view source on GitHub ↗

r""" Args: sample (`torch.FloatTensor`): Input sample. sample_posterior (`bool`, *optional*, defaults to `False`): Whether to sample from the posterior. return_dict (`bool`, *optional*, defaults to `True`): Whether or

(
        self,
        sample: torch.FloatTensor,
        sample_posterior: bool = False,
        return_dict: bool = True,
        generator: Optional[torch.Generator] = None,
    )

Source from the content-addressed store, hash-verified

302 return DecoderOutput(sample=dec)
303
304 def forward(
305 self,
306 sample: torch.FloatTensor,
307 sample_posterior: bool = False,
308 return_dict: bool = True,
309 generator: Optional[torch.Generator] = None,
310 ) -> Union[DecoderOutput, torch.FloatTensor]:
311 r"""
312 Args:
313 sample (`torch.FloatTensor`): Input sample.
314 sample_posterior (`bool`, *optional*, defaults to `False`):
315 Whether to sample from the posterior.
316 return_dict (`bool`, *optional*, defaults to `True`):
317 Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
318 """
319 x = sample
320 posterior = self.encode(x).latent_dist
321 if sample_posterior:
322 z = posterior.sample(generator=generator)
323 else:
324 z = posterior.mode()
325 dec = self.decode(z).sample
326
327 if not return_dict:
328 return (dec,)
329
330 return DecoderOutput(sample=dec)

Callers

nothing calls this directly

Calls 5

encodeMethod · 0.95
decodeMethod · 0.95
DecoderOutputClass · 0.85
sampleMethod · 0.45
modeMethod · 0.45

Tested by

no test coverage detected