Reshape dataset from fetch_mnist
MODIFY
examples/serious_mnist.py
examples/serious_mnist.py
@@ -108,6 +108,8 @@ if __name__ == "__main__":
lmbd = 0.00025
lossfn = lambda out,y: sparse_categorical_crossentropy(out, y) + lmbd*(model.weight1.abs() + model.weight2.abs()).sum()
X_train, Y_train, X_test, Y_test = fetch_mnist()
+ X_train = X_train.reshape(-1, 28, 28).astype(np.uint8)
+ X_test = X_test.reshape(-1, 28, 28).astype(np.uint8)
steps = len(X_train)//BS
np.random.seed(1337)
if QUICK:

MODIFY
extra/augment.py
extra/augment.py
@@ -20,9 +20,10 @@ def augment_img(X, rotate=10, px=3):
return Xaug
if __name__ == "__main__":
- from test_mnist import fetch_mnist
import matplotlib.pyplot as plt
X_train, Y_train, X_test, Y_test = fetch_mnist()
+ X_train = X_train.reshape(-1, 28, 28).astype(np.uint8)
+ X_test = X_test.reshape(-1, 28, 28).astype(np.uint8)
X = np.vstack([X_train[:1]]*10+[X_train[1:2]]*10)
fig, a = plt.subplots(2,len(X))
Xaug = augment_img(X)

Reshape dataset from fetch_mnist (#390)