diff --git a/tensorflow/python/keras/layers/recurrent.py b/tensorflow/python/keras/layers/recurrent.py index 6c7610b6795..3a07fbc1694 100644 --- a/tensorflow/python/keras/layers/recurrent.py +++ b/tensorflow/python/keras/layers/recurrent.py @@ -79,10 +79,10 @@ class StackedRNNCells(Layer): def __init__(self, cells, **kwargs): for cell in cells: - if not hasattr(cell, 'call'): + if not 'call' in dir(cell): raise ValueError('All cells must have a `call` method. ' 'received cells:', cells) - if not ('state_size' in dir(cell) or hasattr(cell, 'state_size')): + if not 'state_size' in dir(cell): raise ValueError('All cells must have a ' '`state_size` attribute. ' 'received cells:', cells)