I try to shift Mnist image by one pixel in each direction(up, down, left, right) and add these shifted image into the training set. But the result always shows the same error. The following is the code
from scipy.ndimage import shift
import pandas as pd
def shift_image(image, shift_x, shift_y):
image = image.reshape(28,28)
shifted_image = shift(image, shift_x, shift_y)
return shifted_image.reshape(-1)
X_train_expansion = X_train.copy()
y_train_expansion = y_train.copy()
for shift_x, shift_y in ((0,1), (0,-1), (1, 0), (-1, 0)):
for image, label in zip(np.array(X_train), y_train):
X_train_expansion = pd.concat(X_train_expansion, shift_image(image, shift_x, shift_y))
y_train_expansion.append(label)
[enter image description here](https://i.sstatic.net/19NRntp3.png)
Can anyone tell me why this happen and what the possible solutions will be?