Update modeling_super_linear.py
Browse files591 unmodified lines592593594595596597598599600601591 unmodified linesreturn ydef upsample_interpolate(self,x, target_len: int = 512):scale_factor = 512/x.shape[1]upsample = interpolate(x, scale_factor=scale_factor, mode='linear').permute(0,2,1)[:, -500:, :]print(upsample.shape)591 unmodified lines592593594595596597598599600601602603604605606607608609610611612613614591 unmodified linesreturn ydef upsample_interpolate(self, x, target_len: int = 512):# Add channel dimension if input is 2Dif len(x.shape) == 2:x = x.unsqueeze(1) # [B, 1, L]scale_factor = 512/x.shape[-1]upsample = interpolate(x, scale_factor=scale_factor, mode='linear') # [B, C, new_L]# Take last 500 timesteps and rearrange to [B, L, C]upsample = upsample.permute(0, 2, 1)[:, -500:, :]# If input was 2D, remove the channel dimensionif x.shape[1] == 1:upsample = upsample.squeeze(-1)print(f"Upsampled shape: {upsample.shape}")return upsample
modeling_super_linear.py+17-4