MCPcopy Create free account
hub / github.com/VisionXLab/OF-Diff / append_dims

Function append_dims

ldm/models/diffusion/sampling_util.py:5–11  ·  view source on GitHub ↗

Appends dimensions to the end of a tensor until it has target_dims dimensions. From https://github.com/crowsonkb/k-diffusion/blob/master/k_diffusion/utils.py

(x, target_dims)

Source from the content-addressed store, hash-verified

3
4
5def append_dims(x, target_dims):
6 """Appends dimensions to the end of a tensor until it has target_dims dimensions.
7 From https://github.com/crowsonkb/k-diffusion/blob/master/k_diffusion/utils.py"""
8 dims_to_append = target_dims - x.ndim
9 if dims_to_append < 0:
10 raise ValueError(f'input has {x.ndim} dims but target_dims is {target_dims}, which is less')
11 return x[(...,) + (None,) * dims_to_append]
12
13
14def norm_thresholding(x0, value):

Callers 1

norm_thresholdingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected