title: NotImplementedError: Cannot convert a symbolic Tensor (lstm_4/strided_slice:0) to a numpy array
body: <p>Numpy version 1.19.2, tensorflow version 2.3.0.</p>
  <p>I'm trying to create an LSTM network:</p>
  <pre><code>model=Sequential()
  model.add(Embedding(input_dim=vocab_size,output_dim=embed_dim,input_length=max_rev_len,embeddings_initializer=Constant(embed_matrix)))
  
  model.add(LSTM(100))
  model.add(Flatten())
  
  model.add(Dense(16,activation='relu'))
  model.add(Dropout(0.70))
  model.add(Dense(1,activation='sigmoid')) 
  </code></pre>
  <p>When I run the cell (I'm using jupyter notebook on Windows 11), I get the error:</p>
  <pre><code>NotImplementedError                       Traceback (most recent call last)
  &lt;ipython-input-57-d024ff74859f&gt; in &lt;module&gt;
        5 model.add(Embedding(input_dim=vocab_size,output_dim=embed_dim,input_length=max_rev_len,embeddings_initializer=Constant(embed_matrix)))
        6 
  ----&gt; 7 model.add(LSTM(100))
        8 model.add(Flatten())
        9 
  
  C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\training\tracking\base.py in _method_wrapper(self, *args, **kwargs)
      455     self._self_setattr_tracking = False  # pylint: disable=protected-access
      456     try:
  --&gt; 457       result = method(self, *args, **kwargs)
      458     finally:
      459       self._self_setattr_tracking = previous_value  # pylint: disable=protected-access
  
  C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\sequential.py in add(self, layer)
      219       # If the model is being built continuously on top of an input layer:
      220       # refresh its output.
  --&gt; 221       output_tensor = layer(self.outputs[0])
      222       if len(nest.flatten(output_tensor)) != 1:
      223         raise ValueError(SINGLE_LAYER_OUTPUT_ERROR_MSG)
  
  C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\layers\recurrent.py in __call__(self, inputs, initial_state, constants, **kwargs)
      661 
      662     if initial_state is None and constants is None:
  --&gt; 663       return super(RNN, self).__call__(inputs, **kwargs)
      664 
      665     # If any of `initial_state` or `constants` are specified and are Keras
  
  C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\base_layer.py in __call__(self, *args, **kwargs)
      923     # &gt;&gt; model = tf.keras.Model(inputs, outputs)
      924     if _in_functional_construction_mode(self, inputs, args, kwargs, input_list):
  --&gt; 925       return self._functional_construction_call(inputs, args, kwargs,
      926                                                 input_list)
      927 
  
  C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\base_layer.py in _functional_construction_call(self, inputs, args, kwargs, input_list)
     1115           try:
     1116             with ops.enable_auto_cast_variables(self._compute_dtype_object):
  -&gt; 1117               outputs = call_fn(cast_inputs, *args, **kwargs)
     1118 
     1119           except errors.OperatorNotAllowedInGraphError as e:
  
  C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\layers\recurrent_v2.py in call(self, inputs, mask, training, initial_state)
     1106 
     1107     # LSTM does not support constants. Ignore it during process.
  -&gt; 1108     inputs, initial_state, _ = self._process_inputs(inputs, initial_state, None)
     1109 
     1110     if isinstance(mask, list):
  
  C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\layers\recurrent.py in _process_inputs(self, inputs, initial_state, constants)
      860         initial_state = self.states
      861     elif initial_state is None:
  --&gt; 862       initial_state = self.get_initial_state(inputs)
      863 
      864     if len(initial_state) != len(self.states):
  
  C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\layers\recurrent.py in get_initial_state(self, inputs)
      643     dtype = inputs.dtype
      644     if get_initial_state_fn:
  --&gt; 645       init_state = get_initial_state_fn(
      646           inputs=None, batch_size=batch_size, dtype=dtype)
      647     else:
  
  C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\layers\recurrent.py in get_initial_state(self, inputs, batch_size, dtype)
     2521 
     2522   def get_initial_state(self, inputs=None, batch_size=None, dtype=None):
  -&gt; 2523     return list(_generate_zero_filled_state_for_cell(
     2524         self, inputs, batch_size, dtype))
     2525 
  
  C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\layers\recurrent.py in _generate_zero_filled_state_for_cell(cell, inputs, batch_size, dtype)
     2966     batch_size = array_ops.shape(inputs)[0]
     2967     dtype = inputs.dtype
  -&gt; 2968   return _generate_zero_filled_state(batch_size, cell.state_size, dtype)
     2969 
     2970 
  
  C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\layers\recurrent.py in _generate_zero_filled_state(batch_size_tensor, state_size, dtype)
     2982 
     2983   if nest.is_sequence(state_size):
  -&gt; 2984     return nest.map_structure(create_zeros, state_size)
     2985   else:
     2986     return create_zeros(state_size)
  
  C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\util\nest.py in map_structure(func, *structure, **kwargs)
      633 
      634   return pack_sequence_as(
  --&gt; 635       structure[0], [func(*x) for x in entries],
      636       expand_composites=expand_composites)
      637 
  
  C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\util\nest.py in &lt;listcomp&gt;(.0)
      633 
      634   return pack_sequence_as(
  --&gt; 635       structure[0], [func(*x) for x in entries],
      636       expand_composites=expand_composites)
      637 
  
  C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\layers\recurrent.py in create_zeros(unnested_state_size)
     2979     flat_dims = tensor_shape.as_shape(unnested_state_size).as_list()
     2980     init_state_size = [batch_size_tensor] + flat_dims
  -&gt; 2981     return array_ops.zeros(init_state_size, dtype=dtype)
     2982 
     2983   if nest.is_sequence(state_size):
  
  C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\util\dispatch.py in wrapper(*args, **kwargs)
      199     &quot;&quot;&quot;Call target, and fall back on dispatchers if there is a TypeError.&quot;&quot;&quot;
      200     try:
  --&gt; 201       return target(*args, **kwargs)
      202     except (TypeError, ValueError):
      203       # Note: convert_to_eager_tensor currently raises a ValueError, not a
  
  C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py in wrapped(*args, **kwargs)
     2745 
     2746   def wrapped(*args, **kwargs):
  -&gt; 2747     tensor = fun(*args, **kwargs)
     2748     tensor._is_zeros_tensor = True
     2749     return tensor
  
  C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py in zeros(shape, dtype, name)
     2792           # Create a constant if it won't be very big. Otherwise create a fill
     2793           # op to prevent serialized GraphDefs from becoming too large.
  -&gt; 2794           output = _constant_if_small(zero, shape, dtype, name)
     2795           if output is not None:
     2796             return output
  
  C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py in _constant_if_small(value, shape, dtype, name)
     2730 def _constant_if_small(value, shape, dtype, name):
     2731   try:
  -&gt; 2732     if np.prod(shape) &lt; 1000:
     2733       return constant(value, shape=shape, dtype=dtype, name=name)
     2734   except TypeError:
  
  &lt;__array_function__ internals&gt; in prod(*args, **kwargs)
  
  C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py in prod(a, axis, dtype, out, keepdims, initial, where)
     3049     ...               # total product 1*2*3 = 6
     3050     array([1, 2, 6])
  -&gt; 3051     &gt;&gt;&gt; a = np.array([[1, 2, 3], [4, 5, 6]])
     3052     &gt;&gt;&gt; np.cumprod(a, dtype=float) # specify type of output
     3053     array([   1.,    2.,    6.,   24.,  120.,  720.])
  
  C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py in _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs)
       84             else:
       85                 return reduction(axis=axis, out=out, **passkwargs)
  ---&gt; 86 
       87     return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
       88 
  
  C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py in __array__(self)
      843 
      844   def __array__(self):
  --&gt; 845     raise NotImplementedError(
      846         &quot;Cannot convert a symbolic Tensor ({}) to a numpy array.&quot;
      847         &quot; This error may indicate that you're trying to pass a Tensor to&quot;
  
  NotImplementedError: Cannot convert a symbolic Tensor (lstm_4/strided_slice:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported
  </code></pre>
  <p>I tried the solution mentioned <a href="https://stackoverflow.com/questions/66207609/notimplementederror-cannot-convert-a-symbolic-tensor-lstm-2-strided-slice0-t">here</a> but even downgrading numpy didn't help. I'm not sure if this is a tensorflow bug or I am doing something wrong. Please advise!</p>