diff --git a/docs/source/keras_integrations.md b/docs/source/keras_integrations.md index 31707881..31d0b81c 100644 --- a/docs/source/keras_integrations.md +++ b/docs/source/keras_integrations.md @@ -72,8 +72,8 @@ class MetricsCallback(keras.callbacks.Callback): def on_epoch_end(self, epoch, logs=dict()): m = self.model - # Ensure we get labels of "1" or "0" - training_preds = np.round(m.predict(self.x_data)) + # Accuracy expects one integer label per example. + training_preds = np.round(m.predict(self.x_data)).reshape(-1).astype(np.int32) training_labels = self.y_data # Compute score and save @@ -102,8 +102,8 @@ We can also use the same metric after model training! Here, we show how to check ```python acc = evaluate.load("accuracy") -# Round the predictions to turn them into "0" or "1" labels -test_preds = np.round(model.predict(x_test)) +# Convert the sigmoid outputs from shape (num_examples, 1) into integer labels. +test_preds = np.round(model.predict(x_test)).reshape(-1).astype(np.int32) test_labels = y_test ```