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

Function pad_vector_like_x

diff2flow/dataset/depth_utils.py:107–119  ·  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). Args: x : Tensor, shape (bs, *dim) v : FloatTensor, shape (bs) Returns: vec : Tensor, shape (bs, number of x dimensions)

(v, x)

Source from the content-addressed store, hash-verified

105
106
107def pad_vector_like_x(v, x):
108 """
109 Function to reshape the vector by the number of dimensions
110 of x. E.g. x (bs, c, h, w), v (bs) -> v (bs, 1, 1, 1).
111 Args:
112 x : Tensor, shape (bs, *dim)
113 v : FloatTensor, shape (bs)
114 Returns:
115 vec : Tensor, shape (bs, number of x dimensions)
116 """
117 if isinstance(v, float):
118 return v
119 return v.reshape(-1, *([1] * (x.ndim - 1)))
120
121
122def per_sample_min_max_normalization(x):

Callers 1

colorize_depth_mapFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected