Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
labmlai
GitHub Repository: labmlai/annotated_deep_learning_paper_implementations
Path: blob/master/labml_nn/diffusion/ddpm/utils.py
4921 views
1
"""
2
---
3
title: Utility functions for DDPM experiment
4
summary: >
5
Utility functions for DDPM experiment
6
---
7
8
# Utility functions for [DDPM](index.html) experiemnt
9
"""
10
import torch.utils.data
11
12
13
def gather(consts: torch.Tensor, t: torch.Tensor):
14
"""Gather consts for $t$ and reshape to feature map shape"""
15
c = consts.gather(-1, t)
16
return c.reshape(-1, 1, 1, 1)
17
18