Ejemplo n.º 1
0
# x_train = x_train.reshape(x_train.shape[0], input_shape)
# x_test = x_test.reshape(x_test.shape[0], input_shape)

# Converting the datatypes as accepted by keras
x_train = x_train.astype('float32')
y_train = y_train.astype('float32')

# One hot encoding of the labels
print("One Hot Encoding of the labels...\n\n")
y_train = to_categorical(y_train, num_classes)
y_test = to_categorical(y_test, num_classes)
print("Success!!!\n\n")

# Creating the model
print("Defining the model...\n\n")
model = obj.create_model(input_shape, num_classes)

# List of callback actions that are to be taken to stop the training after the model reaches an optimal point
callbacks_list = [
    tf.keras.callbacks.ModelCheckpoint(filepath='./models/max_features.h5',
                                       monitor='val_loss',
                                       save_best_only=True)
    # ),
    # tf.keras.callbacks.EarlyStopping(monitor = 'acc', patience = 1)
]

# Compiling and fitting the model
print("Now fitting the model and starting with the training...\n\n")
compile_fit(model, callbacks_list, x_train, y_train, x_test, y_test)
# ============================================================================================