From 11f806df3f2cc35d84d4a0022ca011304699e136 Mon Sep 17 00:00:00 2001 From: Neil Lawrence Date: Wed, 19 May 2021 09:50:51 +0100 Subject: [PATCH] Fix normalizer to catch when output scale is zero. --- GPy/util/normalizer.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/GPy/util/normalizer.py b/GPy/util/normalizer.py index 2e6d991a..4fe9815c 100644 --- a/GPy/util/normalizer.py +++ b/GPy/util/normalizer.py @@ -90,6 +90,9 @@ class Standardize(_Norm): Y = np.ma.masked_invalid(Y, copy=False) self.mean = Y.mean(0).view(np.ndarray) self.std = Y.std(0).view(np.ndarray) + if np.any(self.std) == 0: + self.std[np.where(Y_std==0)]=1. + warnings.warn("Some values of Y have standard deviation of zero. Resetting to 1.0 to avoid divide by zero errors.") def normalize(self, Y): super(Standardize, self).normalize(Y)