|
@@ -27,10 +27,10 @@ x_train = x_train.reshape(x_train.shape[0], img_rows, img_cols, 1)
|
|
|
x_test = x_test.reshape(x_test.shape[0], img_rows, img_cols, 1)
|
|
|
input_shape = (img_rows, img_cols, 1)
|
|
|
|
|
|
-x_train = x_train.astype('float32')
|
|
|
-x_test = x_test.astype('float32')
|
|
|
-x_train /= 255
|
|
|
-x_test /= 255
|
|
|
+x_train = x_train.astype('int32')
|
|
|
+x_test = x_test.astype('int32')
|
|
|
+#x_train /= 255
|
|
|
+#x_test /= 255
|
|
|
print('x_train shape:', x_train.shape)
|
|
|
print(x_train.shape[0], 'train samples')
|
|
|
print(x_test.shape[0], 'test samples')
|
|
@@ -39,13 +39,13 @@ print(x_test.shape[0], 'test samples')
|
|
|
y_train = to_categorical(y_train, num_classes)
|
|
|
y_test = to_categorical(y_test, num_classes)
|
|
|
|
|
|
-a = layers.Input(shape=(28, 28, 1))
|
|
|
-b = Conv2DFPGA(2)(a)
|
|
|
-c = Conv2DFPGA(2)(a)
|
|
|
-d = Conv2DFPGA(2)(a)
|
|
|
-e = Conv2DFPGA(2)(a)
|
|
|
+a = layers.Input(dtype=tf.int32, shape=(28, 28, 1))
|
|
|
+b = Conv2DFPGA(32)(a)
|
|
|
+c = Conv2DFPGA(32)(a)
|
|
|
+d = Conv2DFPGA(2)(b)
|
|
|
+e = Conv2DFPGA(2)(c)
|
|
|
|
|
|
-x = layers.Add()([b,c,d,e])
|
|
|
+x = layers.Add()([d,e])
|
|
|
y = layers.Flatten()(x)
|
|
|
z = layers.Dense(num_classes, activation='softmax')(y)
|
|
|
|
|
@@ -63,7 +63,9 @@ model.add(Dense(num_classes, activation='softmax'))
|
|
|
model.compile(loss=keras.losses.categorical_crossentropy,
|
|
|
optimizer=keras.optimizers.Adadelta(),
|
|
|
metrics=['accuracy'])
|
|
|
-
|
|
|
+
|
|
|
+plot_model(model, to_file='model.png', expand_nested=True, show_shapes=True)
|
|
|
+
|
|
|
model.fit(x_train, y_train,
|
|
|
batch_size=batch_size,
|
|
|
epochs=epochs,
|
|
@@ -74,4 +76,3 @@ score = model.evaluate(x_test, y_test, verbose=0)
|
|
|
print('Test loss:', score[0])
|
|
|
print('Test accuracy:', score[1])
|
|
|
|
|
|
-plot_model(model, to_file='model.png', expand_nested=True, show_shapes=True)
|