{"id":13435538,"url":"https://github.com/timsainb/tensorflow2-generative-models","last_synced_at":"2025-04-13T05:06:00.583Z","repository":{"id":39006576,"uuid":"186476932","full_name":"timsainb/tensorflow2-generative-models","owner":"timsainb","description":"Implementations of a number of generative models in Tensorflow 2. GAN, VAE, Seq2Seq, VAEGAN, GAIA, Spectrogram Inversion. Everything is self contained in a jupyter notebook for easy export to colab.","archived":false,"fork":false,"pushed_at":"2021-07-18T10:26:20.000Z","size":11957,"stargazers_count":1000,"open_issues_count":10,"forks_count":186,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-04-13T05:05:45.273Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timsainb.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-13T18:47:06.000Z","updated_at":"2025-03-26T07:24:09.000Z","dependencies_parsed_at":"2022-07-18T03:00:32.504Z","dependency_job_id":null,"html_url":"https://github.com/timsainb/tensorflow2-generative-models","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timsainb%2Ftensorflow2-generative-models","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timsainb%2Ftensorflow2-generative-models/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timsainb%2Ftensorflow2-generative-models/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timsainb%2Ftensorflow2-generative-models/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timsainb","download_url":"https://codeload.github.com/timsainb/tensorflow2-generative-models/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665749,"owners_count":21142123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T03:00:36.670Z","updated_at":"2025-04-13T05:06:00.555Z","avatar_url":"https://github.com/timsainb.png","language":"Jupyter Notebook","readme":"[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/timsainb/tensorflow2-generative-models/master)\n\nGenerative models in Tensorflow 2\n==============================\n\n[Tim Sainburg](https://timsainburg.com/) (PhD Candidate, UCSD, Gentner Laboratory)\n\nThis is a small project to implement a number of generative models in Tensorflow 2. Layers and optimizers use Keras. The models are implemented for two datasets: [fashion MNIST](https://github.com/zalandoresearch/fashion-mnist), and [NSYNTH](https://magenta.tensorflow.org/datasets/nsynth). Networks were written with the goal of being as simple and consistent as possible while still being readable. Because each network is self contained within the notebook, they should be easily run in a colab session. \n\n## Included models:\n### Autoencoder (AE) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/timsainb/tensorflow2-generative-models/blob/master/0.0-Autoencoder-fashion-mnist.ipynb)\n\nA simple autoencoder network.\n\n![an autoencoder](imgs/ae.png)\n\n### Variational Autoencoder (VAE) ([article](https://arxiv.org/abs/1312.6114)) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/timsainb/tensorflow2-generative-models/blob/master/1.0-Variational-Autoencoder-fashion-mnist.ipynb)\n\nThe original variational autoencoder network,  using [tensorflow_probability](https://github.com/tensorflow/probability)\n\n![variational autoencoder](imgs/vae.png)\n\n### Generative Adversarial Network (GAN) ([article](https://arxiv.org/abs/1406.2661)) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/timsainb/tensorflow2-generative-models/blob/master/2.0-GAN-fashion-mnist.ipynb)\n\nGANs are a form of neural network in which two sub-networks (the encoder and decoder) are trained on opposing loss functions: an encoder that is trained to produce data which is indiscernable from the true data, and a decoder that is trained to discriminate between the data and generated data.\n\n![gan](imgs/gan.png)\n\n### Wasserstein GAN with Gradient Penalty (WGAN-GP) ([article](https://arxiv.org/abs/1701.07875)) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/timsainb/tensorflow2-generative-models/blob/master/3.0-WGAN-GP-fashion-mnist.ipynb)\n\nWGAN-GP is a GAN that improves over the original loss function to improve training stability. \n\n![wgan gp](imgs/gan.png)\n\n\n### VAE-GAN ([article](https://arxiv.org/abs/1512.09300)) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/timsainb/tensorflow2-generative-models/blob/master/6.0-VAE-GAN-fashion-mnist.ipynb)\n\nVAE-GAN combines the VAE and GAN to autoencode over a latent representation of data in the generator to improve over the pixelwise error function used in autoencoders. \n\n![vae gan](imgs/vaegan.png)\n\n### Generative adversarial interpolative autoencoder (GAIA) ([article](https://arxiv.org/abs/1807.06650)) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/timsainb/tensorflow2-generative-models/blob/master/5.0-GAIA-fashion-mnist.ipynb)\n\nGAIA is an autoencoder trained to learn convex latent representations by adversarially training on interpolations in latent space projections of real data. This is an experimental modification of the original algorithm. For the original algorithm, see here: https://github.com/timsainb/gaia\n\n![generative adversarial interpolative autoencoding network](imgs/gaia.png)\n\n## Other Notebooks:\n\n### Seq2Seq Autoencoder (without attention) (Fasion MNIST: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/timsainb/tensorflow2-generative-models/blob/master/4.0-seq2seq-fashion-mnist.ipynb) | NSYNTH: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/timsainb/tensorflow2-generative-models/blob/master/9.0-seq2seq-NSYNTH.ipynb))\n\nSeq2Seq models use recurrent neural network cells (like LSTMs) to better capture sequential organization in data. This implementation uses Convolutional Layers as input to the LSTM cells, and a single Bidirectional LSTM layer. \n\n![a seq2seq bidirectional lstm in tensorflow 2.0](imgs/seq2seq.png)\n\n### Spectrogramming, Mel Scaling, MFCCs, and Inversion in Tensorflow [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/timsainb/tensorflow2-generative-models/blob/master/7.0-Tensorflow-spectrograms-and-inversion.ipynb)\n\nTensorflow has a signal processing package that allows us to generate spectrograms from waveforms as part of our dataset iterator, rather than pregenerating a second spectrogram dataset. This notebook can serve as a reference for how this is done. Spectrogram inversion is done using the Griffin-Lim algorithm. \n\n![spectrogram inversion in tensorflow 2.0](imgs/spectrogram-inversion.png)\n\n\n### Iterator for NSynth [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/timsainb/tensorflow2-generative-models/blob/master/8.0-NSYNTH-iterator.ipynb)\n\nThe NSYNTH dataset is a set of thousands of musical notes saved as waveforms. To input these into a Seq2Seq model as spectrograms, I wrote a small dataset class that converts to spectrogram in tensorflow (using the code from the spectrogramming notebook). \n\n![a dataset iterator for tensorflow 2.0](imgs/nsynth-dataset.png)\n","funding_links":[],"categories":["Sample Codes / Projects \u003ca name=\"sample\" /\u003e ⛏️📐📁","Jupyter Notebook","Unofficial","\u003cspan id=\"head50\"\u003e3.6. Probablistic Machine Learning and Deep Learning\u003c/span\u003e","Technologies","Model 💛💛💛💛💛\u003ca name=\"Model\" /\u003e"],"sub_categories":["Reinforcement Learning \u003ca name=\"RL\" /\u003e🔮","\u003cspan id=\"head53\"\u003e3.6.3. VAE\u003c/span\u003e","Classification 分类"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimsainb%2Ftensorflow2-generative-models","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimsainb%2Ftensorflow2-generative-models","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimsainb%2Ftensorflow2-generative-models/lists"}