百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
G

Glow-PyTorch

> 编程语言
开源

PyTorch 中简单、可扩展且易于理解的 Glow 实现

388 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

PyTorch 中简单、可扩展且易于理解的 Glow 实现

Glow

This repository implements the Glow model using PyTorch on the CIFAR-10 and SVHN dataset. We use the trained Glow to reproduce some of the results of the paper "Do Deep Generative Models Know What They Don't Know?":

To create histogram: See notebook. Pretrained model (on CIFAR-10): download (unzip before use).

Note this pretrained model was created using the affine coupling layer, so it does not work well for generative sampling (see qualitative vs quantitative models in the Glow paper). The pretrained model achieves 3.39 bpd, while the original paper gets 3.35. The difference between our pretrained model and the paper is that we use batch size 64 (single GPU) and the paper uses 512 (8 GPU).

This code uses some layers and groundwork from glow-pytorch, but is more modular, extendable, faster, easier to read and supports training on CIFAR-10 and SVHN. There are fewer dependencies and a consistent interface for new datasets. Thanks to Milad for comments and help with debugging.

Setup and run

The code has minimal dependencies. You need python 3.6+ and up to date versions of:

pytorch (tested on 1.1.0)
torchvision
pytorch-ignite
tqdm

To install in a local conda:

conda install pytorch torchvision pytorch-ignite tqdm -c pytorch

To train your own model:

bash
python train.py --download

Will download the CIFAR10 dataset for you, and start training. The defaults are tested on a 1080Ti, Glow is a memory hungry model and it might be necessary to tune down the model size for your specific GPU. The output files will be send to output/.

Everything is configurable through command line arguments, see

bash
python train.py --help

for what is possible.

Evaluate

There are two notebooks available for evaluation:

  • The first notebook reproduces a plot from "Do Deep Generative models know what they don't know?" (see above) and computes the average bpd on the CIFAR-10 and SVHN test sets.
  • The second notebook allows you to visualise samples from the model (This works best with a model trained using the additive coupling layer).

Extensions

There are several possible extensions:

  • Multiclass conditional training
  • port over the tests

PRs for any of these would be very welcome. If you find any problem, feel free to make an issue too.

The model is trained using adamax instead of adam as in the original implementation. Using adam leads to a NLL of 3.48 (vs. 3.39 with adamax). Note: when using adam you need to set warmup to 1, otherwise optimisation gets stuck in a poor local minimum. It's unclear why adamax is so important and I'm curious to hear any ideas!

References:

…

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Python

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言