Music classification using Tensorflow
Can we use our features to feed into TensorFlow? Of course! But let's try to use this opportunity to achieve two other goals:
- We will make the TensforFlow classifier behave like a
sklearn
one to be reused in all the compatible functions. - Even if neural networks can extract any feature, they still need to be designed and trained to extract them. In this example, starting from the original sound file, we will show you that it is not enough to get better results than the cepstral coefficients.
But let's cut to the chase and set our hyperparameters:
import tensorflow as tf import numpy as np n_epochs = 50 learning_rate = 0.01 batch_size = 128 step = 32 dropout_rate = 0.2 signal_size = 1000 signal_shape = [signal_size,1]
We start with our 600 samples, but to add more data to the training, we will split our file into chunks:
def read_wav(genre_list, multiplicity=1, base_dir=GENRE_DIR): X = [] y = [] for label, genre in enumerate(genre_list): ...