title: Tensorflow 2.0 InvalidArgumentError: assertion failed: [Condition x == y did not hold element-wise:]
body: <p>i am  training a mnist CNN. When i  ran my code the   problem is coming . I tried other answers but they do not work. I am a new to TensorFlow so  can someone explain me this error. Here is my code. i am using Pycharm 2020.2. and Python 3.6 in anaconda. There is no help i could find.</p>
  <pre><code>import tensorflow as tf
  from tensorflow.keras.models import Sequential
  
  mnist = tf.keras.datasets.mnist
  
  (x_train, y_train), (x_test, y_test) = mnist.load_data()
  x_train = tf.keras.utils.normalize(x_train, axis=1)
  x_test = tf.keras.utils.normalize(x_train, axis=1)
  
  
  
  model = Sequential()
  
  model.add(tf.keras.layers.Dense(256))
  model.add(tf.keras.layers.Conv1D(kernel_size=4, strides=1, filters=4, activation=&quot;relu&quot;))
  model.add(tf.keras.layers.Conv1D(kernel_size=3, strides=1, activation=&quot;relu&quot;, filters=3))
  model.add(tf.keras.layers.Dense(128, activation=&quot;relu&quot;))
  model.add(tf.keras.layers.Conv1D(kernel_size=2, filters=2, strides=1, activation=&quot;relu&quot;))
  model.add(tf.keras.layers.Conv1D(kernel_size=1, filters=1, strides=1, activation=&quot;relu&quot;))
  model.add(tf.keras.layers.Dense(64, activation=&quot;relu&quot;))
  model.add(tf.keras.layers.MaxPool1D(pool_size=2, strides=1))
  model.add(tf.keras.layers.Dense(256, activation=&quot;relu&quot;))
  model.add(tf.keras.layers.Conv1D(kernel_size=4, filters=4, strides=1, activation=&quot;relu&quot;))
  model.add(tf.keras.layers.Conv1D(kernel_size=3, filters=3, strides=1, activation=&quot;relu&quot;))
  model.add(tf.keras.layers.MaxPool1D(pool_size=2, strides=1))
  model.add(tf.keras.layers.Dropout(0.2))
  model.add(tf.keras.layers.Dense(128, activation=&quot;relu&quot;))
  model.add(tf.keras.layers.Conv1D(kernel_size=2, filters=2, strides=1, activation=&quot;relu&quot;))
  model.add(tf.keras.layers.Conv1D(kernel_size=1, filters=1, strides=1, activation=&quot;relu&quot;))
  model.add(tf.keras.layers.Dense(64, activation=&quot;relu&quot;))
  model.add(tf.keras.layers.Dense(16, activation=&quot;softmax&quot;))
  model.compile(optimizer='adam',
                loss='sparse_categorical_crossentropy',
                metrics=['accuracy'])
  
  
      
  model.compile(optimizer='adam',
                loss='sparse_categorical_crossentropy',
                metrics=['accuracy'])
  model.fit(x=x_train, y=y_train, batch_size=64, epochs=5, shuffle=True, validation_split=0.1)
  model.summary()
  </code></pre>
  <p>it is giving the error:</p>
  <pre><code>Train on 54000 samples, validate on 6000 samples
  Epoch 1/5
  2020-09-09 15:16:16.953428: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
  2020-09-09 15:16:17.146701: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
  2020-09-09 15:16:17.741916: W tensorflow/stream_executor/gpu/redzone_allocator.cc:312] Internal: Invoking GPU asm compilation is supported on Cuda non-Windows platforms only
  Relying on driver to perform ptx compilation. This message will be only logged once.
  2020-09-09 15:16:18.085250: W tensorflow/core/common_runtime/base_collective_executor.cc:217] BaseCollectiveExecutor::StartAbort Invalid argument: assertion failed: [Condition x == y did not hold element-wise:] [x (loss/output_1_loss/SparseSoftmaxCrossEntropyWithLogits/Shape_1:0) = ] [64 1] [y (loss/output_1_loss/SparseSoftmaxCrossEntropyWithLogits/strided_slice:0) = ] [64 14]
       [[{{node loss/output_1_loss/SparseSoftmaxCrossEntropyWithLogits/assert_equal_1/Assert/Assert}}]]
     64/54000 [..............................] - ETA: 39:34Traceback (most recent call last):
    File &quot;F:\anaconda\envs\tensorflow1\lib\site-packages\IPython\core\interactiveshell.py&quot;, line 3331, in run_code
      exec(code_obj, self.user_global_ns, self.user_ns)
    File &quot;&lt;ipython-input-2-d2317d03e1c1&gt;&quot;, line 1, in &lt;module&gt;
      runfile('F:/Pycharm_projects/my_fun_project/Fake or real news/fake-or-real-news/bitcoin.py', wdir='F:/Pycharm_projects/my_fun_project/Fake or real news/fake-or-real-news')
    File &quot;C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.3\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_umd.py&quot;, line 197, in runfile
      pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
    File &quot;C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.3\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py&quot;, line 18, in execfile
      exec(compile(contents+&quot;\n&quot;, file, 'exec'), glob, loc)
    File &quot;F:/Pycharm_projects/my_fun_project/Fake or real news/fake-or-real-news/bitcoin.py&quot;, line 41, in &lt;module&gt;
      model.fit(x=x_train, y=y_train, batch_size=64, epochs=5, shuffle=True, validation_split=0.1)
    File &quot;F:\anaconda\envs\tensorflow1\lib\site-packages\tensorflow_core\python\keras\engine\training.py&quot;, line 819, in fit
      use_multiprocessing=use_multiprocessing)
    File &quot;F:\anaconda\envs\tensorflow1\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py&quot;, line 342, in fit
      total_epochs=epochs)
    File &quot;F:\anaconda\envs\tensorflow1\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py&quot;, line 128, in run_one_epoch
      batch_outs = execution_function(iterator)
    File &quot;F:\anaconda\envs\tensorflow1\lib\site-packages\tensorflow_core\python\keras\engine\training_v2_utils.py&quot;, line 98, in execution_function
      distributed_function(input_fn))
    File &quot;F:\anaconda\envs\tensorflow1\lib\site-packages\tensorflow_core\python\eager\def_function.py&quot;, line 568, in __call__
      result = self._call(*args, **kwds)
    File &quot;F:\anaconda\envs\tensorflow1\lib\site-packages\tensorflow_core\python\eager\def_function.py&quot;, line 632, in _call
      return self._stateless_fn(*args, **kwds)
    File &quot;F:\anaconda\envs\tensorflow1\lib\site-packages\tensorflow_core\python\eager\function.py&quot;, line 2363, in __call__
      return graph_function._filtered_call(args, kwargs)  # pylint: disable=protected-access
    File &quot;F:\anaconda\envs\tensorflow1\lib\site-packages\tensorflow_core\python\eager\function.py&quot;, line 1611, in _filtered_call
      self.captured_inputs)
    File &quot;F:\anaconda\envs\tensorflow1\lib\site-packages\tensorflow_core\python\eager\function.py&quot;, line 1692, in _call_flat
      ctx, args, cancellation_manager=cancellation_manager))
    File &quot;F:\anaconda\envs\tensorflow1\lib\site-packages\tensorflow_core\python\eager\function.py&quot;, line 545, in call
      ctx=ctx)
    File &quot;F:\anaconda\envs\tensorflow1\lib\site-packages\tensorflow_core\python\eager\execute.py&quot;, line 67, in quick_execute
      six.raise_from(core._status_to_exception(e.code, message), None)
    File &quot;&lt;string&gt;&quot;, line 3, in raise_from
  tensorflow.python.framework.errors_impl.InvalidArgumentError:  assertion failed: [Condition x == y did not hold element-wise:] [x (loss/output_1_loss/SparseSoftmaxCrossEntropyWithLogits/Shape_1:0) = ] [64 1] [y (loss/output_1_loss/SparseSoftmaxCrossEntropyWithLogits/strided_slice:0) = ] [64 14]
       [[node loss/output_1_loss/SparseSoftmaxCrossEntropyWithLogits/assert_equal_1/Assert/Assert (defined at F:/Pycharm_projects/my_fun_project/Fake or real news/fake-or-real-news/bitcoin.py:41) ]] [Op:__inference_distributed_function_2970]
  Function call stack:
  distributed_function
  
  </code></pre>