MCPcopy Create free account
hub / github.com/CompVis/diff2flow / pad_vector_like_x

Function pad_vector_like_x

diff2flow/helpers.py:148–155  ·  view source on GitHub ↗

Function to reshape the vector by the number of dimensions of x. E.g. x (bs, c, h, w), v (bs) -> v (bs, 1, 1, 1).

(v, x)

Source from the content-addressed store, hash-verified

146
147
148def pad_vector_like_x(v, x):
149 """
150 Function to reshape the vector by the number of dimensions
151 of x. E.g. x (bs, c, h, w), v (bs) -> v (bs, 1, 1, 1).
152 """
153 if isinstance(v, float):
154 return v
155 return v.reshape(-1, *([1] * (x.dim() - 1)))
156
157
158def resize_ims(x: Tensor, size: int, mode: str = "bilinear", **kwargs):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected