Skip to content

Instantly share code, notes, and snippets.

@0xfe
Created February 23, 2020 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xfe/3e4d90436dce46ec121b9f94948001a1 to your computer and use it in GitHub Desktop.
Save 0xfe/3e4d90436dce46ec121b9f94948001a1 to your computer and use it in GitHub Desktop.
Plot prediction errors by key
files = os.listdir("samples")
np.random.shuffle(files)
notes = ['A', 'As', 'B', 'C', 'Cs', 'D', 'Ds', 'E', 'F', 'Fs', 'G', 'Gs']
note_map = {}
for i, note_name in enumerate(notes):
note_map[note_name] = i
count_by_key = np.zeros((8 * 12))
errors_by_key = np.zeros((8 * 12))
for i, file in enumerate(files[17000:18000]):
predicted = deepears.predict("samples/"+file).flatten()[0]
parts = DeepSamples.note_parts(file)
octave = int(parts['octave'])
note = parts['root']
freq = parts['freq']
error = abs(predicted - freq)
count_by_key[(octave * 12) + note_map[note]] += 1
errors_by_key[(octave * 12) + note_map[note]] += error
# print(file, base, predicted, actual, error)
errors_by_key /= count_by_key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment