{"id":20021737,"url":"https://github.com/bshall/vectorquantizedvae","last_synced_at":"2025-05-05T01:30:58.593Z","repository":{"id":119398896,"uuid":"207502894","full_name":"bshall/VectorQuantizedVAE","owner":"bshall","description":"A PyTorch implementation of \"Continuous Relaxation Training of Discrete Latent Variable Image Models\"","archived":false,"fork":false,"pushed_at":"2020-03-25T18:26:31.000Z","size":998,"stargazers_count":73,"open_issues_count":1,"forks_count":16,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-08T14:45:48.776Z","etag":null,"topics":["generative-models","pytorch","vae","vq-vae"],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bshall.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-10T08:17:55.000Z","updated_at":"2025-01-03T01:49:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"50eff6ef-b0fb-4d65-adc2-d9e80f0ef11b","html_url":"https://github.com/bshall/VectorQuantizedVAE","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bshall%2FVectorQuantizedVAE","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bshall%2FVectorQuantizedVAE/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bshall%2FVectorQuantizedVAE/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bshall%2FVectorQuantizedVAE/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bshall","download_url":"https://codeload.github.com/bshall/VectorQuantizedVAE/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252423012,"owners_count":21745531,"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":["generative-models","pytorch","vae","vq-vae"],"created_at":"2024-11-13T08:38:04.032Z","updated_at":"2025-05-05T01:30:58.587Z","avatar_url":"https://github.com/bshall.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vector Quantized VAE\nA PyTorch implementation of [Continuous Relaxation Training of Discrete Latent Variable Image Models](http://bayesiandeeplearning.org/2017/papers/54.pdf).\n\nEnsure you have Python 3.7 and PyTorch 1.2 or greater. \nTo train the `VQVAE` model with 8 categorical dimensions and 128 codes per dimension \nrun the following command:\n```\npython train.py --model=VQVAE --latent-dim=8 --num-embeddings=128\n``` \nTo train the `GS-Soft` model use `--model=GSSOFT`. \nPretrained weights for the `VQVAE` and `GS-Soft` models can be found \n[here](https://github.com/bshall/VectorQuantizedVAE/releases/tag/v0.1).\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"assets/reconstructions.png?raw=true\" alt=\"VQVAE Reconstructions\"\u003e\n\u003c/p\u003e\n\nThe `VQVAE` model gets ~4.82 bpd while the `GS-soft` model gets ~4.6 bpd.\n\n# Analysis of the Codebooks \n\nAs demonstrated in the paper, the codebook matrices are low-dimensional, spanning only a few dimensions:\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"assets/variance_ratio.png?raw=true\" alt=\"Explained Variance Ratio\"\u003e\n\u003c/p\u003e\n\nProjecting the codes onto the first 3 principal components shows that the codes typically tile \ncontinuous 1- or 2-D manifolds:\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"assets/codebooks.png?raw=true\" alt=\"Codebook principal components\"\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbshall%2Fvectorquantizedvae","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbshall%2Fvectorquantizedvae","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbshall%2Fvectorquantizedvae/lists"}