def nudge_dataset(X, Y):
 direction_vectors = [[[0, 1, 0], [0, 0, 0], [0, 0, 0]], [[0, 0, 0], [1, 0, 0], [0, 0, 0]], [[0, 0, 0], [0, 0, 1], [0, 0, 0]], [[0, 0, 0], [0, 0, 0], [0, 1, 0]]]
 shift = (lambda x, w: convolve(x.reshape((8, 8)), mode='constant', weights=w).ravel())
 X = np.concatenate(([X] + [np.apply_along_axis(shift, 1, X, vector) for vector in direction_vectors]))
 Y = np.concatenate([Y for _ in range(5)], axis=0)
 return (X, Y)

def nudge_dataset ( X , Y ) : direction_vectors = [ [ [ 0 , 1 , 0 ] , [ 0 , 0 , 0 ] , [ 0 , 0 , 0 ] ] , [ [ 0 , 0 , 0 ] , [ 1 , 0 , 0 ] , [ 0 , 0 , 0 ] ] , [ [ 0 , 0 , 0 ] , [ 0 , 0 , 1 ] , [ 0 , 0 , 0 ] ] , [ [ 0 , 0 , 0 ] , [ 0 , 0 , 0 ] , [ 0 , 1 , 0 ] ] ] shift = ( lambda x , w : convolve ( x . reshape ( ( 8 , 8 ) ) , mode = 'constant' , weights = w ) . ravel ( ) ) X = np . concatenate ( ( [ X ] + [ np . apply_along_axis ( shift , 1 , X , vector ) for vector in direction_vectors ] ) ) Y = np . concatenate ( [ Y for _ in range ( 5 ) ] , axis = 0 ) return ( X , Y )
this produces a dataset 5 times bigger than the original one .