<jupyter_start><jupyter_text>Mel-Spec function used in the training is power=1<jupyter_code>%matplotlib inline
import matplotlib.pyplot as plt
fig, axs = plt.subplots(2,1)
Y2_log = _log_amp(Y2)
axs[0].imshow(Y[0].T*1.5, aspect='auto', origin='low')
axs[1].imshow(Y2_log[0].T, aspect='auto', origin='low')
plt.imshow(np.abs(Y[0].T - Y3[0].T)[:, 2:-2], aspect='auto', origin='low')
np.isclose(np.exp(Y[0, 2:-2].T*1.99),np.exp(Y2_log[0, 2:-2].T)).sum() / float(np.prod(Y[0].size))
np.isclose(10**Y[0,2:-2].T,10**Y3[0][2:-2].T).sum() / float(np.prod(Y[0].size))
fig, axs = plt.subplots(1,2)
axs[0].imshow(Y[0,2:-2].T, aspect='auto')
axs[1].imshow(Y3[0][2:-2].T, aspect='auto')
import librosa
y, sr = librosa.load('/home/ubuntu/downloads/NAUL.mp3', sr=22050, mono=False)
st = int(20 * sr)
Y3 = [
    _log_amp(librosa.feature.melspectrogram(ch, sr=sr, n_fft=1024, hop_length=256, power=1)).T
    for ch in y[:, st:st+int(sr*2.5)]
]
plt.imshow(Y3[0])<jupyter_output><empty_output><jupyter_text>Empirical test using librosa.feature.melspectrogram (pow=1)<jupyter_code>from model.model import Model
import namedtupled
from sklearn.externals import joblib

state = joblib.load('/mnt/bulk2/exp_res/models/9/conv_2d_bpm_self_artist_tag_50_intersc_b2_run9_state.dat.gz')
state_nt = namedtupled.map(state)
model = Model(state_nt.config)
model.config.target
f_gpumel = model.feature('bpm', Y[None, :, :, :])
f_librosamel = model.feature('bpm', np.array(Y3)[None, :, :, :])
plt.plot(f_gpumel[0])
plt.plot(f_librosamel[0])
print('close numbers:', np.isclose(f_gpumel, f_librosamel).sum())<jupyter_output>('close numbers:', 154)<jupyter_text>Is feature varying a lot across music?<jupyter_code>from sklearn.preprocessing import StandardScaler
sclr = StandardScaler()

music_length = len(y) / sr  # in sec
win_sz = int(2.5 * sr)
hop_sz = win_sz / 2
target = 'artist_tag'

X = []
Z = []
for n in range(0, y.shape[-1], hop_sz):
    input_ = np.array([
        _log_amp(librosa.feature.melspectrogram(ch, sr=sr, n_fft=1024, hop_length=256, power=1)).T
        for ch in y[:, n:n+win_sz]
    ])[None, :, :, :]
    
    if input_.shape[2] < 216:
        continue
        
    X.append(model.feature(target, input_).ravel())
#     Z.append(model.predict(target, input_).ravel())
plt.figure(figsize=(10, 5))
plt.title('bpm')
plt.imshow(sclr.fit_transform(np.array(X)).T[:,10:-15], aspect='auto')
plt.figure(figsize=(10, 5))
plt.title('self')
plt.imshow(np.array(X).T[:,10:-15], aspect='auto')
plt.figure(figsize=(10, 5))
plt.title('artist_tag')
plt.imshow(np.array(X).T[:,10:-15], aspect='auto')
from sklearn.decomposition import NMF, PCA
# mdl = NMF(n_components=21)
mdl = PCA(n_components=21, whiten=True)
U = mdl.fit_transform(sclr.fit_transform(X))
V = mdl.components_
plt.figure(figsize=(10, 5))
plt.imshow(U.T, aspect='auto')
plt.figure(figsize=(10, 5))
plt.imshow(V.T, aspect='auto')

plt.plot(U[:,1])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20432692307692307, 'fraction_numerical': 0.04635989010989011, 'mean_word_length': 5.758700696055684, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '36701', 'license': 'MIT', 'n_tokens_mistral': 1351, 'n_tokens_neox': 1272, 'n_words': 189, 'path': 'notebooks/MelSpecCheck.ipynb', 'repo_name': 'eldrin/MTLMusicRepresentation', 'size': '2912'}