from perclearn import mnist_reader
from perclearn.utils import (
    create_2D_noise,
    scale_2D,
    create_new_dataset,
)

cwd = os.getcwd()

X_train, y_train = mnist_reader.load_mnist(opj(cwd, 'perclearn/data/fashion'),
                                           kind='train')
X_test, y_test = mnist_reader.load_mnist(opj(cwd, 'perclearn/data/fashion'),
                                         kind='t10k')

X_train = create_new_dataset(X_train, [[0, 0]])
np.savez(opj(cwd, 'perclearn/data/experiments/1/training'), X_train)

X_test = create_new_dataset(X_test, [[0, 28], [28, 0], [28, 28]])
np.savez(opj(cwd, 'perclearn/data/experiments/1/testing'), X_test)

dataset = X_test
i = 10
offsets = [[0, 28], [28, 0], [28, 28]]

m, n = dataset.shape
im_x = int(np.sqrt(n))
num_offsets = len(offsets)

new_dataset = np.zeros((m, n * 4))
model.fit(x_train,
          y_train,
          validation_data=(x_val, y_val),
          batch_size=batch_size,
          epochs=epochs,
          verbose=1)
"""
TRANSLATION
"""

score = np.empty((2, 28))
# iterate over creation of different x_tests and evaluate model
for offset_x in range(28):

    x_test, _ = create_new_dataset(x_test_full, [[offset_x, 0]])

    if K.image_data_format() == 'channels_first':
        x_test = x_test.reshape(x_test.shape[0], 1, img_rows, img_cols)
    else:
        x_test = x_test.reshape(x_test.shape[0], img_rows, img_cols, 1)

    x_test = x_test.astype('float32')
    x_test /= 255
    print(x_test.shape[0], 'test samples')
    print('offset x: ', offset_x)

    score[:, offset_x] = np.array(model.evaluate(x_test, y_test, verbose=0))
    print('Test loss:', score[0, offset_x])
    print('Test accuracy:', score[1, offset_x])