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. When I add convolutional layer it returns an error:
ValueError: Input 0 of layer conv1d_1 is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: [None, 200]
Here is my code:
def get_dataset(file_path):
dataset = tf.data.experimental.make_csv_dataset(
file_path,
batch_size=12,
label_name='label',
na_value='?',
num_epochs=1,
ignore_errors=False)
return dataset
train = get_dataset('/content/gdrive/My Drive/MyProject/train.csv')
test = get_dataset('/content/gdrive/My Drive/MyProject/TestData/manual.csv')
feature_columns = []
for number in range(200):
feature_columns.append(tf.feature_column.numeric_column('note' + str(number + 1) ))
preprocessing_layer = tf.keras.layers.DenseFeatures(feature_columns)
model = tf.keras.Sequential([
preprocessing_layer,
tf.keras.layers.Conv1D(32, 3, padding='same', activation=tf.nn.relu, input_shape=[None, 200]),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(50, activation=tf.nn.relu),
tf.keras.layers.Dense(1, activation=tf.nn.sigmoid)
])
model.compile(
loss='binary_crossentropy',
optimizer='adam',
metrics=['accuracy'])
model.fit(train, epochs=20)
What causes this problem and how can it be fixed?