Training settings
Please provide a valid training processor option
Audio training options
Neural network architecture
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, InputLayer, Dropout, Conv1D, Conv2D, Flatten, Reshape, MaxPooling1D, MaxPooling2D, BatchNormalization
from tensorflow.keras.optimizers import Adam
sys.path.append('./resources/libraries')
import ei_tensorflow.training
# Manage unbalanced dataset
from sklearn.utils.class_weight import compute_class_weight
class_weights = dict(enumerate(compute_class_weight('balanced', np.unique(np.argmax(Y_train, axis=1)), np.argmax(Y_train, axis=1))))
# model architecture
model = Sequential()
model.add(Reshape((int(input_length / 32), 32), input_shape=(input_length, )))
model.add(Conv1D(8, kernel_size=3, activation='relu', padding='same'))
model.add(MaxPooling1D(pool_size=2, strides=2, padding='same'))
model.add(Dropout(0.25))
model.add(Conv1D(16, kernel_size=3, activation='relu', padding='same'))
model.add(MaxPooling1D(pool_size=2, strides=2, padding='same'))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(classes, activation='softmax', name='y_pred'))
# this controls the learning rate
opt = Adam(lr=0.005, beta_1=0.9, beta_2=0.999)
# this controls the batch size, or you can manipulate the tf.data.Dataset objects yourself
BATCH_SIZE = 32
train_dataset, validation_dataset = ei_tensorflow.training.set_batch_size(BATCH_SIZE, train_dataset, validation_dataset)
callbacks.append(BatchLoggerCallback(BATCH_SIZE, train_sample_count))
# train the neural network
model.compile(loss='categorical_crossentropy', optimizer=opt, metrics=['accuracy'])
#model.fit(train_dataset, epochs=20, validation_data=validation_dataset, verbose=2, callbacks=callbacks)
model.fit(X_train, Y_train, batch_size=50, epochs=20, verbose=2, validation_data=(X_test, Y_test), class_weight=class_weights)
Input layer (6,368 features)
Reshape layer (32 columns)
1D conv / pool layer (8 filters, 3 kernel size, 1 layer)
Dropout (rate 0.25)
1D conv / pool layer (16 filters, 3 kernel size, 1 layer)
Dropout (rate 0.25)
Flatten layer
Output layer (2 classes)
Model
Model version: