title: Model was constructed with shape (None, 65536) but it was called on an input with incompatible shape (None, 65536, None)
body: <p>For reference the full error is here:</p>
  <pre><code>WARNING:tensorflow:Model was constructed with shape (None, 65536) for input KerasTensor(type_spec=TensorSpec(shape=(None, 65536), dtype=tf.float32, name='input_1'), name='input_1', description=&quot;created by layer 'input_1'&quot;), but it was called on an input with incompatible shape (None, 65536, None).
  </code></pre>
  <p>I am using <a href="https://www.kymat.io/index.html" rel="nofollow noreferrer"><code>kymatio</code></a> to classify audio signals. Before constructing the model I use tensorflow's <a href="https://www.tensorflow.org/api_docs/python/tf/keras/utils/audio_dataset_from_directory" rel="nofollow noreferrer"><code>tf.keras.utils.audio_dataset_from_directory</code></a> to create the training and testing sets.</p>
  <p>The audio samples are of shape <code>(65536,)</code> before the sets are created. To create the sets I use the following code:</p>
  <pre><code>T = 2**16
  J = 8
  Q = 12
  log_eps = 1e-6
  SEED = 42
  
  train_dataset = tf.keras.utils.audio_dataset_from_directory(
      '../train',
      labels='inferred',
      label_mode='int',
      class_names=['x', 'y', 'z', 'xy', 'xz', 'yz', 'xyz'],
      batch_size=32,
      output_sequence_length=T,
      ragged=False,
      shuffle=True,
      seed=SEED,
      follow_links=False
  )
  </code></pre>
  <p>The <code>element_spec</code> of the <code>train_dataset</code> is <code>(TensorSpec(shape=(None, 65536, None), dtype=tf.float32, name=None), TensorSpec(shape=(None,), dtype=tf.int32, name=None))</code>.</p>
  <p>So at some point the shape is changing in the <code>TensorSpec</code> to <code>(None, 65536, None)</code> for some reason...</p>
  <p>The model is constructed as follows and the error points to <code>model.fit(...)</code>.</p>
  <pre><code>x_in = layers.Input(shape=(T))
  x = Scattering1D(J, Q=Q)(x_in)
  x = layers.Lambda(lambda x: x[..., 1:, :])(x)
  x = layers.Lambda(lambda x: tf.math.log(tf.abs(x) + log_eps))(x)
  x = layers.GlobalAveragePooling1D(data_format='channels_first')(x)
  x = layers.BatchNormalization(axis=1)(x)
  x_out = layers.Dense(7, activation='softmax')(x)
  model = tf.keras.models.Model(x_in, x_out)
  model.summary()
  model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
  model.fit(train_dataset, epochs=50)
  </code></pre>