<jupyter_start><jupyter_text>Preparation<jupyter_code>stft_func   = get_stft_func()
amp2db_func = get_amp2db_func()<jupyter_output>STFT kernels created, time used = 0.1602 seconds<jupyter_text>VMask  Data Prepareing<jupyter_code>num_band     = 3 
num_param    = 2 # each eq has two parameters (Cutoff_freq, Q_factor)
batch_size   = 4 

waves        = torch.stack([generate_noise(10).unsqueeze(0) for batch in range(batch_size)]) # (batch_size, channels, samples)
mags, phases = stft_func(waves) # (batch_size, channels, bins, frames)

print('mags: ', mags.size())<jupyter_output>mags:  torch.Size([4, 1, 1025, 862])<jupyter_text>VMask Usage<jupyter_code>vmask   = VMask('mean', 'low', 'linear', 'equal')
params  = torch.rand(batch_size, num_band - 1, num_param)
vmags, vmasks, vcurves, vfcurves = vmask(mags, params)

print('mag : ', vmags.size())
print('mask: ', vmasks.size())
print('curve: ', vcurves.size())<jupyter_output>mag :  torch.Size([4, 3, 1, 1025, 862])
mask:  torch.Size([4, 3, 1, 1025, 862])
curve:  torch.Size([4, 3, 1, 1025])<jupyter_text>VMask Visualize<jupyter_code>for batch_idx in range(batch_size):
    fig, axes = plt.subplots(num_band, 3, figsize=(12, 6))
    for (mag, mask, curve, ax) in zip(vmags[batch_idx], vmasks[batch_idx], vcurves[batch_idx], axes):
        ax[0].plot(curve[0])
        mask_visualize(mask[0], ax[1])
        mask_visualize(amp2db_func(mag[0]), ax[2])
    plt.suptitle(f'batch: {batch_idx + 1}')
    plt.tight_layout()
    plt.show()<jupyter_output><empty_output><jupyter_text>Check Differentiability<jupyter_code>params  = torch.rand(batch_size, num_band - 1, num_param, requires_grad=True)
vmags, vmasks, vcurves, vfcurves = vmask(mags, params)
vmags.backward(torch.ones_like(vmags))
print(f'grad: {params.grad is not None}')<jupyter_output>grad: True<jupyter_text>HMask  Data Prepareing<jupyter_code>num_band     = 2
num_fader    = 1
num_param    = 2 # each fader curve need two parameters (start, slope)
batch_size   = 4 
waves        = torch.stack([generate_noise(10).unsqueeze(0) for batch in range(batch_size)])
mags, phases = stft_func(waves)
mags         = torch.stack([mags for i in range(num_band)], axis=1) # (batch_size, bands, channels, bins, frames)

print('mags: ', mags.size())<jupyter_output>mags:  torch.Size([4, 2, 1, 1025, 862])<jupyter_text>HMask Usage<jupyter_code>hmask   = HMask('sum', 'fi', 'linear')
params  = torch.rand(batch_size, num_band, num_fader, num_param)
hmags, hmasks, hcurves = hmask(mags, params)


print('mag : ', hmags.size())
print('mask: ', hmasks.size())
print('curve: ', hcurves.size())<jupyter_output>mag :  torch.Size([4, 2, 1, 1025, 862])
mask:  torch.Size([4, 2, 1, 1025, 862])
curve:  torch.Size([4, 2, 1, 862])<jupyter_text>HMask Visualize<jupyter_code>for batch_idx in range(batch_size):
    fig, axes = plt.subplots(num_band, 3, figsize=(12, 6))
    for (mag, mask, curve, ax) in zip(hmags[batch_idx], hmasks[batch_idx], hcurves[batch_idx], axes):
        ax[0].plot(curve[0])
        mask_visualize(mask[0], ax[1])
        mask_visualize(amp2db_func(mag[0]), ax[2])
    plt.suptitle(f'batch: {batch_idx+1}')
    plt.tight_layout()
    plt.show()<jupyter_output><empty_output><jupyter_text>Check Differentiability<jupyter_code>params  = torch.rand(batch_size, num_band, num_fader, num_param, requires_grad=True)
hmags, hmasks, hcurves = hmask(mags, params)
hmags.backward(torch.ones_like(hmags))

print(f'grad: {params.grad is not None}')<jupyter_output>grad: True
{'fraction_non_alphanumeric': 0.1574848572252668, 'fraction_numerical': 0.03432362272858379, 'mean_word_length': 5.760233918128655, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '583862', 'license': 'MIT', 'n_tokens_mistral': 1503, 'n_tokens_neox': 1403, 'n_words': 261, 'path': 'examples/mixer/mask.ipynb', 'repo_name': 'ChenPaulYu/DJTransGAN', 'size': '3467'}