rapidae


Namerapidae JSON
Version 0.0.4 PyPI version JSON
download
home_pageNone
SummaryRapidae: Python Library for Rapid Creation and Experimentation of Autoencoders
upload_time2024-04-17 10:24:36
maintainerNone
docs_urlNone
authorNone
requires_python<3.12,>=3.10
licenseNone
keywords autoencoder deep learning machine learning variational autoencoder
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Rapidae: Python Library for Rapid Creation and Experimentation of Autoencoders

[![Documentation Status](https://readthedocs.org/projects/rapidae/badge/?version=latest)](https://rapidae.readthedocs.io/en/latest/?badge=latest)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![made-with-python](https://img.shields.io/badge/Made%20with-Python-1f425f.svg)](https://www.python.org/)

🔗 [Documentation](https://rapidae.readthedocs.io/en/latest/) | 🔗 [PyPI Package](https://pypi.org/project/rapidae/)

## Description 📕

Rapidae is a Python library specialized in simplifying the creation and experimentation of autoencoder models. With a focus on ease of use, this library allows users to explore and develop autoencoder models in an efficient and straightforward manner.

I decided to develop this library to optimize my research workflow and provide a comprehensive resource for educators and learners exploring autoencoders.

As a researcher, I often found myself spending time on repetitive tasks, such as creating project structures or replicating baseline models. (I've lost count of how many times I've gone through the Keras VAE tutorial just to copy the model as a baseline for other experiments.)

As an educator, despite recognizing numerous fantastic online resources, I felt the need for a place where the features I consider important for teaching these models are consolidated: explanation, implementation, and versatility across different backends. The latter is particularly crucial, considering that PyTorch practitioners may find tedious to switch to TensorFlow, and vice versa. With the recently released Keras 3, Rapidae ensures that the user is met with a seamless and engaging experience, enabling to focus on model creation rather than backend specifics.

In summary, this library is designed to be simple enough for educational purposes, yet robust for researchers to concentrate on developing their models and conducting benchmark experiments in a unified environment.

>[!NOTE]
>Shout out to [Pythae](https://github.com/clementchadebec/benchmark_VAE/tree/main), which provides an excellent library for experimenting with VAEs . If you're looking for a quick way to implement autoencoders for image applications, Pythae is probably your best option. Rapidae differs from Pythae in the following ways:
>- It is built on Keras 3, allowing you to experiment with and provide your implementations in either PyTorch, TensorFlow, or JAX.
>- The image models implemented in Rapidae are primarily designed for educational purposes.
>- Rapidae is intended to serve as a benchmarking library for models implemented in the sequential/time-series domain, as these are widely dispersed across various fields.

🚨**Call for contributions**🚨

If you want to add your model to the package or collaborate in the package development feel free to shoot me a message at costanahuel@uniovi.es or just open an issue or a pull request. I´ll be happy to collaborate with you.

## Quick access:
- [Main Features](#main-features)
- [Overview](#overview)
- [Installation](#installation)
- [Available models](#available-models) 
- [Usage](#usage)
- [Custom models and architectures](#custom-models-and-architectures)
- [Switching backends](#switching-backends)
- [Experiment tracking with wandb](#experiment-tracking-with-wandb)
- [Documentation](https://rapidae.readthedocs.io/en/latest/)
- [Citing this repository](#citation)


## Main features

- **Ease of Use:** Rapidae has been designed to make the process of creating and experimenting with autoencoders as simple as possible, users can create and train autoencoder models with just a few lines of code.

- **Backend versatility:** Rapidae relies on Keras 3.0, which is backend agnostic, allowing switching indistinctly between Tensorflow, Pytorch or Jax.

- **Customization:** Easily customize model architecture, loss functions, and training parameters to suit your specific use case.

- **Experimentation:** Conduct experiments with different hyperparameters and configurations to optimize the performance of your models.


## Overview

Rapidae is structured as follows:

- **data:** This module contains everything related to the acquisition and preprocessing of datasets. 

- **models:** This is the core module of the library. It includes the base architectures on which new ones can be created, several predefined architectures and a list of predefined default encoders and decoders.

- **pipelines:** Pipelines are designed to perform a specific task or set of tasks such as data preprocessing or model training.

- **evaluate:** Its main functionality is the evaluation of model performance. It also includes a tool utils for various tasks: latent space visualization, reconstructions, evaluation, etc.
 

## Installation

The library has been tested with Python versions >=3.10, <3.12, therefore we recommend first creating a **virtual environment** with a suitable python version. Here´s an example with conda:

```conda create -n rapidae python=3.10```

Then, just activate the environment with ```conda activate rapidae``` and install the library.

>[!NOTE]
>If you are using Google Colab, you are good to go (i.e. you do not need to create an environment). The library is fully compatible with Colab´s default environment.


### With Pip
To install the latest stable release of this library run the following:

```bash
  pip install rapidae
```

Note that you will also need to install a backend framework. Here are the official installation guidelines:

- [Installing TensorFlow](https://www.tensorflow.org/install)
- [Installing PyTorch](https://pytorch.org/get-started/locally/)
- [Installing JAX](https://jax.readthedocs.io/en/latest/installation.html)

>[!IMPORTANT]
>If you install TensorFlow, you should reinstall Keras 3 afterwards via ```pip install --upgrade keras```. This is a temporary step while TensorFlow is pinned to Keras 2, and will no longer be necessary after TensorFlow 2.16. The cause is that tensorflow==2.15 will overwrite your Keras installation with keras==2.15.

### From source code
You can also clone the repo to have fully access to all the code. Some features may not yet be available in the published stable version so this is the best way to stay up-to-date with the latest updates.

```bash
git clone https://github.com/NahuelCostaCortez/rapidae
cd rapidae
```

Then you only have to install the requirements:

```bash
pip install -r requirements.txt
```

## Available Models

Below is the list of the models currently implemented in the library.

|               Models               |                                                                                    Training example                                                                                    |                     Paper                    |                           Official Implementation                          |
|:----------------------------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:--------------------------------------------:|:--------------------------------------------------------------------------:|
| Autoencoder (AE)                   | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NahuelCostaCortez/rapidae/blob/main/examples/QUICKSTART_tutorial.ipynb) | [link](https://www.science.org/doi/abs/10.1126/science.1127647)                                             |  
| Denoising Autoencoder                  | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NahuelCostaCortez/rapidae/blob/main/examples/denoising_autoencoder.ipynb) | [link](https://www.cs.toronto.edu/~larocheh/publications/icml-2008-denoising-autoencoders.pdf)                                             | [link](https://keras.io/examples/vision/autoencoder/)
| Sparse Autoencoder                 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NahuelCostaCortez/rapidae/blob/main/examples/sparse_autoencoder.ipynb) | [link](https://arxiv.org/abs/1312.5663)                                             |   
| Contractive Autoencoder                 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NahuelCostaCortez/rapidae/blob/main/examples/contractive_autoencoder.ipynb) | [link](http://www.icml-2011.org/papers/455_icmlpaper.pdf)                                             |  
| Variational Autoencoder (VAE)                 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NahuelCostaCortez/rapidae/blob/main/examples/vae.ipynb) | [link](https://arxiv.org/abs/1312.6114)                                             | [link](https://keras.io/examples/generative/vae/)
| Beta Variational Autoencoder (BetaVAE)                 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NahuelCostaCortez/rapidae/blob/main/examples/beta_vae.ipynb)| [link](https://openreview.net/pdf?id=Sy2fzU9gl)                                             | 
| Vector Quantised-Variational AutoEncoder (VQ-VAE)                 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NahuelCostaCortez/rapidae/blob/main/examples/vae.ipynb) | [link](https://proceedings.neurips.cc/paper_files/paper/2017/file/7a98af17e63a0ac09ce2e96d03992fbc-Paper.pdf)                                             | [link](https://keras.io/examples/generative/vq_vae/)
| 
Recurrent Variational AutoEncoder (RVAE)                 | SOON | [link](https://ieeexplore.ieee.org/document/9373315)                                             | [link](https://github.com/NahuelCostaCortez/RVAE)
Recurrent Variational Encoder (RVE)                 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NahuelCostaCortez/rapidae/blob/main/examples/RVE_RUL.ipynb) | [link](https://www.sciencedirect.com/science/article/pii/S0951832022000321)                                             | [link](https://github.com/NahuelCostaCortez/Remaining-Useful-Life-Estimation-Variational)
| ICFormer                 | SOON | [link](https://www.sciencedirect.com/science/article/pii/S0378775323012867)                                             | [link](https://github.com/NahuelCostaCortez/ICFormer)
| Hierarchical Variational Autoencoder (HVAE)                 | SOON | [link](https://arxiv.org/abs/1905.06845)                                             | [link](https://github.com/fhkingma/bitswap)
| interval-valued Variational Autoencoder (iVAE)                 | IN PROGRESS |                                             | 


## Usage
[Here](https://github.com/NahuelCostaCortez/rapidae/blob/main/examples/QUICKSTART_tutorial.ipynb) you have a simple tutorial with the most relevant aspects of the library. In addition, in the [examples folder](https://github.com/NahuelCostaCortez/rapidae/tree/main/examples), you will find a series of notebooks for each model and with particular use cases.

You can also use a web interface made with Streamlit where you can load datasets, configure models and hypeparameters, train, and evaluate the results. Check the [web interface](https://github.com/NahuelCostaCortez/rapidae/blob/main/examples/web_interface.ipynb) notebook.

## Custom models and loss functions
You can provide your own autoencoder architecture. Here´s an example for defining a custom encoder and a custom decoder:

```
from rapidae.models.base import BaseEncoder, BaseDecoder
from keras.layers import Dense

class Custom_Encoder(BaseEncoder):
    def __init__(self, input_dim, latent_dim, **kwargs): # you can add more arguments, but al least these are required
        BaseEncoder.__init__(self, input_dim=input_dim, latent_dim=latent_dim)

        self.layer_1 = Dense(300)
        self.layer_2 = Dense(150)
        self.layer_3 = Dense(self.latent_dim)

    def call(self, x):
        x = self.layer_1(x)
        x = self.layer_2(x)
        x = self.layer_3(x)
        return x
```

```
class Custom_Decoder(BaseDecoder):
    def __init__(self, input_dim, latent_dim, **kwargs): # you can add more arguments, but al least these are required
        BaseDecoder.__init__(self, input_dim=input_dim, latent_dim=latent_dim)

        self.layer_1 = Dense(self.latent_dim)
        self.layer_2 = Dense(self.input_dim)

    def call(self, x):
        x = self.layer_1(x)
        x = self.layer_2(x)
        return x
```

You can also provide a custom model. This is specially useful if you want to implement your own loss function.

```
from rapidae.models.base import BaseAE
from keras.ops import mean
from keras.losses import mean_squared_error

class CustomModel(BaseAE):
    def __init__(self, input_dim, latent_dim, encoder, decoder):
        # If you are adding your model to the source code there is no need to specify the encoder and decoder, just place them in the same directory as the model and the BaseAE constructor will initialize them
        BaseAE.__init__(
            self,
            input_dim=input_dim,
            latent_dim=latent_dim,
            encoder=encoder,
            decoder=decoder
        )
        
    def call(self, x):
        # IMPLEMENT FORWARD PASS
        x = self.encoder(x)
        x = self.decoder(x)

        return x
      
    def compute_loss(self, x=None, y=None, y_pred=None, sample_weight=None):
        '''
        Computes the loss of the model.
        x: input data
        y: target data
        y_pred: predicted data (output of call)
        sample_weight: Optional array of the same length as x, containing weights to apply to the model's loss for each sample
        '''
        # IMPLEMENT LOSS FUNCTION
        loss = mean(mean_squared_error(x, y_pred))

        return loss
```

## Switching backends
Since Rapidae uses Keras 3, you can easily switch among Tensorflow, Pytorch and Jax (Tensorflow is the selected option by default).

You can export the environment variable KERAS_BACKEND or you can edit your local config file at ~/.keras/keras.json to configure your backend. Available backend options are: "jax", "tensorflow", "torch". Example:

```bash
export KERAS_BACKEND="torch"
```

In a notebook, you can do:

```c
import os
os.environ["KERAS_BACKEND"] = "torch" 
import keras
```

## Experiment tracking with wandb

If you want to add experiment tracking to rapidae models you can just create a Wandb callback and pass it to the TrainingPipeline as follows (this also applies to other experiment tracking frameworks):

```
wandb_cb = WandbCallback()

wandb_cb.setup(
    training_config=your_training_config,
    model_config=your_model_config,
    project_name="your_wandb_project",
    entity_name="your_wandb_entity",
)

pipeline = TrainingPipeline(name="you_pipeline_name", 
                            model=model,
                            callbacks=[wandb_cb])
```

## Documentation

Check out the full documentation for detailed information on installation, usage, examples and recipes: 🔗 [Documentation Link](https://rapidae.readthedocs.io/en/latest/)

All documentation source and configuration files are located inside the docs directory.


## Dealing with issues	

If you are experiencing any issues while running the code or request new features/models to be implemented please [open an issue on github](https://github.com/NahuelCostaCortez/rapidae/issues).


## Citation

If you find this work useful or incorporate it into your research, please consider citing it 🙏🏻.

```
@software{Costa_Rapidae,
author = {Costa, Nahuel},
license = {Apache-2.0},
title = {{Rapidae}},
url = {https://github.com/NahuelCostaCortez/rapidae}
}
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "rapidae",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.12,>=3.10",
    "maintainer_email": null,
    "keywords": "autoencoder, deep learning, machine learning, variational autoencoder",
    "author": null,
    "author_email": "Nahuel Costa <costanahuel@gmail.com>, Lucas P\u00e9rez <lucasperezca22@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/55/c6/360a400e6f0b28f616022ea0176a8f9fe813499e2e9a7fb22a143f383122/rapidae-0.0.4.tar.gz",
    "platform": null,
    "description": "# Rapidae: Python Library for Rapid Creation and Experimentation of Autoencoders\n\n[![Documentation Status](https://readthedocs.org/projects/rapidae/badge/?version=latest)](https://rapidae.readthedocs.io/en/latest/?badge=latest)\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![made-with-python](https://img.shields.io/badge/Made%20with-Python-1f425f.svg)](https://www.python.org/)\n\n\ud83d\udd17 [Documentation](https://rapidae.readthedocs.io/en/latest/) | \ud83d\udd17 [PyPI Package](https://pypi.org/project/rapidae/)\n\n## Description \ud83d\udcd5\n\nRapidae is a Python library specialized in simplifying the creation and experimentation of autoencoder models. With a focus on ease of use, this library allows users to explore and develop autoencoder models in an efficient and straightforward manner.\n\nI decided to develop this library to optimize my research workflow and provide a comprehensive resource for educators and learners exploring autoencoders.\n\nAs a researcher, I often found myself spending time on repetitive tasks, such as creating project structures or replicating baseline models. (I've lost count of how many times I've gone through the Keras VAE tutorial just to copy the model as a baseline for other experiments.)\n\nAs an educator, despite recognizing numerous fantastic online resources, I felt the need for a place where the features I consider important for teaching these models are consolidated: explanation, implementation, and versatility across different backends. The latter is particularly crucial, considering that PyTorch practitioners may find tedious to switch to TensorFlow, and vice versa. With the recently released Keras 3, Rapidae ensures that the user is met with a seamless and engaging experience, enabling to focus on model creation rather than backend specifics.\n\nIn summary, this library is designed to be simple enough for educational purposes, yet robust for researchers to concentrate on developing their models and conducting benchmark experiments in a unified environment.\n\n>[!NOTE]\n>Shout out to [Pythae](https://github.com/clementchadebec/benchmark_VAE/tree/main), which provides an excellent library for experimenting with VAEs . If you're looking for a quick way to implement autoencoders for image applications, Pythae is probably your best option. Rapidae differs from Pythae in the following ways:\n>- It is built on Keras 3, allowing you to experiment with and provide your implementations in either PyTorch, TensorFlow, or JAX.\n>- The image models implemented in Rapidae are primarily designed for educational purposes.\n>- Rapidae is intended to serve as a benchmarking library for models implemented in the sequential/time-series domain, as these are widely dispersed across various fields.\n\n\ud83d\udea8**Call for contributions**\ud83d\udea8\n\nIf you want to add your model to the package or collaborate in the package development feel free to shoot me a message at costanahuel@uniovi.es or just open an issue or a pull request. I\u00b4ll be happy to collaborate with you.\n\n## Quick access:\n- [Main Features](#main-features)\n- [Overview](#overview)\n- [Installation](#installation)\n- [Available models](#available-models) \n- [Usage](#usage)\n- [Custom models and architectures](#custom-models-and-architectures)\n- [Switching backends](#switching-backends)\n- [Experiment tracking with wandb](#experiment-tracking-with-wandb)\n- [Documentation](https://rapidae.readthedocs.io/en/latest/)\n- [Citing this repository](#citation)\n\n\n## Main features\n\n- **Ease of Use:** Rapidae has been designed to make the process of creating and experimenting with autoencoders as simple as possible, users can create and train autoencoder models with just a few lines of code.\n\n- **Backend versatility:** Rapidae relies on Keras 3.0, which is backend agnostic, allowing switching indistinctly between Tensorflow, Pytorch or Jax.\n\n- **Customization:** Easily customize model architecture, loss functions, and training parameters to suit your specific use case.\n\n- **Experimentation:** Conduct experiments with different hyperparameters and configurations to optimize the performance of your models.\n\n\n## Overview\n\nRapidae is structured as follows:\n\n- **data:** This module contains everything related to the acquisition and preprocessing of datasets. \n\n- **models:** This is the core module of the library. It includes the base architectures on which new ones can be created, several predefined architectures and a list of predefined default encoders and decoders.\n\n- **pipelines:** Pipelines are designed to perform a specific task or set of tasks such as data preprocessing or model training.\n\n- **evaluate:** Its main functionality is the evaluation of model performance. It also includes a tool utils for various tasks: latent space visualization, reconstructions, evaluation, etc.\n \n\n## Installation\n\nThe library has been tested with Python versions >=3.10, <3.12, therefore we recommend first creating a **virtual environment** with a suitable python version. Here\u00b4s an example with conda:\n\n```conda create -n rapidae python=3.10```\n\nThen, just activate the environment with ```conda activate rapidae``` and install the library.\n\n>[!NOTE]\n>If you are using Google Colab, you are good to go (i.e. you do not need to create an environment). The library is fully compatible with Colab\u00b4s default environment.\n\n\n### With Pip\nTo install the latest stable release of this library run the following:\n\n```bash\n  pip install rapidae\n```\n\nNote that you will also need to install a backend framework. Here are the official installation guidelines:\n\n- [Installing TensorFlow](https://www.tensorflow.org/install)\n- [Installing PyTorch](https://pytorch.org/get-started/locally/)\n- [Installing JAX](https://jax.readthedocs.io/en/latest/installation.html)\n\n>[!IMPORTANT]\n>If you install TensorFlow, you should reinstall Keras 3 afterwards via ```pip install --upgrade keras```. This is a temporary step while TensorFlow is pinned to Keras 2, and will no longer be necessary after TensorFlow 2.16. The cause is that tensorflow==2.15 will overwrite your Keras installation with keras==2.15.\n\n### From source code\nYou can also clone the repo to have fully access to all the code. Some features may not yet be available in the published stable version so this is the best way to stay up-to-date with the latest updates.\n\n```bash\ngit clone https://github.com/NahuelCostaCortez/rapidae\ncd rapidae\n```\n\nThen you only have to install the requirements:\n\n```bash\npip install -r requirements.txt\n```\n\n## Available Models\n\nBelow is the list of the models currently implemented in the library.\n\n|               Models               |                                                                                    Training example                                                                                    |                     Paper                    |                           Official Implementation                          |\n|:----------------------------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:--------------------------------------------:|:--------------------------------------------------------------------------:|\n| Autoencoder (AE)                   | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NahuelCostaCortez/rapidae/blob/main/examples/QUICKSTART_tutorial.ipynb) | [link](https://www.science.org/doi/abs/10.1126/science.1127647)                                             |  \n| Denoising Autoencoder                  | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NahuelCostaCortez/rapidae/blob/main/examples/denoising_autoencoder.ipynb) | [link](https://www.cs.toronto.edu/~larocheh/publications/icml-2008-denoising-autoencoders.pdf)                                             | [link](https://keras.io/examples/vision/autoencoder/)\n| Sparse Autoencoder                 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NahuelCostaCortez/rapidae/blob/main/examples/sparse_autoencoder.ipynb) | [link](https://arxiv.org/abs/1312.5663)                                             |   \n| Contractive Autoencoder                 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NahuelCostaCortez/rapidae/blob/main/examples/contractive_autoencoder.ipynb) | [link](http://www.icml-2011.org/papers/455_icmlpaper.pdf)                                             |  \n| Variational Autoencoder (VAE)                 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NahuelCostaCortez/rapidae/blob/main/examples/vae.ipynb) | [link](https://arxiv.org/abs/1312.6114)                                             | [link](https://keras.io/examples/generative/vae/)\n| Beta Variational Autoencoder (BetaVAE)                 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NahuelCostaCortez/rapidae/blob/main/examples/beta_vae.ipynb)| [link](https://openreview.net/pdf?id=Sy2fzU9gl)                                             | \n| Vector Quantised-Variational AutoEncoder (VQ-VAE)                 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NahuelCostaCortez/rapidae/blob/main/examples/vae.ipynb) | [link](https://proceedings.neurips.cc/paper_files/paper/2017/file/7a98af17e63a0ac09ce2e96d03992fbc-Paper.pdf)                                             | [link](https://keras.io/examples/generative/vq_vae/)\n| \nRecurrent Variational AutoEncoder (RVAE)                 | SOON | [link](https://ieeexplore.ieee.org/document/9373315)                                             | [link](https://github.com/NahuelCostaCortez/RVAE)\nRecurrent Variational Encoder (RVE)                 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NahuelCostaCortez/rapidae/blob/main/examples/RVE_RUL.ipynb) | [link](https://www.sciencedirect.com/science/article/pii/S0951832022000321)                                             | [link](https://github.com/NahuelCostaCortez/Remaining-Useful-Life-Estimation-Variational)\n| ICFormer                 | SOON | [link](https://www.sciencedirect.com/science/article/pii/S0378775323012867)                                             | [link](https://github.com/NahuelCostaCortez/ICFormer)\n| Hierarchical Variational Autoencoder (HVAE)                 | SOON | [link](https://arxiv.org/abs/1905.06845)                                             | [link](https://github.com/fhkingma/bitswap)\n| interval-valued Variational Autoencoder (iVAE)                 | IN PROGRESS |                                             | \n\n\n## Usage\n[Here](https://github.com/NahuelCostaCortez/rapidae/blob/main/examples/QUICKSTART_tutorial.ipynb) you have a simple tutorial with the most relevant aspects of the library. In addition, in the [examples folder](https://github.com/NahuelCostaCortez/rapidae/tree/main/examples), you will find a series of notebooks for each model and with particular use cases.\n\nYou can also use a web interface made with Streamlit where you can load datasets, configure models and hypeparameters, train, and evaluate the results. Check the [web interface](https://github.com/NahuelCostaCortez/rapidae/blob/main/examples/web_interface.ipynb) notebook.\n\n## Custom models and loss functions\nYou can provide your own autoencoder architecture. Here\u00b4s an example for defining a custom encoder and a custom decoder:\n\n```\nfrom rapidae.models.base import BaseEncoder, BaseDecoder\nfrom keras.layers import Dense\n\nclass Custom_Encoder(BaseEncoder):\n    def __init__(self, input_dim, latent_dim, **kwargs): # you can add more arguments, but al least these are required\n        BaseEncoder.__init__(self, input_dim=input_dim, latent_dim=latent_dim)\n\n        self.layer_1 = Dense(300)\n        self.layer_2 = Dense(150)\n        self.layer_3 = Dense(self.latent_dim)\n\n    def call(self, x):\n        x = self.layer_1(x)\n        x = self.layer_2(x)\n        x = self.layer_3(x)\n        return x\n```\n\n```\nclass Custom_Decoder(BaseDecoder):\n    def __init__(self, input_dim, latent_dim, **kwargs): # you can add more arguments, but al least these are required\n        BaseDecoder.__init__(self, input_dim=input_dim, latent_dim=latent_dim)\n\n        self.layer_1 = Dense(self.latent_dim)\n        self.layer_2 = Dense(self.input_dim)\n\n    def call(self, x):\n        x = self.layer_1(x)\n        x = self.layer_2(x)\n        return x\n```\n\nYou can also provide a custom model. This is specially useful if you want to implement your own loss function.\n\n```\nfrom rapidae.models.base import BaseAE\nfrom keras.ops import mean\nfrom keras.losses import mean_squared_error\n\nclass CustomModel(BaseAE):\n    def __init__(self, input_dim, latent_dim, encoder, decoder):\n        # If you are adding your model to the source code there is no need to specify the encoder and decoder, just place them in the same directory as the model and the BaseAE constructor will initialize them\n        BaseAE.__init__(\n            self,\n            input_dim=input_dim,\n            latent_dim=latent_dim,\n            encoder=encoder,\n            decoder=decoder\n        )\n        \n    def call(self, x):\n        # IMPLEMENT FORWARD PASS\n        x = self.encoder(x)\n        x = self.decoder(x)\n\n        return x\n      \n    def compute_loss(self, x=None, y=None, y_pred=None, sample_weight=None):\n        '''\n        Computes the loss of the model.\n        x: input data\n        y: target data\n        y_pred: predicted data (output of call)\n        sample_weight: Optional array of the same length as x, containing weights to apply to the model's loss for each sample\n        '''\n        # IMPLEMENT LOSS FUNCTION\n        loss = mean(mean_squared_error(x, y_pred))\n\n        return loss\n```\n\n## Switching backends\nSince Rapidae uses Keras 3, you can easily switch among Tensorflow, Pytorch and Jax (Tensorflow is the selected option by default).\n\nYou can export the environment variable KERAS_BACKEND or you can edit your local config file at ~/.keras/keras.json to configure your backend. Available backend options are: \"jax\", \"tensorflow\", \"torch\". Example:\n\n```bash\nexport KERAS_BACKEND=\"torch\"\n```\n\nIn a notebook, you can do:\n\n```c\nimport os\nos.environ[\"KERAS_BACKEND\"] = \"torch\" \nimport keras\n```\n\n## Experiment tracking with wandb\n\nIf you want to add experiment tracking to rapidae models you can just create a Wandb callback and pass it to the TrainingPipeline as follows (this also applies to other experiment tracking frameworks):\n\n```\nwandb_cb = WandbCallback()\n\nwandb_cb.setup(\n    training_config=your_training_config,\n    model_config=your_model_config,\n    project_name=\"your_wandb_project\",\n    entity_name=\"your_wandb_entity\",\n)\n\npipeline = TrainingPipeline(name=\"you_pipeline_name\", \n                            model=model,\n                            callbacks=[wandb_cb])\n```\n\n## Documentation\n\nCheck out the full documentation for detailed information on installation, usage, examples and recipes: \ud83d\udd17 [Documentation Link](https://rapidae.readthedocs.io/en/latest/)\n\nAll documentation source and configuration files are located inside the docs directory.\n\n\n## Dealing with issues\t\n\nIf you are experiencing any issues while running the code or request new features/models to be implemented please [open an issue on github](https://github.com/NahuelCostaCortez/rapidae/issues).\n\n\n## Citation\n\nIf you find this work useful or incorporate it into your research, please consider citing it \ud83d\ude4f\ud83c\udffb.\n\n```\n@software{Costa_Rapidae,\nauthor = {Costa, Nahuel},\nlicense = {Apache-2.0},\ntitle = {{Rapidae}},\nurl = {https://github.com/NahuelCostaCortez/rapidae}\n}\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Rapidae: Python Library for Rapid Creation and Experimentation of Autoencoders",
    "version": "0.0.4",
    "project_urls": {
        "Homepage": "https://github.com/NahuelCostaCortez/rapidae",
        "Issues": "https://github.com/NahuelCostaCortez/rapidae/issues"
    },
    "split_keywords": [
        "autoencoder",
        " deep learning",
        " machine learning",
        " variational autoencoder"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e4b95e97a2e9e80fd4c8878d7fd921a24b18a6271d8ec3c81a969b952042c5b2",
                "md5": "b5882abcd6c1aeac830161972e6e1424",
                "sha256": "d1622e356e44f246121268e8256b7c236aeaf489b430b03a05f5685b1be768e5"
            },
            "downloads": -1,
            "filename": "rapidae-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b5882abcd6c1aeac830161972e6e1424",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.12,>=3.10",
            "size": 60785,
            "upload_time": "2024-04-17T10:24:33",
            "upload_time_iso_8601": "2024-04-17T10:24:33.448319Z",
            "url": "https://files.pythonhosted.org/packages/e4/b9/5e97a2e9e80fd4c8878d7fd921a24b18a6271d8ec3c81a969b952042c5b2/rapidae-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "55c6360a400e6f0b28f616022ea0176a8f9fe813499e2e9a7fb22a143f383122",
                "md5": "09c8f46660fea2c4865a7c8f7bdce6bf",
                "sha256": "938f02d28111ee6778103c732acd5fa62655d83ef9bc98b9144b713aa2d97aa2"
            },
            "downloads": -1,
            "filename": "rapidae-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "09c8f46660fea2c4865a7c8f7bdce6bf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.12,>=3.10",
            "size": 2839429,
            "upload_time": "2024-04-17T10:24:36",
            "upload_time_iso_8601": "2024-04-17T10:24:36.184123Z",
            "url": "https://files.pythonhosted.org/packages/55/c6/360a400e6f0b28f616022ea0176a8f9fe813499e2e9a7fb22a143f383122/rapidae-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-17 10:24:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "NahuelCostaCortez",
    "github_project": "rapidae",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "rapidae"
}
        
Elapsed time: 0.46661s