From 69448cfda5b5a09c419f431ef08d67894dc4a18d Mon Sep 17 00:00:00 2001 From: Uri Granta Date: Tue, 10 Sep 2024 10:11:33 +0100 Subject: [PATCH] Better exception message --- trieste/space.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trieste/space.py b/trieste/space.py index 41a73f514..4b32181cc 100644 --- a/trieste/space.py +++ b/trieste/space.py @@ -656,8 +656,8 @@ def one_hot_encoder(self) -> EncoderFunction: def binary_encoder(x: TensorType) -> TensorType: # no need to one-hot encode binary categories (but we should still validate) - if not tf.reduce_all((x == 0) | (x == 1)): - raise ValueError(f"Invalid value {x}") + if tf.reduce_any((x != 0) & (x != 1)): + raise ValueError(f"Invalid values {tf.boolean_mask(x, ((x != 0) & (x != 1)))}") return x def encoder(x: TensorType) -> TensorType: