title: Only integers, slices (`:`), ellipsis (`...`), tf.newaxis (`None`) and scalar tf.int32/tf.int64 tensors are valid indices, got array([ 219, 928,
body: <p>I have three different sensors. For each I have the following shape according tf:</p>
  <pre><code>sensor1.shape = (1134, 100, 400)
  sensor2.shape = (1134, 100, 400)
  sensor3.shape = (1134, 100, 400)
  </code></pre>
  <p>Each tensor has the same size.</p>
  <p>In the next step I stack these 3 sensors in order to get one with just 3 dimensions:</p>
  <pre><code>final = tf.stack([sensor1, sensor2, sensor3], axis=-1)
  
  final.shape
  
  TensorShape([1134, 100, 400, 3])
  </code></pre>
  <p>Now I want to do a train test split</p>
  <pre><code>X_train, X_test, y_train, y_test = train_test_split(final, y, test_size=0.25, random_state=42, stratify=y)
  </code></pre>
  <p>but following error occurs:
  <em><strong>Only integers, slices (<code>:</code>), ellipsis (<code>...</code>), tf.newaxis (<code>None</code>) and scalar tf.int32/tf.int64 tensors are valid indices, got array([ 219,  928,  636,  862,  606,  793,  621,  118, 1047,  635,  ..</strong></em>
  Any ideas? What's wrong?</p>
  <p>Edit:
  Current working solution with just <strong>1</strong> sensor. So I think the problem are the three 3 dimensions.</p>
  <pre><code>sensor1.shape
  (100, 400, 1134)
  
  final = np.moveaxis(sensor1, -1, 0)
  
  final.shape
  (1134, 100, 400)
  
  X_train, X_test, y_train, y_test = train_test_split(final, y, test_size=0.25, random_state=42, stratify=y)
  
  print(&quot;X:&quot;, final.shape)
  print(&quot;y:&quot;, y.shape)
  
  print(&quot;Xtrain:&quot;, X_train.shape)
  print(&quot;y_train:&quot;, y_train.shape)
  print(&quot;X_test:&quot;, X_test.shape)
  print(&quot;y_test:&quot;, y_test.shape)
  
  X: (1134, 100, 400)
  y: (1134,)
  Xtrain: (850, 100, 400)
  y_train: (850,)
  X_test: (284, 100, 400)
  y_test: (284,)
  
  X_train = tf.expand_dims(X_train, axis=-1)
  X_test = tf.expand_dims(X_test, axis=-1)
  
  print(&quot;X_train shape new:&quot;, X_train.shape)
  X_train shape new: (850, 100, 400, 1)
  
  </code></pre>