python - How to handle variable sized input in CNN with Keras? -
i trying perform usual classification on mnist database randomly cropped digits. images cropped following way : removed randomly first/last and/or row/column. i use convolutional neural network using keras (and tensorflow backend) perform convolution , usual classification. inputs of variable size , can't manage work. here how cropped digits import numpy np keras.utils import to_categorical sklearn.datasets import load_digits digits = load_digits() x = digits.images x = np.expand_dims(x, axis=3) x_crop = list() index in range(len(x)): x_crop.append(x[index, np.random.randint(0,2):np.random.randint(7,9), np.random.randint(0,2):np.random.randint(7,9), :]) x_crop = np.array(x_crop) y = to_categorical(digits.target) sklearn.model_selection import train_test_split x_train, x_test, y_train, y_test = train_test_split(x_crop, y, train_size=0.8, test_size=0.2) and here architecture of model want use from keras.layers import dense, dropout keras.layers.convolutiona