def denormalize(self, v): mean = reshape_for_broadcasting(self.mean, v) std = reshape_for_broadcasting(self.std, v) return mean + v * std
def normalize(self, v, clip_range=None): if clip_range is None: clip_range = self.default_clip_range mean = reshape_for_broadcasting(self.mean, v) std = reshape_for_broadcasting(self.std, v) return tf.clip_by_value((v - mean) / std, -clip_range, clip_range)