|
37 | 37 |
|
38 | 38 | # Conv layer 1 output shape (32, 28, 28) |
39 | 39 | model.add(Convolution2D( |
40 | | - nb_filter=32, |
41 | | - nb_row=5, |
42 | | - nb_col=5, |
43 | | - border_mode='same', # Padding method |
44 | | - dim_ordering='th', # if use tensorflow, to set the input dimension order to theano ("th") style, but you can change it. |
45 | | - input_shape=(1, # channels |
46 | | - 28, 28,) # height & width |
| 40 | + batch_input_shape=(64, 1, 28, 28), |
| 41 | + filters=32, |
| 42 | + kernel_size=5, |
| 43 | + strides=1, |
| 44 | + padding='same', # Padding method |
| 45 | + data_format='channels_first', |
47 | 46 | )) |
48 | 47 | model.add(Activation('relu')) |
49 | 48 |
|
50 | 49 | # Pooling layer 1 (max pooling) output shape (32, 14, 14) |
51 | 50 | model.add(MaxPooling2D( |
52 | | - pool_size=(2, 2), |
53 | | - strides=(2, 2), |
54 | | - border_mode='same', # Padding method |
| 51 | + pool_size=2, |
| 52 | + strides=2, |
| 53 | + padding='same', # Padding method |
| 54 | + data_format='channels_first', |
55 | 55 | )) |
56 | 56 |
|
57 | 57 | # Conv layer 2 output shape (64, 14, 14) |
58 | | -model.add(Convolution2D(64, 5, 5, border_mode='same')) |
| 58 | +model.add(Convolution2D(64, 5, strides=1, padding='same', data_format='channels_first')) |
59 | 59 | model.add(Activation('relu')) |
60 | 60 |
|
61 | 61 | # Pooling layer 2 (max pooling) output shape (64, 7, 7) |
62 | | -model.add(MaxPooling2D(pool_size=(2, 2), border_mode='same')) |
| 62 | +model.add(MaxPooling2D(2, 2, 'same', data_format='channels_first')) |
63 | 63 |
|
64 | 64 | # Fully connected layer 1 input shape (64 * 7 * 7) = (3136), output shape (1024) |
65 | 65 | model.add(Flatten()) |
|
80 | 80 |
|
81 | 81 | print('Training ------------') |
82 | 82 | # Another way to train the model |
83 | | -model.fit(X_train, y_train, epochs=1, batch_size=32,) |
| 83 | +model.fit(X_train, y_train, epochs=1, batch_size=64,) |
84 | 84 |
|
85 | 85 | print('\nTesting ------------') |
86 | 86 | # Evaluate the model with the metrics we defined earlier |
|
0 commit comments