diff --git a/tensorflow/python/keras/layers/convolutional_recurrent.py b/tensorflow/python/keras/layers/convolutional_recurrent.py index fe2994c8335..b1e30ac3790 100644 --- a/tensorflow/python/keras/layers/convolutional_recurrent.py +++ b/tensorflow/python/keras/layers/convolutional_recurrent.py @@ -921,7 +921,8 @@ def __init__(self, recurrent_constraint=recurrent_constraint, bias_constraint=bias_constraint, dropout=dropout, - recurrent_dropout=recurrent_dropout) + recurrent_dropout=recurrent_dropout, + dtype=kwargs.get('dtype')) super(ConvLSTM2D, self).__init__(cell, return_sequences=return_sequences, go_backwards=go_backwards, diff --git a/tensorflow/python/keras/layers/gru_test.py b/tensorflow/python/keras/layers/gru_test.py index 6095dc19dfe..cf32b8022b7 100644 --- a/tensorflow/python/keras/layers/gru_test.py +++ b/tensorflow/python/keras/layers/gru_test.py @@ -43,6 +43,19 @@ def test_return_sequences_GRU(self): 'return_sequences': True}, input_shape=(num_samples, timesteps, embedding_dim)) + def test_float64_GRU(self): + num_samples = 2 + timesteps = 3 + embedding_dim = 4 + units = 2 + testing_utils.layer_test( + keras.layers.GRU, + kwargs={'units': units, + 'return_sequences': True, + 'dtype': 'float64'}, + input_shape=(num_samples, timesteps, embedding_dim), + input_dtype='float64') + def test_dynamic_behavior_GRU(self): num_samples = 2 timesteps = 3 diff --git a/tensorflow/python/keras/layers/gru_v2_test.py b/tensorflow/python/keras/layers/gru_v2_test.py index bbb6988839c..454c6fd0f40 100644 --- a/tensorflow/python/keras/layers/gru_v2_test.py +++ b/tensorflow/python/keras/layers/gru_v2_test.py @@ -342,6 +342,19 @@ def test_return_sequences_GRU(self): 'return_sequences': True}, input_shape=(num_samples, timesteps, embedding_dim)) + def test_float64_GRU(self): + num_samples = 2 + timesteps = 3 + embedding_dim = 4 + units = 2 + testing_utils.layer_test( + rnn.GRU, + kwargs={'units': units, + 'return_sequences': True, + 'dtype': 'float64'}, + input_shape=(num_samples, timesteps, embedding_dim), + input_dtype='float64') + def test_return_states_GRU(self): layer_class = rnn.GRU x = np.random.random((2, 3, 4)) diff --git a/tensorflow/python/keras/layers/lstm_test.py b/tensorflow/python/keras/layers/lstm_test.py index 95627e8e851..c3708d92688 100644 --- a/tensorflow/python/keras/layers/lstm_test.py +++ b/tensorflow/python/keras/layers/lstm_test.py @@ -44,6 +44,19 @@ def test_return_sequences_LSTM(self): 'return_sequences': True}, input_shape=(num_samples, timesteps, embedding_dim)) + def test_float64_LSTM(self): + num_samples = 2 + timesteps = 3 + embedding_dim = 4 + units = 2 + testing_utils.layer_test( + keras.layers.LSTM, + kwargs={'units': units, + 'return_sequences': True, + 'dtype': 'float64'}, + input_shape=(num_samples, timesteps, embedding_dim), + input_dtype='float64') + def test_static_shape_inference_LSTM(self): # Github issue: 15165 timesteps = 3 diff --git a/tensorflow/python/keras/layers/lstm_v2_test.py b/tensorflow/python/keras/layers/lstm_v2_test.py index e6fc0eb3243..6cea4c33783 100644 --- a/tensorflow/python/keras/layers/lstm_v2_test.py +++ b/tensorflow/python/keras/layers/lstm_v2_test.py @@ -565,6 +565,21 @@ def test_return_sequences_LSTM(self): }, input_shape=(num_samples, timesteps, embedding_dim)) + def test_float64_LSTM(self): + num_samples = 2 + timesteps = 3 + embedding_dim = 4 + units = 2 + testing_utils.layer_test( + rnn.LSTM, + kwargs={ + 'units': units, + 'return_sequences': True, + 'dtype': 'float64' + }, + input_shape=(num_samples, timesteps, embedding_dim), + input_dtype='float64') + def test_regularizers_LSTM(self): embedding_dim = 4 layer_class = rnn.LSTM diff --git a/tensorflow/python/keras/layers/recurrent.py b/tensorflow/python/keras/layers/recurrent.py index 5b88db6a346..f02925da4ce 100644 --- a/tensorflow/python/keras/layers/recurrent.py +++ b/tensorflow/python/keras/layers/recurrent.py @@ -1362,7 +1362,8 @@ def __init__(self, recurrent_constraint=recurrent_constraint, bias_constraint=bias_constraint, dropout=dropout, - recurrent_dropout=recurrent_dropout) + recurrent_dropout=recurrent_dropout, + dtype=kwargs.get('dtype')) super(SimpleRNN, self).__init__( cell, return_sequences=return_sequences, @@ -1890,7 +1891,8 @@ def __init__(self, dropout=dropout, recurrent_dropout=recurrent_dropout, implementation=implementation, - reset_after=reset_after) + reset_after=reset_after, + dtype=kwargs.get('dtype')) super(GRU, self).__init__( cell, return_sequences=return_sequences, @@ -2516,7 +2518,8 @@ def __init__(self, bias_constraint=bias_constraint, dropout=dropout, recurrent_dropout=recurrent_dropout, - implementation=implementation) + implementation=implementation, + dtype=kwargs.get('dtype')) super(LSTM, self).__init__( cell, return_sequences=return_sequences, diff --git a/tensorflow/python/keras/layers/simplernn_test.py b/tensorflow/python/keras/layers/simplernn_test.py index e595d7c980f..731e312c356 100644 --- a/tensorflow/python/keras/layers/simplernn_test.py +++ b/tensorflow/python/keras/layers/simplernn_test.py @@ -42,6 +42,19 @@ def test_return_sequences_SimpleRNN(self): 'return_sequences': True}, input_shape=(num_samples, timesteps, embedding_dim)) + def test_float64_SimpleRNN(self): + num_samples = 2 + timesteps = 3 + embedding_dim = 4 + units = 2 + testing_utils.layer_test( + keras.layers.SimpleRNN, + kwargs={'units': units, + 'return_sequences': True, + 'dtype': 'float64'}, + input_shape=(num_samples, timesteps, embedding_dim), + input_dtype='float64') + def test_dynamic_behavior_SimpleRNN(self): num_samples = 2 timesteps = 3