panik commited on
Commit
8b3f01d
1 Parent(s): dc0264f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -1
app.py CHANGED
@@ -8,4 +8,33 @@ model.add(layers.MaxPooling2D((2, 2)))
8
  model.add(layers.Conv2D(64, (3, 3), activation='relu'))
9
  model.add(layers.MaxPooling2D((2, 2)))
10
  model.add(layers.Conv2D(64, (3, 3), activation='relu'))
11
- model.summary()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  model.add(layers.Conv2D(64, (3, 3), activation='relu'))
9
  model.add(layers.MaxPooling2D((2, 2)))
10
  model.add(layers.Conv2D(64, (3, 3), activation='relu'))
11
+ #model.summary()
12
+
13
+ # add fully-connected layers at the end of the model
14
+ model.add(layers.Flatten())
15
+ model.add(layers.Dense(64, activation='relu'))
16
+ model.add(layers.Dense(10, activation='softmax'))
17
+ model.summary()
18
+
19
+ from keras.datasets import mnist
20
+ #from keras.utils import to_categorical
21
+ from tensorflow.keras.utils import to_categorical
22
+
23
+ (train_images, train_labels), (test_images, test_labels) = mnist.load_data()
24
+
25
+ train_images = train_images.reshape((60000, 28, 28, 1))
26
+ train_images = train_images.astype('float32') / 255
27
+
28
+ test_images = test_images.reshape((10000, 28, 28, 1))
29
+ test_images = test_images.astype('float32') / 255
30
+
31
+ train_labels = to_categorical(train_labels)
32
+ test_labels = to_categorical(test_labels)
33
+
34
+ # compile and train the model
35
+ model.compile(optimizer='rmsprop',
36
+ loss='categorical_crossentropy',
37
+ metrics=['accuracy'])
38
+ model.fit(train_images, train_labels, epochs=5, batch_size=64)
39
+
40
+ test_loss, test_acc = model.evaluate(test_images, test_labels)