-
Notifications
You must be signed in to change notification settings - Fork 0
/
paper_figures.py
48 lines (36 loc) · 1.13 KB
/
paper_figures.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import numpy as np
import matplotlib.pyplot as plt
import mosaic_mnist as mm
import mosaic_mnist.mnist as mnist
def show_noaxes(img):
plt.imshow(img, cmap='gray')
plt.gca().axes.xaxis.set_visible(False)
plt.gca().axes.yaxis.set_visible(False)
# Figure 1: Examples of the different configurations of Mosaic MNIST
def figure1(show=True):
idx = 626
# Original MNIST
x1,y1,x2,y2 = mnist.load()
img = x2[idx,:].reshape([28,28])
plt.subplot(1,4,1)
show_noaxes(img)
# Consistent MosNIST
images,labels = mm.load('consistent_test')
img = images[idx,:,:].squeeze()
plt.subplot(1,4,2)
show_noaxes(img)
# Inconsistent MosNIST
images,labels = mm.load('inconsistent_test') # Change this to inconsistent once files are ready
img = images[idx,:,:].squeeze()
plt.subplot(1,4,3)
show_noaxes(img)
# Malicious MosNIST
images,labels = mm.load('malicious_test')
img = images[idx,:,:].squeeze()
plt.subplot(1,4,4)
show_noaxes(img)
plt.savefig('mosaic-mnist-examples.png')
if show:
plt.show()
if __name__ == '__main__':
figure1()