Skip to content Skip to sidebar Skip to footer

Input 0 Of Layer Conv1d_1 Is Incompatible With The Layer: Expected Ndim=3, Found Ndim=2. Full Shape Received: [none, 200]

I'm working on application that should predict interesting moments in 10 sec audio files. I divided audio on 50ms chunks and extracted notes, so I have 200 notes for each example.

Solution 1:

The 1D convolution over sequences expects a 3D input. In other words, for each element in the batch, for each time step, a single vector. Consider the following:

X = tf.random.normal([10, 200])
convolved = tf.keras.layers.Conv1D(32, 3, padding='same', activation=tf.nn.relu, input_shape=[None, 200])
print(convolved(X))

This throws an error:

ValueError: Input 0 of layer conv1d_3 is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: [10, 200]

However, If we provide for each of the 10 batch samples, for each of the 5 time steps, a 200 dimensional vector:

X = tf.random.normal([10, 5, 200])
convolved = tf.keras.layers.Conv1D(32, 3, padding='same', activation=tf.nn.relu, input_shape=[None, 200])
print(convolved(X)

This works as it should. Therefore, in your case, for each audio file, for each second (depends on how you sample the data), you will have a single vector.

Post a Comment for "Input 0 Of Layer Conv1d_1 Is Incompatible With The Layer: Expected Ndim=3, Found Ndim=2. Full Shape Received: [none, 200]"