hyrax.models.image_dcae
=======================

.. py:module:: hyrax.models.image_dcae


Classes
-------

.. autoapisummary::

   hyrax.models.image_dcae.ArcsinhActivation
   hyrax.models.image_dcae.ImageDCAE


Module Contents
---------------

.. py:class:: ArcsinhActivation(*args, **kwargs)

   Bases: :py:obj:`torch.nn.Module`


   Helper module for ImageDCAE to use the arcsinh function

   Initialize internal Module state, shared by both nn.Module and ScriptModule.


   .. py:method:: forward(x)


.. py:class:: ImageDCAE(config, data_sample=None)

   Bases: :py:obj:`torch.nn.Module`


   This is an autoencoder with skipconnections that should work with
   arbitarily sized images with arbitrary number of channels.

   Initialize internal Module state, shared by both nn.Module and ScriptModule.


   .. py:attribute:: input_shape


   .. py:attribute:: config


   .. py:attribute:: latent_dim


   .. py:attribute:: base_channel_size


   .. py:attribute:: conv_output_size


   .. py:attribute:: encoder1


   .. py:attribute:: encoder2


   .. py:attribute:: encoder3


   .. py:attribute:: encoder4


   .. py:attribute:: pool


   .. py:attribute:: latent_encoder


   .. py:attribute:: latent_decoder


   .. py:attribute:: decoder4


   .. py:attribute:: decoder3


   .. py:attribute:: decoder2


   .. py:attribute:: decoder1


   .. py:attribute:: activation


   .. py:method:: _calculate_conv_output_size()

      Calculate the output size after all convolutional layers for the linear bottleneck.



   .. py:method:: encode(x)

      Encode input to latent space with skip connections.



   .. py:method:: decode(latent, skip_connections, encoded_shape)

      Decode from latent space to image with skip connections.



   .. py:method:: forward(x)

      Forward pass - returns latent representation for anomaly detection.



   .. py:method:: reconstruct(x)

      Full reconstruction for evaluation and anomaly detection.



   .. py:method:: train_step(batch)

      This function contains the logic for a single training step.

      :param batch: A tuple containing the two values the loss function
      :type batch: tuple

      :returns: **Current loss value** -- Dictionary containing the loss value for the current batch.
      :rtype: dict



   .. py:method:: to_tensor(data_dict)
      :staticmethod:


      Convert structured data to tensor format.



