diff --git a/tensorflow/python/keras/layers/recurrent.py b/tensorflow/python/keras/layers/recurrent.py index 3a07fbc1694..22d7cd4dcf9 100644 --- a/tensorflow/python/keras/layers/recurrent.py +++ b/tensorflow/python/keras/layers/recurrent.py @@ -388,10 +388,10 @@ class RNN(Layer): **kwargs): if isinstance(cell, (list, tuple)): cell = StackedRNNCells(cell) - if not hasattr(cell, 'call'): + if not 'call' in dir(cell): raise ValueError('`cell` should have a `call` method. ' 'The RNN was passed:', cell) - if not ('state_size' in dir(cell) or hasattr(cell, 'state_size')): + if not 'state_size' in dir(cell): raise ValueError('The RNN cell should have ' 'an attribute `state_size` ' '(tuple of integers, '