{"id":22202363,"url":"https://github.com/ryushinn/flows-on-sphere","last_synced_at":"2025-07-27T04:31:45.610Z","repository":{"id":41445458,"uuid":"507705129","full_name":"ryushinn/flows-on-sphere","owner":"ryushinn","description":"This is a Pytorch implementation of [normalizing flows on tori and spheres, ICML 2020]","archived":false,"fork":false,"pushed_at":"2022-10-12T12:45:55.000Z","size":309,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-03-22T08:27:53.540Z","etag":null,"topics":["distribution-estimation","manifolds","normalizing-flows"],"latest_commit_sha":null,"homepage":"","language":"Python","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/ryushinn.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}},"created_at":"2022-06-26T23:14:30.000Z","updated_at":"2022-12-13T05:50:42.000Z","dependencies_parsed_at":"2023-01-20T01:01:31.639Z","dependency_job_id":null,"html_url":"https://github.com/ryushinn/flows-on-sphere","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryushinn%2Fflows-on-sphere","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryushinn%2Fflows-on-sphere/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryushinn%2Fflows-on-sphere/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryushinn%2Fflows-on-sphere/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryushinn","download_url":"https://codeload.github.com/ryushinn/flows-on-sphere/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227759916,"owners_count":17815626,"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":["distribution-estimation","manifolds","normalizing-flows"],"created_at":"2024-12-02T16:14:44.190Z","updated_at":"2024-12-02T16:14:44.870Z","avatar_url":"https://github.com/ryushinn.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Overview\nThis is a Pytorch implementation of [Normalizing Flows on Tori and Spheres](https://arxiv.org/abs/2002.02428) by Rezende et al. All 3 flows on spheres MS, EMP, and EMSRE are implemented, and the Table.1 results have been reproduced. \n\nThis is another great and helpful [JAX attempt](https://github.com/katalinic/sdflows) I refered though the experiment of (N=24, K=1) fails in their case.\n\n# Experiments\n\nWe conduct the experiments reported in the Table.1 in the paper, and compare results below (theirs/ours):\n\n## Quantitative\n\n| Model                       | KL          | ESS       |\n| --------------------------- | ----------- | --------- |\n| MS \u003cimg src=\"https://latex.codecogs.com/svg.image?\\inline\u0026space;(N_T=1,K_m=12,K_s=\u0026space;32)\" title=\"https://latex.codecogs.com/svg.image?\\inline (N_T=1,K_m=12,K_s= 32)\" /\u003e | 0.05 / 0.03 | 90% / 96% |\n| EMP \u003cimg src=\"https://latex.codecogs.com/svg.image?\\inline\u0026space;(N_T=1)\" title=\"https://latex.codecogs.com/svg.image?\\inline (N_T=1)\" /\u003e               | 0.50 / 0.59 | 43% / 42% |\n| EMSRE \u003cimg src=\"https://latex.codecogs.com/svg.image?\\inline\u0026space;(N_T=1,\u0026space;K=12)\" title=\"https://latex.codecogs.com/svg.image?\\inline (N_T=1, K=12)\" /\u003e       | 0.82 / 0.81 | 42% / 48% |\n| EMSRE \u003cimg src=\"https://latex.codecogs.com/svg.image?\\inline\u0026space;(N_T=6,\u0026space;K=5)\" title=\"https://latex.codecogs.com/svg.image?\\inline (N_T=6, K=5)\" /\u003e        | 0.19 / 0.19 | 75% / 82% |\n| EMSRE \u003cimg src=\"https://latex.codecogs.com/svg.image?\\inline\u0026space;(N_T=24,\u0026space;K=1)\" title=\"https://latex.codecogs.com/svg.image?\\inline (N_T=24, K=1)\" /\u003e       | 0.10 / 0.16 | 85% / 84% |\n\n## Qualitative\n|  Tagrgt Density   |   Approximated Density by MS \u003cimg src=\"https://latex.codecogs.com/svg.image?\\inline\u0026space;(N_T=1,K_m=12,K_s=\u0026space;32)\" title=\"https://latex.codecogs.com/svg.image?\\inline (N_T=1,K_m=12,K_s= 32)\" /\u003e |  Approximated Density by EMSRE \u003cimg src=\"https://latex.codecogs.com/svg.image?\\inline\u0026space;(N_T=24,\u0026space;K=1)\" title=\"https://latex.codecogs.com/svg.image?\\inline (N_T=24, K=1)\" /\u003e  |  Approximated Density by EMP \u003cimg src=\"https://latex.codecogs.com/svg.image?\\inline\u0026space;(N_T=1)\" title=\"https://latex.codecogs.com/svg.image?\\inline (N_T=1)\" /\u003e   |\n| --- | --- | --- | --- |\n|  \u003cimg src=\"md.assets/README/s2_target_density.png\" alt=\"s2_target_density\"/\u003e |  \u003cimg src=\"md.assets/README/flow_density_MS.png\" alt=\"flow_density_MS\" /\u003e   |  \u003cimg src=\"md.assets/README/flow_density_EMSRE.png\" alt=\"flow_density_EMSRE\" /\u003e   |  \u003cimg src=\"md.assets/README/flow_density_EMP.png\" alt=\"flow_density_EMP\"/\u003e   |\n\n# Run\n\n```bash\npip install -r requirements.txt\n\n# run MS\npython MS.py --N 1 --Km 12 --Ks 32\n# run EMSRE\npython EMSRE --N 24 --K 1\n# run EMP\npython EMP.py --N 1\n```\n\n# Some derivations\n\n1. The gradient of spline transforms: check the paper [Neural Spline Flows](https://proceedings.neurips.cc/paper/2019/hash/7ac71d433f282034e088473244df8c02-Abstract.html)\n\n2. The gradient of mobius transforms \u003cimg src=\"https://latex.codecogs.com/svg.image?\\inline\u0026space;(\\theta\\rightarrow\u0026space;z\\rightarrow\u0026space;h_w(z)\\rightarrow\u0026space;\\hat{\\theta})\" title=\"https://latex.codecogs.com/svg.image?\\inline (\\theta\\rightarrow z\\rightarrow h_w(z)\\rightarrow \\hat{\\theta})\" /\u003e:\n\nNote that we only want the determinant of the gradient \u003cimg src=\"https://latex.codecogs.com/svg.image?\\inline\u0026space;\\partial\\hat{\\theta}/\\partial\\theta\" title=\"https://latex.codecogs.com/svg.image?\\inline \\partial\\hat{\\theta}/\\partial\\theta\" /\u003e. \nAs the mobius transform \u003cimg src=\"https://latex.codecogs.com/svg.image?\\inline\u0026space;h\" title=\"https://latex.codecogs.com/svg.image?\\inline h\" /\u003e maps a point in a circle into another point in the circle, \nwe can have: \n\n\u003ccenter\u003e\n\u003cimg src=\"https://latex.codecogs.com/svg.image?\\inline\u0026space;\\det|\\partial\\hat{\\theta}/\\partial\\theta|\u0026space;=\\|\\frac{\\partial\u0026space;h}{\\partial\\theta}\\|_2\" title=\"https://latex.codecogs.com/svg.image?\\inline \\det|\\partial\\hat{\\theta}/\\partial\\theta| =\\|\\frac{\\partial h}{\\partial\\theta}\\|_2\" /\u003e\n\u003c/center\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryushinn%2Fflows-on-sphere","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryushinn%2Fflows-on-sphere","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryushinn%2Fflows-on-sphere/lists"}