Skip to content

Instantly share code, notes, and snippets.

@IlievskiV
Created December 21, 2021 23:41
Show Gist options
  • Save IlievskiV/bc3e236fc9c721d7c41d35fdc53cc916 to your computer and use it in GitHub Desktop.
Save IlievskiV/bc3e236fc9c721d7c41d35fdc53cc916 to your computer and use it in GitHub Desktop.
import itertools
epochs = 3 # number of training epochs
test_batch_size = 32 # batch size for testing
arrays = [
embedding_size,
dropout,
filters,
kernel_size,
pool_size,
lstm_output_size,
batch_size,
] # all hyper-params
for ed, d, flt, ks, ps, ls, bs in itertools.product(*arrays):
model = make_model(
embedding_dim=ed,
dropout=d,
filters=flt,
kernel_size=ks,
pool_size=ps,
lstm_output_size=ls,
metrics=METRICS,
vocab_size=max_features,
maxlen=maxlen,
)
h = model.fit(x_train, y_train, batch_size=bs, epochs=epochs, verbose=2)
train_loss = h.history["loss"][-1]
test_metrics = model.evaluate(x=x_test, y=y_test, batch_size=test_batch_size)
test_loss, test_acc, test_prec, test_rec = test_metrics
# write everything to external JSON file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment