NeuralTSNE.TSNE.Modules package

Submodules

NeuralTSNE.TSNE.Modules.dimensionality_reduction module

class DimensionalityReduction(tsne: <module 'NeuralTSNE.TSNE.ParametricTSNE' from '/tmp/tmpbxegikcq/1aeb06a64c8d2b0c97fea0906ca6d931ffcdb1cc/NeuralTSNE/NeuralTSNE/TSNE/ParametricTSNE/__init__.py'>, shuffle: bool, optimizer: str = 'adam', lr: float = 0.001)[source]View on GitHub

Bases: LightningModule

Lightning Module for training a neural network-based Parametric t-SNE dimensionality reduction model.

Parameters:
  • tsne (ParametricTSNE) – Parametric t-SNE model for feature extraction.

  • shuffle (bool) – Flag indicating whether to shuffle data during training.

  • optimizer (str, optional) – Optimizer for training. Defaults to adam.

  • lr (float, optional) – Learning rate for the optimizer. Defaults to 1e-3.

Note

This class defines a Lightning Module for training a neural network-based Parametric t-SNE dimensionality reduction model for feature extraction. It includes methods for the training step, configuring optimizers, and handling the training process.

configure_optimizers() Optimizer[source]View on GitHub

Configure the optimizer for training.

Returns:

Configured optimizer.

Return type:

torch.optim.Optimizer

Note

This method configures and returns the optimizer for training based on the specified parameters.

on_train_epoch_end() None[source]View on GitHub

Perform actions at the end of each training epoch.

Note

This method is called at the end of each training epoch. If exaggeration has ended and P_multiplied exists, it is deleted to free up memory.

on_train_epoch_start() None[source]View on GitHub

Perform actions at the start of each training epoch.

Note

This method is called at the start of each training epoch. If exaggeration is enabled and has not ended, it modifies the joint probability matrix for the current epoch.

on_train_start() None[source]View on GitHub

Perform actions at the beginning of the training process.

Note

This method is called at the start of the training process and calculates the joint probability matrix P based on the training dataloader.

on_validation_start() None[source]View on GitHub

Perform actions at the beginning of the validation process.

Note

This method is called at the start of the validation process and calculates the joint probability matrix P for each validation dataloader.

predict_step(batch, batch_idx, dataloader_idx=None)[source]View on GitHub

Perform a single step during the prediction process.

Parameters:
  • batch – Input batch.

  • batch_idx – Index of the current batch.

  • dataloader_idx (optional) – Index of the dataloader

Returns:

Model predictions.

Return type:

torch.Tensor

Note

This method is called during the prediction process and returns the model’s predictions for the input batch.

reset_exaggeration_status()[source]View on GitHub

Reset exaggeration status based on the number of exaggeration epochs.

training_step(batch: Tensor | Tuple[Tensor, ...] | List[Tensor | Any], batch_idx: int)[source]View on GitHub

Perform a single training step.

Parameters:
  • batch (Union[torch.Tensor, Tuple[torch.Tensor, …], List[Union[torch.Tensor, Any]]]) – Input batch.

  • batch_idx (int) – Index of the current batch.

Returns:

Dictionary containing the loss value.

Return type:

Dict[str, torch.Tensor]

Note

This method defines a single training step for the dimensionality reduction model. It computes the loss using the model’s logits and the conditional probability matrix _P_batch.

validation_step(batch: Tensor | Tuple[Tensor, ...] | List[Tensor | Any], batch_idx: int, dataloader_idx: int | None = None)[source]View on GitHub

Perform a single validation step.

Parameters:
  • batch (Union[torch.Tensor, Tuple[torch.Tensor, …], List[Union[torch.Tensor, Any]]]) – Input batch.

  • batch_idx – Index of the current batch.

  • dataloader_idx (optional) – Index of the dataloader

Returns:

Dictionary containing the loss value.

Return type:

Dict[str, torch.Tensor]

Note

This method defines a single validation step for the dimensionality reduction model. It computes the loss using the model’s logits and the conditional probability matrix _P_batch.

Module contents