У меня возникла эта проблема: ошибка при проверке цели: ожидалось, что плотность_производителя имеет 2 измерения, но получен массив с формой (35206, 50, 1). При этом коде используется автоматический кодер с CONV1D и двумя выходными данными, но проблема заключается в реконструкциивыходной сигнал (density_output):
X_train, X_test, y_train, y_test = train_test_split(X, other_output, test_size=0.3, random_state=42)
TAM_VECTOR = X_train.shape[1]
input_tweet = Input(shape=(TAM_VECTOR,X_train.shape[2]))
encoded = Conv1D(64, kernel_size=1, activation='relu')(input_tweet)
encoded = Conv1D(32, kernel_size=1, activation='relu')(encoded)
decoded = Conv1D(32, kernel_size=1, activation='relu')(encoded)
decoded = Conv1D(64, kernel_size=1, activation='relu')(decoded)
decoded = Flatten()(decoded)
decoded = Dense(TAM_VECTOR, activation='relu', name='dense_output')(decoded)
encoded = Flatten()(encoded)
second_output = Dense(1, activation='linear', name='second_output')(encoded)
autoencoder = Model(inputs=input_tweet, outputs=[decoded, second_output])
autoencoder.compile(optimizer="adam",
loss={'dense_output': 'mse', 'second_output': 'mse'},
loss_weights={'dense_output': 0.001, 'second_output': 0.999},
metrics=["mae"])
autoencoder.fit([X_train], [X_train, y_train], epochs=10, batch_size=32)
Вход (X) имеет форму (50000,50), и я изменяю его на:
X = np.reshape(X, (X.shape[0], X.shape[1], -1))
(50000,50,1)
И other_output -
other_output.shape
(50000,1)
А вот краткое изложение модели
Layer (type) Output Shape Param # Connected to
==================================================================================================
input_27 (InputLayer) (None, 50, 1) 0
__________________________________________________________________________________________________
conv1d_105 (Conv1D) (None, 50, 64) 128 input_27[0][0]
__________________________________________________________________________________________________
conv1d_106 (Conv1D) (None, 50, 32) 2080 conv1d_105[0][0]
__________________________________________________________________________________________________
conv1d_107 (Conv1D) (None, 50, 32) 1056 conv1d_106[0][0]
__________________________________________________________________________________________________
conv1d_108 (Conv1D) (None, 50, 64) 2112 conv1d_107[0][0]
__________________________________________________________________________________________________
flatten_42 (Flatten) (None, 3200) 0 conv1d_108[0][0]
__________________________________________________________________________________________________
flatten_43 (Flatten) (None, 1600) 0 conv1d_106[0][0]
__________________________________________________________________________________________________
dense_output (Dense) (None, 50) 160050 flatten_42[0][0]
__________________________________________________________________________________________________
second_output (Dense) (None, 1) 1601 flatten_43[0][0]
==================================================================================================
Total params: 167,027
Trainable params: 167,027
Non-trainable params: 0