| 23 | |
| 24 | |
| 25 | def load_mnist(size=64): |
| 26 | (train_data, train_labels), (test_data, test_labels) = mnist.load_data() |
| 27 | train_data = normalize(train_data) |
| 28 | test_data = normalize(test_data) |
| 29 | print(train_data.shape) |
| 30 | x = np.concatenate((train_data, test_data), axis=0) |
| 31 | print(x.shape) |
| 32 | # y = np.concatenate((train_labels, test_labels), axis=0).astype(np.int) |
| 33 | |
| 34 | seed = 777 |
| 35 | np.random.seed(seed) |
| 36 | np.random.shuffle(x) |
| 37 | # np.random.seed(seed) |
| 38 | # np.random.shuffle(y) |
| 39 | # x = np.expand_dims(x, axis=-1) |
| 40 | print(x.shape) |
| 41 | |
| 42 | x = np.asarray([scipy.misc.imresize(x_img, [size, size]) for x_img in x]) |
| 43 | x = np.expand_dims(x, axis=-1) |
| 44 | print(x.shape) |
| 45 | return x |
| 46 | |
| 47 | def load_cifar10(size=64) : |
| 48 | (train_data, train_labels), (test_data, test_labels) = cifar10.load_data() |