MCPcopy Index your code
hub / github.com/MStypulkowski/diffused-heads / cut_n_stack

Function cut_n_stack

utils.py:175–188  ·  view source on GitHub ↗
(seq, snip_length, cut_dim=0, cutting_stride=None, pad_samples=0)

Source from the content-addressed store, hash-verified

173
174
175def cut_n_stack(seq, snip_length, cut_dim=0, cutting_stride=None, pad_samples=0):
176 if cutting_stride is None:
177 cutting_stride = snip_length
178
179 pad_left = pad_samples // 2
180 pad_right = pad_samples - pad_samples // 2
181
182 seq = pad_both_ends(seq, pad_left, pad_right, dim=cut_dim)
183
184 stacked = seq.narrow(cut_dim, 0, snip_length).unsqueeze(0)
185 iterations = (seq.size()[cut_dim] - snip_length) // cutting_stride + 1
186 for i in range(1, iterations):
187 stacked = torch.cat((stacked, seq.narrow(cut_dim, i * cutting_stride, snip_length).unsqueeze(0)))
188 return stacked
189
190
191def create_windowed_sequence(seqs, snip_length, cut_dim=0, cutting_stride=None, pad_samples=0):

Callers 1

create_windowed_sequenceFunction · 0.85

Calls 1

pad_both_endsFunction · 0.85

Tested by

no test coverage detected