Code:

from keras import Model, Input
from keras.datasets import cifar10
from keras import layers
from keras import optimizers
from keras.utils import to_categorical
import time

(train_x, train_y), (test_x, test_y) = cifar10.load_data()
train_x = train_x / 255.0
test_x = test_x / 255.0
train_y = to_categorical(train_y)
test_y = to_categorical(test_y)

head = Input(shape=(32, 32, 3,))
x = layers.Conv2D(256, 3, activation='relu', padding='same')(head)
x = layers.Conv2D(256, 3, activation='relu', padding='same')(x)
x = layers.MaxPool2D(strides=2)(x)
x = layers.Dropout(0.2)(x)

x = layers.Conv2D(128, 3, activation='relu', padding='same')(x)
x = layers.Conv2D(64, 3, activation='relu', padding='same')(x)
x = layers.MaxPool2D(strides=2)(x)
x = layers.Dropout(0.2)(x)


x = layers.Flatten()(x)
x = layers.Dense(256, activation='relu')(x)
x = layers.Dropout(0.5)(x)
x = layers.Dense(128, activation='relu')(x)
x = layers.Dense(64, activation='relu')(x)
x = layers.Dense(10)(x)
x = layers.Softmax()(x)

model = Model(head, x)

model.summary()

model.compile(optimizer=optimizers.Adam(lr=0.001, beta_1=0.9, beta_2=0.999, epsilon=1e-08), loss='categorical_crossentropy', metrics=['acc'])
start = time.time()
model.fit(train_x, train_y, batch_size=512, epochs=20)

info = model.evaluate(test_x, test_y)

print('\ncost %ds' % (time.time() - start))
print('loss = %g, acc = %g' % (info[0], info[1]))

Ps:

在colab上跑了300秒左右
最终正确率在79 %左右

12-20 15:55