@@ -775,6 +775,31 @@ def func(x):
775
775
return tf .identity (y [0 ], name = "output" ), tf .identity (y [1 ], name = "output1" )
776
776
self .run_test_case (func , {"input:0" : x_val }, [], ["output:0" , "output1:0" ], rtol = 1e-05 , atol = 1e-06 )
777
777
778
+ @check_tf_min_version ("2.0" )
779
+ @skip_tf_versions ("2.1" , "Bug in TF 2.1" )
780
+ def test_keras_bilstm_recurrent_activation_is_hard_sigmoid (self ):
781
+ in_shape = [10 , 3 ]
782
+ x_val = np .random .uniform (size = [2 , 10 , 3 ]).astype (np .float32 )
783
+
784
+ model_in = tf .keras .layers .Input (tuple (in_shape ), batch_size = 2 )
785
+ x = tf .keras .layers .Bidirectional (
786
+ tf .keras .layers .LSTM (
787
+ units = 5 ,
788
+ return_sequences = True ,
789
+ return_state = True ,
790
+ kernel_initializer = tf .random_uniform_initializer (0.0 , 1.0 , seed = 42 ),
791
+ recurrent_initializer = tf .random_uniform_initializer (0.0 , 1.0 , seed = 44 ),
792
+ bias_initializer = tf .random_uniform_initializer (0.0 , 1.0 , seed = 43 ),
793
+ recurrent_activation = "hard_sigmoid" ,
794
+ )
795
+ )(model_in )
796
+ model = tf .keras .models .Model (inputs = model_in , outputs = x )
797
+
798
+ def func (x ):
799
+ y = model (x )
800
+ return tf .identity (y [0 ], name = "output" ), tf .identity (y [1 ], name = "output1" )
801
+ self .run_test_case (func , {"input:0" : x_val }, [], ["output:0" , "output1:0" ], rtol = 1e-05 , atol = 1e-06 )
802
+
778
803
@check_tf_min_version ("2.0" )
779
804
@skip_tfjs ("TFJS converts model incorrectly" )
780
805
def test_keras_lstm_sigmoid_dropout (self ):
0 commit comments