Ich versuche, die 2d Faltungsautoencoder Beispiel aus der keras Webseite anzupassen: https://blog.keras.io/building-autoencoders-in-keras.htmlkeras Autoencoder "Fehler bei der Überprüfung Ziel"
zu meinem eigenen Fall, in dem i 1d Eingänge verwenden:
from keras.layers import Input, Dense, Conv1D, MaxPooling1D, UpSampling1D
from keras.models import Model
from keras import backend as K
import scipy as scipy
import numpy as np
mat = scipy.io.loadmat('edata.mat')
emat = mat['edata']
input_img = Input(shape=(64,1)) # adapt this if using `channels_first` image data format
x = Conv1D(32, (9), activation='relu', padding='same')(input_img)
x = MaxPooling1D((4), padding='same')(x)
x = Conv1D(16, (9), activation='relu', padding='same')(x)
x = MaxPooling1D((4), padding='same')(x)
x = Conv1D(8, (9), activation='relu', padding='same')(x)
encoded = MaxPooling1D(4, padding='same')(x)
x = Conv1D(8, (9), activation='relu', padding='same')(encoded)
x = UpSampling1D((4))(x)
x = Conv1D(16, (9), activation='relu', padding='same')(x)
x = UpSampling1D((4))(x)
x = Conv1D(32, (9), activation='relu')(x)
x = UpSampling1D((4))(x)
decoded = Conv1D(1, (9), activation='sigmoid', padding='same')(x)
autoencoder = Model(input_img, decoded)
autoencoder.compile(optimizer='adadelta', loss='binary_crossentropy')
x_train = emat[:,0:80000]
x_train = np.reshape(x_train, (x_train.shape[1], 64, 1))
x_test = emat[:,80000:120000]
x_test = np.reshape(x_test, (x_test.shape[1], 64, 1))
from keras.callbacks import TensorBoard
autoencoder.fit(x_train, x_train,
epochs=50,
batch_size=128,
shuffle=True,
validation_data=(x_test, x_test),
callbacks=[TensorBoard(log_dir='/tmp/autoencoder')])
jedoch erhalte ich diese Störung, wenn ich versuche, die autoencoder.fit zu laufen():
ValueError: Error when checking target: expected conv1d_165 to have shape (None, 32, 1) but got array with shape (80000, 64, 1)
ich weiß, ich mache einige wahrscheinlich sache falsch, wenn ich meine Schichten aufstelle, änderte ich gerade die Größen maxpool und conv2d zu einer 1d Form ... ich habe sehr wenig Erfahrung mit keras oder autoencoders, jedermann sehen, was ich falsch mache?
dank
EDIT: der Fehler, wenn ich es auf einem frischen Konsole ausführen:
ValueError: Error when checking target: expected conv1d_7 to have shape (None, 32, 1) but got array with shape (80000, 64, 1)
hier ist die Ausgabe von autoencoder.summary()
Layer (type) Output Shape Param #
=================================================================
input_1 (InputLayer) (None, 64, 1) 0
_________________________________________________________________
conv1d_1 (Conv1D) (None, 64, 32) 320
_________________________________________________________________
max_pooling1d_1 (MaxPooling1 (None, 16, 32) 0
_________________________________________________________________
conv1d_2 (Conv1D) (None, 16, 16) 4624
_________________________________________________________________
max_pooling1d_2 (MaxPooling1 (None, 4, 16) 0
_________________________________________________________________
conv1d_3 (Conv1D) (None, 4, 8) 1160
_________________________________________________________________
max_pooling1d_3 (MaxPooling1 (None, 1, 8) 0
_________________________________________________________________
conv1d_4 (Conv1D) (None, 1, 8) 584
_________________________________________________________________
up_sampling1d_1 (UpSampling1 (None, 4, 8) 0
_________________________________________________________________
conv1d_5 (Conv1D) (None, 4, 16) 1168
_________________________________________________________________
up_sampling1d_2 (UpSampling1 (None, 16, 16) 0
_________________________________________________________________
conv1d_6 (Conv1D) (None, 8, 32) 4640
_________________________________________________________________
up_sampling1d_3 (UpSampling1 (None, 32, 32) 0
_________________________________________________________________
conv1d_7 (Conv1D) (None, 32, 1) 289
=================================================================
Total params: 12,785
Trainable params: 12,785
Non-trainable params: 0
_________________________________________________________________
Es ist schwer zu sehen, welche Schicht 'conv1d_165' genau ist (Sie haben das wahrscheinlich schon oft gemacht); Führen Sie ein neues Skript oder Kernel erneut aus, und fügen Sie das Ergebnis von 'autoencoder.summary()' hinzu, bevor Sie – desertnaut
einfügen. Danke!Ich bearbeitete meinen Beitrag mit der frischen Konsole Ausgabe und autoencoder.summary() –
Ich bearbeitete (formatiert) die Ausgabe Ihrer 'Zusammenfassung()' (es war unlesbar) - Bitte bestätigen Sie, dass es das gleiche mit Ihrem ist – desertnaut