title: AttributError: 'NoneType' object has no attribute 'dtype'
body: <p>I am building a simple recurrent neural network, which contains a lstm layer with a fully connected layer, to make the classification for every row data. shape of my data 'x_train' is an nd.array with the shape of (210,240,1), 'y_train' is an nd.array with the shape of (210,). And the model output is normal. However, when I run model.fit(), there is always an error: AttributeError: 'NoneType' object has no attribute 'dtype'.</p>
  <p>I don' t know what's wrong with the following code.</p>
  <pre><code>#%%
  import os
  os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
  
  import tensorflow as tf
  import pandas as pd
  import numpy as np
  
  #%%
  model = tf.keras.models.Sequential([
    tf.keras.layers.LSTM(8),
    tf.keras.layers.Dense(units = 2)
  ])
  
  #%%
  loss_fn = tf.keras.losses.SparseCategoricalCrossentropy\
      (from_logits=True)
  model.compile(optimizer=tf.keras.optimizers.Adam(0.001),\
                loss = loss_fn)
  
  #%%
  x_train = np.random.randn(210,240,1)
  y_train = np.random.binomial(1, 0.5,(210,))
  
  #%%
  model.fit(x_train, y_train, epochs=20)
  </code></pre>
  <p>The following are the whole error information:</p>
  <pre><code>Traceback (most recent call last):
  
    File &quot;D:\运筹优化\机器学习课程项目\时序数据预测\rnn_exploration.py&quot;, line 68, in &lt;module&gt;
      model.fit(x_train, y_train, epochs=20)
  
    File &quot;D:\python\anaconda\anaconda\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training.py&quot;, line 819, in fit
      use_multiprocessing=use_multiprocessing)
  
    File &quot;D:\python\anaconda\anaconda\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py&quot;, line 235, in fit
      use_multiprocessing=use_multiprocessing)
  
    File &quot;D:\python\anaconda\anaconda\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py&quot;, line 593, in _process_training_inputs
      use_multiprocessing=use_multiprocessing)
  
    File &quot;D:\python\anaconda\anaconda\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py&quot;, line 646, in _process_inputs
      x, y, sample_weight=sample_weights)
  
    File &quot;D:\python\anaconda\anaconda\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training.py&quot;, line 2360, in _standardize_user_data
      self._compile_from_inputs(all_inputs, y_input, x, y)
  
    File &quot;D:\python\anaconda\anaconda\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training.py&quot;, line 2618, in _compile_from_inputs
      experimental_run_tf_function=self._experimental_run_tf_function)
  
    File &quot;D:\python\anaconda\anaconda\envs\tensorflow\lib\site-packages\tensorflow_core\python\training\tracking\base.py&quot;, line 457, in _method_wrapper
      result = method(self, *args, **kwargs)
  
    File &quot;D:\python\anaconda\anaconda\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training.py&quot;, line 416, in compile
      endpoint.create_training_target(t, run_eagerly=self.run_eagerly)
  
    File &quot;D:\python\anaconda\anaconda\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training.py&quot;, line 3023, in create_training_target
      self.loss_fn, K.dtype(self.output))
  
    File &quot;D:\python\anaconda\anaconda\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\backend.py&quot;, line 1237, in dtype
      return x.dtype.base_dtype.name
  
  AttributeError: 'NoneType' object has no attribute 'dtype'
  </code></pre>
  <p>Any help would be appreciated!</p>