1

I am trying to program a convolutional autoencoder with my 2D array data (28x28). Here is the link I referred. https://blog.keras.io/building-autoencoders-in-keras.html

The only deference between the reference and mine is either MNIST or mine.

The problem should be caused by the data split "X_train..., X_test..." sections. Since I have been having a trouble with if I use skitlearn train_test_split algorism.

I know what it the problem. I just do not know how to fix it. Thank you.

data1 = pd.read_csv("2D2828.csv")
data2 = data1.as_matrix()
X = data2.astype(np.float32)
X = Input(shape=(28, 28, 1))

ae_cnn = Conv2D(16, (3, 3), activation='relu', padding='same')(X)
ae_cnn = MaxPooling2D((2, 2), padding='same')(ae_cnn)
ae_cnn = Conv2D(8, (3, 3), activation='relu', padding='same')(ae_cnn)
ae_cnn = MaxPooling2D((2, 2), padding='same')(ae_cnn)
ae_cnn = Conv2D(8, (3, 3), activation='relu', padding='same')(ae_cnn)
encoded = MaxPooling2D((2, 2), padding='same')(ae_cnn)

ae_cnn = Conv2D(8, (3, 3), activation='relu', padding='same')(encoded)
ae_cnn = UpSampling2D((2, 2))(ae_cnn)
ae_cnn = Conv2D(8, (3, 3), activation='relu', padding='same')(ae_cnn)
ae_cnn = UpSampling2D((2, 2))(ae_cnn)
ae_cnn = Conv2D(16, (3, 3), activation='relu')(ae_cnn)
ae_cnn = UpSampling2D((2, 2))(ae_cnn)
decoded = Conv2D(1, (3, 3), activation='sigmoid', padding='same')(ae_cnn)

autoencoder = Model(X, decoded)
autoencoder.compile(optimizer='adadelta', loss='binary_crossentropy')

from keras.callbacks import TensorBoard
X_train = X[1:24
X_test = X[25:28]

autoencoder.fit(X_train, X_train,
                epochs=2,
                batch_size=2,
4

0 回答 0