Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
model = models.Sequential([
layers.Dense(128, activation = 'relu', input_shape = Xtrain[0].shape),
layers.Dense(64, activation = 'relu'),
layers.Dense(32, activation = 'relu'),
layers.Dense(len(languages), activation = 'softmax')
])
cb = [callbacks.EarlyStopping(patience = 5, restore_best_weights = True)]
model.compile(optimizer = optimizers.Adam(0.001), loss = losses.CategoricalCrossentropy(), metrics = ['accuracy'])
history = model.fit(Xtrain, ytrain, validation_data = (Xval, yval), epochs = 64, callbacks = cb)
model.compile(optimizer = optimizers.Adam(0.0001), loss = losses.CategoricalCrossentropy(), metrics = ['accuracy'])
history1 = model.fit(Xtrain, ytrain, validation_data = (Xval, yval), epochs = 64, callbacks = cb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment