Here is the shape of my data
print(X_train1_padded.shape, y_train1_padded.shape)
print(X_val1_padded.shape, y_val1_padded.shape)
print(X_test1_padded.shape, y_test1_padded.shape)
(203161, 496, 1) (203161, 496, 1)
(118096, 496, 1) (118096, 496, 1)
(85491, 496, 1) (85491, 496, 1)
And here is my model code
# Initialize the Sequential model
model = Sequential()
# 1D Convolutional Layer 1
model.add(Conv1D(8, 4, activation="linear", input_shape=(sequence_len, 1), padding="same", strides=1))
model.add(MaxPooling1D(pool_size=2))
# 1D Convolutional Layer 2
model.add(Conv1D(8, 4, activation="linear", padding="same", strides=1))
model.add(MaxPooling1D(pool_size=2))
model.add(Flatten())
# Fully Connected Layers
model.add(Dropout(0.2))
model.add(Dense((sequence_len - 3) * 8, activation='relu')) # Adjusted input size
model.add(Dropout(0.2))
model.add(Dense(128, activation='relu'))
model.add(Dropout(0.2))
model.add(Dense((sequence_len - 3) * 8, activation='relu')) # Adjusted input size
model.add(Dropout(0.2))
# UpSampling1D Layer 1
model.add(Reshape(((sequence_len-3), 8)))
model.add(UpSampling1D(size=2))
model.add(Conv1D(1, 4, activation="linear", padding="same", strides=1))
# UpSampling1D Layer 2
model.add(UpSampling1D(size=2))
# Adjust the number of filters and kernel size to match the required output shape
model.add(Conv1D(1, 4, activation="linear", padding="same", strides=1))
model.summary()
optimizer = SGD(lr=0.01, momentum=0.9, decay=1e-6)
model.compile(loss='mse', optimizer=optimizer)
I am trying to run it but the main issue is that the input and output shape is not matched. Here is the error
model.fit(X_train1_padded, y_train1_padded, epochs=50, batch_size=16, validation_data=(X_val1_padded, y_val1_padded),shuffle=True)
ValueError: Dimensions must be equal, but are 1972 and 496 for '{{node mean_squared_error/SquaredDifference}} = SquaredDifference[T=DT_FLOAT](sequential_11/conv1d_37/BiasAdd, IteratorGetNext:1)' with input shapes: [?,1972,1], [?,496,1].
I can’t change the model because its the requirement so could anyone suggest something to do with the shape of the data
New contributor
axiid 777 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.