From 1b1e5ad07096bf2fc446ebd0e98c655d3d9630a5 Mon Sep 17 00:00:00 2001 From: SuryanarayanaY Date: Tue, 24 Oct 2023 12:43:06 +0530 Subject: [PATCH] Validate alpha argument in leaky relu --- keras/layers/activations/leaky_relu.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/keras/layers/activations/leaky_relu.py b/keras/layers/activations/leaky_relu.py index fae75abaa4a..4e2783fc08f 100644 --- a/keras/layers/activations/leaky_relu.py +++ b/keras/layers/activations/leaky_relu.py @@ -43,11 +43,11 @@ def __init__(self, negative_slope=0.3, **kwargs): "Use `negative_slope` instead." ) super().__init__(**kwargs) - if negative_slope is None: + if negative_slope is None or negative_slope < 0: raise ValueError( "The negative_slope value of a Leaky ReLU layer " - "cannot be None. Expected a float. Received: " - f"negative_slope={negative_slope}" + "cannot be None or negative value. Expected a float." + f" Received: negative_slope={negative_slope}" ) self.supports_masking = True self.negative_slope = negative_slope