Neural Network
Let’s evaluate the dataset with the simple Neural network.
Python3
import tensorflow.keras as keras from tensorflow.keras import Sequential from tensorflow.keras.layers import * model = Sequential() model.add(Flatten(input_shape = ( 58 ,))) model.add(Dense( 256 , activation = 'relu' )) model.add(BatchNormalization()) model.add(Dense( 128 , activation = 'relu' )) model.add(Dropout( 0.3 )) model.add(Dense( 10 , activation = 'softmax' )) model.summary() |
Output :
Compiling and fitting the model
Python3
# compile the model adam = keras.optimizers.Adam(lr = 1e - 4 ) model. compile (optimizer = adam, loss = "sparse_categorical_crossentropy" , metrics = [ "accuracy" ]) hist = model.fit(X_train, y_train, validation_data = (X_test,y_test), epochs = 100 , batch_size = 32 ) |
100 epochs will take some time.
Once done, then we can do evaluation.
Music Genre Classifier using Machine Learning
Music is the art of arranging sound and noise together to create harmony, melody, rhythm, and expressive content. It is organized so that humans and sometimes other living organisms can express their current emotions with it.
We all have our own playlist, which we listen to while traveling, studying, dancing, etc.
In short, every emotion has a different genre. So here today, we will study how can we implement the task of genre classification using Machine Learning in Python.
Before starting the code, download the data from this link.
Let’s start with the code.