diff --git a/.github/workflows/pypi.yml b/.github/workflows/CD.yml similarity index 92% rename from .github/workflows/pypi.yml rename to .github/workflows/CD.yml index fcbaef3..a699a90 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/CD.yml @@ -1,4 +1,4 @@ -name: To PyPI +name: Delivery automation on: push: @@ -30,7 +30,6 @@ jobs: - name: Update version in setup.py and lightorch/_version.py run: | - sed -i "s/{{VERSION_PLACEHOLDER}}/${{ env.TAG_NAME }}/g" setup.py sed -i "s/{{VERSION_PLACEHOLDER}}/${{ env.TAG_NAME }}/g" lightorch/_version.py - name: Build the package diff --git a/.github/workflows/default.yml b/.github/workflows/CI.yml similarity index 97% rename from .github/workflows/default.yml rename to .github/workflows/CI.yml index 03fbf4a..a9b77f0 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/CI.yml @@ -1,4 +1,4 @@ -name: Default +name: Integration automation on: push: diff --git a/README.md b/README.md index eaf5753..790bd82 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ [![license](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![code-style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![pypi](https://img.shields.io/pypi/v/lightorch)](https://pypi.org/project/lightorch) -![CI-CD](https://github.com/Jorgedavyd/LighTorch/actions/workflows/default.yml/badge.svg) +![CI](https://github.com/Jorgedavyd/LighTorch/actions/workflows/CI.yml/badge.svg) +![CD](https://github.com/Jorgedavyd/LighTorch/actions/workflows/CD.yml/badge.svg) # LighTorch diff --git a/lightorch/default/__init__.py b/lightorch/default/__init__.py deleted file mode 100644 index 5d383ce..0000000 --- a/lightorch/default/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .diffusion import * -from .transformer import * -from .vae import * diff --git a/lightorch/default/diffusion.py b/lightorch/default/diffusion.py deleted file mode 100644 index e69de29..0000000 diff --git a/lightorch/default/transformer.py b/lightorch/default/transformer.py deleted file mode 100644 index e69de29..0000000 diff --git a/lightorch/default/vae.py b/lightorch/default/vae.py deleted file mode 100644 index 3da3623..0000000 --- a/lightorch/default/vae.py +++ /dev/null @@ -1,101 +0,0 @@ -import torch -from torch import nn, Tensor -from typing import Tuple, Sequence -from ..nn.criterions import _Loss -from ..training import Module -from dataclasses import dataclass - -""" -VAE - -beta-VAE - -Conditional VAE -""" - - -@dataclass -class ValidKwargs: - optimizer: torch.optim.Optimizer - scheduler: torch.optim.lr_scheduler.LRScheduler - - encoder_lr: float - encoder_wd: float - decoder_lr: float - decoder_wd: float - - grad_clip_value: float - - # Reconstruction criterion - reconstruction_criterion: nn.Module - recons_params: Sequence[float] | float | None - - -class Loss(_Loss): - """ - # Variational Autoencoder Loss: - \mathcal{L}_{total} = \mathcal{L}_{recons} - \beta \mathcal{L}_{KL} - Given a beta parameter, it is converted into a \beta-VAE. - """ - - def __init__(self, beta: float, reconstruction_criterion: nn.Module) -> None: - super().__init__( - reconstruction_criterion.labels.append("KL Divergence"), - reconstruction_criterion.factors.update({"KL Divergence": beta}), - ) - - self.L_recons = reconstruction_criterion(**self.recons_kwargs) - self.beta = beta - - def forward(self, I_out, I_gt, mu, logvar) -> Tuple[Tensor, ...]: - L_recons = self.L_recons(I_out, I_gt) - - L_kl = -0.5 * torch.sum(torch.log(logvar) - 1 + logvar + torch.pow(mu, 2)) - - return (L_recons, L_kl, L_recons + self.beta * L_kl) - - -class VAE(Module): - """ """ - - def __init__( - self, - encoder: nn.Module, - decoder: nn.Module, - conditional: bool = True, - **hparams, - ) -> None: - super().__init__() - # Defining the hyperparameters - for hparam_name, hparam in hparams.items(): - setattr(self, hparam_name, hparam) - # Defining the encoder-decoder architecture - self.encoder = encoder - self.decoder = decoder - # Defining conditional VAE - self.conditional = conditional - # Defining the criterion - self.criterion = Loss(self.beta, self.reconstruction_criterion) - # latent variable characteristics - assert ( - self.encoder.fc.out_features % 2 == 0 - ), f"Not valid encoder final layer output size {self.encoder.fc.out_features}, should be even." - self._half = self.encoder.fc.out_features // 2 - - def _reparametrization(self, encoder_output: Tensor) -> Tuple[Tensor, ...]: - # encoder_output = encoder_output.view(b, _, 2 * self._half, 2*self._half) - pass - - def training_step(self, batch, idx) -> Tensor: - x, y = batch - x, mu, std = self(x, y) - return self.compute_loss(x, mu, std) - - def validation_step(self, batch, idx) -> None: - pass - - def forward(self, x: Tensor) -> Tuple[Tensor, ...] | Tensor: - x = self.encoder(x) - x, mu, std = self._reparametrization(x) - x = self.decoder(x) - return x, mu, std diff --git a/setup.py b/setup.py index af7dc14..769885c 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,5 @@ from setuptools import setup, find_packages -from lightorch import __author__, __email__ +from lightorch import __author__, __email__, __version__ from pathlib import Path this_directory = Path(__file__).parent @@ -8,7 +8,7 @@ if __name__ == "__main__": setup( name="lightorch", - version='{{VERSION_PLACEHOLDER}}', + version=__version__, packages=find_packages(), author=__author__, long_description=long_description, diff --git a/tests/test_models.py b/tests/test_models.py deleted file mode 100644 index e69de29..0000000