با سلام من کد زیررو نوشتم ولی متاسفانه ارور میگیرم .ممنون میشم اگر راهنمایی کنید:
#autoencoder
from keras.layers import Input, Dense, Conv2D, MaxPooling2D, UpSampling2D
from keras.models import Model
from keras import backend as K
from keras.models import Sequential
from keras.layers.convolutional_recurrent import ConvLSTM2D
from keras.layers.normalization import BatchNormalization
from keras import optimizers
import keras
#encoder
input_img = Input(shape=(228, 228, 1)) # adapt this if using `channels_first` image data format
x = Conv2D(128, (11, 11), activation='relu',padding='valid',strides=3)(input_img)
x = Conv2D(64, (3, 3), activation='relu', padding='valid',strides=2)(x)
x = Conv2D(32, (5, 5), activation='relu', padding='valid')(x)
# at this point the representation is (4, 4, 8) i.e. 128-dimensional
#decoder
x = Conv2D(64, (5, 5), activation='relu', padding='same')(x)
x = UpSampling2D((2, 2))(x)
x = Conv2D(128, (3, 3), activation='relu', padding='same',strides=2)(x)
x = UpSampling2D((2, 2))(x)
x = Conv2D(1, (11, 11), activation='relu' , padding='same',strides=3)(x)
x = UpSampling2D((2, 2))(x)
decoded = Conv2D(1, (3, 3), activation='sigmoid', padding='same')(x)
keras.optimizers.RMSprop(lr=0.001, rho=0.9, epsilon=None, decay=0.0)
#RMSprob =keras.optimizers.RMSprop(lr=0.0001, rho=0.9, epsilon=None, decay=0.96)
#sgd = optimizers.SGD(lr=0.0001, decay=5e-4, momentum=0.96, nesterov=True)
autoencoder = Model(input_img, x)
autoencoder.compile(optimizer='rmsprop', loss='mean_squared_error')
autoencoder.fit(x_train,x_train,epochs=1)
autoencoder.save("ArticleAutoencoder.h5")
خطا :
Using TensorFlow backend.
Traceback (most recent call last):
File "E:/new folder(3)/article autoencoder.py", line 65, in <module>
autoencoder.fit(x_train,x_train,epochs=1)
File "E:\Program Files\Python\Python36\lib\site-packages\keras\engine\training.py", line 952, in fit
batch_size=batch_size)
File "E:\Program Files\Python\Python36\lib\site-packages\keras\engine\training.py", line 789, in _standardize_user_data
exception_prefix='target')
File "E:\Program Files\Python\Python36\lib\site-packages\keras\engine\training_utils.py", line 138, in standardize_input_data
str(data_shape))
ValueError: Error when checking target: expected up_sampling2d_3 to have shape (44, 44, 1) but got array with shape (228, 228, 1)
Process finished with exit code 1