title: ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type int). Tensorflow 1.15 runs. Tensorflow 2.x breaks
body: <p>System: Linux Manjaro</p>
  <p>The full Error is:</p>
  <pre><code>    history = clf.fit(
    File &quot;/usr/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py&quot;, line 66, in _method_wrapper
      return method(self, *args, **kwargs)
    File &quot;/usr/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py&quot;, line 795, in fit
      data_adapter.train_validation_split((x, y, sample_weight),
    File &quot;/usr/lib/python3.8/site-packages/tensorflow/python/keras/engine/data_adapter.py&quot;, line 1337, in train_validation_split
      train_arrays = nest.map_structure(
    File &quot;/usr/lib/python3.8/site-packages/tensorflow/python/util/nest.py&quot;, line 617, in map_structure
      structure[0], [func(*x) for x in entries],
    File &quot;/usr/lib/python3.8/site-packages/tensorflow/python/util/nest.py&quot;, line 617, in &lt;listcomp&gt;
      structure[0], [func(*x) for x in entries],
    File &quot;/usr/lib/python3.8/site-packages/tensorflow/python/keras/engine/data_adapter.py&quot;, line 1334, in _split
      t = ops.convert_to_tensor_v2(t)
    File &quot;/usr/lib/python3.8/site-packages/tensorflow/python/framework/ops.py&quot;, line 1278, in convert_to_tensor_v2
      return convert_to_tensor(
    File &quot;/usr/lib/python3.8/site-packages/tensorflow/python/framework/ops.py&quot;, line 1341, in convert_to_tensor
      ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
    File &quot;/usr/lib/python3.8/site-packages/tensorflow/python/framework/tensor_conversion_registry.py&quot;, line 52, in _default_conversion_function
      return constant_op.constant(value, dtype, name=name)
    File &quot;/usr/lib/python3.8/site-packages/tensorflow/python/framework/constant_op.py&quot;, line 261, in constant
      return _constant_impl(value, dtype, shape, name, verify_shape=False,
    File &quot;/usr/lib/python3.8/site-packages/tensorflow/python/framework/constant_op.py&quot;, line 270, in _constant_impl
      t = convert_to_eager_tensor(value, ctx, dtype)
    File &quot;/usr/lib/python3.8/site-packages/tensorflow/python/framework/constant_op.py&quot;, line 96, in convert_to_eager_tensor
      return ops.EagerTensor(value, ctx.device_name, dtype)
  ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type int).
  </code></pre>
  <p>I am training a CNN with the following code:</p>
  <pre><code>X2 = np.append(self.data.Img_Lr2_Train, self.data.Img_Lr2_Val, axis=0)
  Y  = np.append(self.data.Y_Train, self.data.Y_Val, axis=0)
  Y  = np.multiply(Y, 1)
  X2, Y = shuffle(X2, Y, random_state=self.seed)
  X2 = X2.reshape(X2.shape[0], 11, 7, 1)
  
  history = clf.fit(
                    x=X2,
                    y=Y,
                    epochs=self.nEp,
                    batch_size=self.bt,
                    # shuffle=True,
                    validation_split=0.33,
                    callbacks=callbacks_list,
                    class_weight=class_weights
                    )
  </code></pre>
  <p>Following this (<a href="https://stackoverflow.com/questions/58636087/tensorflow-valueerror-failed-to-convert-a-numpy-array-to-a-tensor-unsupporte">Tensorflow - ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type float)</a>) discusion I checked the variables type and shape:
  which are all numpy arrays and are as expected.</p>
  <p>Also the <strong>MAIN ISSUE</strong> is that when I run this with tensorflow 1.15 I don't get any problems.
  However if I try runing with tensorflow 2.2 then I get the error.
  I have tried migrating the code from tf_v1 -&gt; tf_v2 using
  <code>tf_upgrade_v2 </code>
  both in <code>DEFAULT</code> and <code>SAFETY</code> mode,
  and in both cases the process ends successfully.
  However that didn't solve it.</p>
  <p>Any idea where the problem might be?</p>
  <p>Thank you in advance</p>