MCPcopy Create free account
hub / github.com/MStypulkowski/diffused-heads / pad_both_ends

Function pad_both_ends

utils.py:164–172  ·  view source on GitHub ↗
(tensor, left, right, dim=0)

Source from the content-addressed store, hash-verified

162
163
164def pad_both_ends(tensor, left, right, dim=0):
165 no_dims = len(tensor.size())
166 if dim == -1:
167 dim = no_dims - 1
168
169 padding = [0] * 2 * no_dims
170 padding[2 * (no_dims - dim - 1)] = left
171 padding[2 * (no_dims - dim - 1) + 1] = right
172 return F.pad(tensor, padding, "constant", 0)
173
174
175def cut_n_stack(seq, snip_length, cut_dim=0, cutting_stride=None, pad_samples=0):

Callers 1

cut_n_stackFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected