# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import pickle
import numpy as np
import sys
import os
o_path = os.getcwd()
sys.path.append(os.path.dirname(o_path))
from models.utils import *
# %matplotlib inline

# +
save_path = '../../data/source_data/mnist_100'

train_imgs_ = load_pkls(save_path, 'train_images')
train_labels_ = load_pkls(save_path, 'train_labels')
square_grid_show_imgs(train_imgs_[:25], mode='L')
print(train_labels_[:25])


# -

def load_pickle(data_path):
    with open(data_path, 'rb') as f:
        return pickle.load(f)


def is_equal(a):
    x_bk = load_pickle('../../data/mnist_bk/{}.p'.format(a))
    print(x_bk.shape)
    x = load_pickle('../../data/preprocessed_data/mnist/{}.p'.format(a))
    print(x.shape)
    print(a+': ', np.equal(x_bk, x).all())


is_equal('x_train')
is_equal('x_test')
is_equal('x_valid')
is_equal('y_train')
is_equal('y_test')
is_equal('y_valid')
is_equal('imgs_train')
is_equal('imgs_test')
is_equal('imgs_valid')

y = np.argmax(load_pickle('../../data/mnist_bk/y_test.p'), axis=-1)
y[:100]

y = np.argmax(load_pickle('../../data/preprocessed_data/mnist/y_test.p'), axis=-1)
y[:100]

y = load_pickle('../../data/source_data/mnist/test_labels.p')
y[:100]


def is_equal(a):
    x_bk = load_pickle('../../data/source_data/{}.p'.format(a))
    print(x_bk.shape)
    x = load_pickle('../../data/preprocessed_data/mnist/{}.p'.format(a))
    print(a+': ', np.equal(x_bk, x).all())

StarcoderdataJupyterScriptsDedupFiltered