-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmnist_fcc.py
More file actions
71 lines (42 loc) · 1.57 KB
/
Copy pathmnist_fcc.py
File metadata and controls
71 lines (42 loc) · 1.57 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout
from keras.optimizers import RMSprop
from keras.utils import to_categorical
# the data, shuffled and split between train and test sets
(X_train, y_train), (X_test, y_test) = mnist.load_data('/tmp/mnist.npz')
print("X_train shape:", X_train.shape)
print("X_test shape:", X_test.shape)
print("Data type:", X_train.dtype)
# Exercise 1:
# Reshape your data so that each image becomes a long vector
# Your code here
# Exercise 2:
# change the type of the input vectors to be 'float32'
# and rescale them so that the values are between 0 and 1
# Your code here:
# Exercise 3:
# convert class vectors to binary class matrices
# using the keras.utils.to_categorical function
# Your code here:
# Exercise 4:
# Define a fully connected model using the Sequential API
# https://keras.io/getting-started/sequential-model-guide/
# Choose your architecture as you please
# Your code here:
# Exercise 5:
# Compile your model using an optimizer of your choice
# make sure to display the accuracy metric
# https://keras.io/optimizers/
# Your code here:
# Exercise 6:
# Fit the model on the training data. Use 30% of the
# data as validation. Experiment with different batch sizes
# and number of epochs. Save the history of training and print it.
# Your code here:
# Exercise 7:
# Calculate the score on the test data using `model.evaluate`
# Your code here:
# Bonus Exercise:
# Modify the code to use a Convolutional Neural Network
# Hints: you'll have to reshape your data to a 4D-array...