Skip to content

Instantly share code, notes, and snippets.

@detrin
Created August 7, 2021 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save detrin/a364f85741e22a42dc9b343aee5bd47f to your computer and use it in GitHub Desktop.
Save detrin/a364f85741e22a42dc9b343aee5bd47f to your computer and use it in GitHub Desktop.
Serve ML model with Flask REST API - 2
normalizer = preprocessing.Normalization(axis=-1)
normalizer.adapt(np.array(train_features))
model = keras.Sequential(
[
normalizer,
layers.Dense(64, activation="relu"),
layers.Dense(64, activation="relu"),
layers.Dense(1),
]
)
model.compile(loss="mean_absolute_error", optimizer=tf.keras.optimizers.Adam(0.001))
train_features, test_features, train_labels, test_labels = get_data()
model = get_model(train_features)
model.summary()
history = model.fit(
train_features, train_labels, validation_split=0.2, verbose=2, epochs=100
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment