I want to use this code as an autoencoder:
# ENCODER
input_sig = Input(batch_shape=(None,1389,1))
x = Conv1D(64,3, activation='relu', padding='valid')(input_sig)
x1 = MaxPooling1D(2)(x)
x2 = Conv1D(32,3, activation='relu', padding='valid')(x1)
x3 = MaxPooling1D(2)(x2)
flat = Flatten()(x3)
encoded = Dense(32,activation = 'relu')(flat)
#encoded = Reshape((32,1))(encoded)
print("shape of encoded {}".format(K.int_shape(encoded)))
# DECODER
x2_ = Conv1D(32, 3, activation='relu', padding='valid')(x3)
x1_ = UpSampling1D(2)(x2_)
x_ = Conv1D(64, 3, activation='relu', padding='valid')(x1_)
upsamp = UpSampling1D(2)(x_)
flat = Flatten()(upsamp)
decoded = Dense(1389,activation = 'relu')(flat)
decoded = Reshape((1389,))(decoded)
print("shape of decoded {}".format(K.int_shape(decoded)))
autoencoder = Model(input_sig, decoded)
autoencoder.compile(optimizer='adam', loss='mse', metrics=['accuracy'])
As you can see, the shapes of encoded is (?, 32) and decoded (?, 1389).
The shape of my training_data is (141, 1389).
By execute the following code,
autoencoder.fit(X_train, X_train,
epochs=150,
batch_size=256,
shuffle=True,
validation_data=(X_test, X_test))
I got the error: ValueError: Error when checking input: expected input_15 to have 3 dimensions, but got array with shape (141, 1389)
Could you help me by solving this problem?
(141, 1389)and yourInputlayer has a shape(None,1389,1). So it is expecting 3 dimensions. Change either of the shapes according to your need.Inputlayertrain = K.reshape(X_train,(141,1389,1)) test = K.reshape(X_test,(36,1389,1)) autoencoder.fit(train, train, epochs=150, batch_size=256, shuffle=True, validation_data=(test, test))ValueError: If your data is in the form of symbolic tensors, you should specify the "steps_per_epoch" argument (instead of the "batch_size" argument, because symbolic tensors are expected to produce batches of input data).