基于路透社新闻报道主题分类任务,训练和评估一个简单的MLP(多层感知机)。
Keras使用的数据集下载(包含以下数据集)
MNIST
cifar-10-batches-py
imdb.npz、imdb_word_index.json
nietzsche.txt
reuters.npz
fra-eng
代码注释
'''Trains and evaluate a simple MLP
on the Reuters newswire topic classification task.
基于路透社新闻报道主题分类任务,训练和评估一个简单的MLP(多层感知机)。
MLP(Multi-Layer Perceptron),即多层感知器,是一种前向结构的人工神经网络,映射一组输入向量到一组输出向量。
MLP可以被看做是一个有向图,由多个节点层组成,每一层全连接到下一层。
'''
from __future__ import print_function
import numpy as np
import keras
from keras.datasets import reuters
from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation
from keras.preprocessing.text import Tokenizer
max_words = 1000
batch_size = 32
epochs = 5
print('Loading data...')
(x_train, y_train), (x_test, y_test) = reuters.load_data(num_words=max_words,
test_split=0.2)
print(len(x_train), 'train sequences')
print(len(x_test), 'test sequences')
num_classes = np.max(y_train) + 1
print(num_classes, 'classes')
print('Vectorizing sequence data...')
tokenizer = Tokenizer(num_words=max_words)
x_train = tokenizer.sequences_to_matrix(x_train, mode='binary')
x_test = tokenizer.sequences_to_matrix(x_test, mode='binary')
print('x_train shape:', x_train.shape)
print('x_test shape:', x_test.shape)
print('Convert class vector to binary class matrix '
'(for use with categorical_crossentropy)')
y_train = keras.utils.to_categorical(y_train, num_classes)
y_test = keras.utils.to_categorical(y_test, num_classes)
print('y_train shape:', y_train.shape)
print('y_test shape:', y_test.shape)
print('Building model...')
model = Sequential()
model.add(Dense(512, input_shape=(max_words,)))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(num_classes))
model.add(Activation('softmax'))
model.compile(loss='categorical_crossentropy',
optimizer='adam',
metrics=['accuracy'])
history = model.fit(x_train, y_train,
batch_size=batch_size,
epochs=epochs,
verbose=1,
validation_split=0.1)
score = model.evaluate(x_test, y_test,
batch_size=batch_size, verbose=1)
print('Test score:', score[0])
print('Test accuracy:', score[1])
代码执行
C:\ProgramData\Anaconda3\python.exe E:/keras-master/examples/reuters_mlp.py
Using TensorFlow backend.
Loading data...
8982 train sequences
2246 test sequences
46 classes
Vectorizing sequence data...
x_train shape: (8982, 1000)
x_test shape: (2246, 1000)
Convert class vector to binary class matrix (for use with categorical_crossentropy)
y_train shape: (8982, 46)
y_test shape: (2246, 46)
Building model...
Train on 8083 samples, validate on 899 samples
Epoch 1/5
32/8083 [..............................] - ETA: 4:13 - loss: 4.0334 - acc: 0.0000e+00
128/8083 [..............................] - ETA: 1:05 - loss: 3.7674 - acc: 0.0938
256/8083 [..............................] - ETA: 34s - loss: 3.4732 - acc: 0.2344
352/8083 [>.............................] - ETA: 26s - loss: 3.2942 - acc: 0.3011
448/8083 [>.............................] - ETA: 21s - loss: 3.1269 - acc: 0.3326
544/8083 [=>............................] - ETA: 18s - loss: 2.9496 - acc: 0.3603
640/8083 [=>............................] - ETA: 16s - loss: 2.8190 - acc: 0.3812
736/8083 [=>............................] - ETA: 14s - loss: 2.7076 - acc: 0.4103
832/8083 [==>...........................] - ETA: 13s - loss: 2.6083 - acc: 0.4291
928/8083 [==>...........................] - ETA: 12s - loss: 2.5429 - acc: 0.4407
1024/8083 [==>...........................] - ETA: 11s - loss: 2.4777 - acc: 0.4512
1120/8083 [===>..........................] - ETA: 10s - loss: 2.4086 - acc: 0.4643
1216/8083 [===>..........................] - ETA: 9s - loss: 2.3391 - acc: 0.4770
1312/8083 [===>..........................] - ETA: 9s - loss: 2.3032 - acc: 0.4840
1408/8083 [====>.........................] - ETA: 8s - loss: 2.2650 - acc: 0.4929
1504/8083 [====>.........................] - ETA: 8s - loss: 2.2205 - acc: 0.5060
1600/8083 [====>.........................] - ETA: 8s - loss: 2.1933 - acc: 0.5144
1696/8083 [=====>........................] - ETA: 7s - loss: 2.1661 - acc: 0.5183
1792/8083 [=====>........................] - ETA: 7s - loss: 2.1136 - acc: 0.5279
1888/8083 [======>.......................] - ETA: 7s - loss: 2.0729 - acc: 0.5371
1984/8083 [======>.......................] - ETA: 6s - loss: 2.0337 - acc: 0.5469
2080/8083 [======>.......................] - ETA: 6s - loss: 2.0334 - acc: 0.5452
2176/8083 [=======>......................] - ETA: 6s - loss: 2.0054 - acc: 0.5519
2240/8083 [=======>......................] - ETA: 6s - loss: 1.9911 - acc: 0.5527
2336/8083 [=======>......................] - ETA: 6s - loss: 1.9810 - acc: 0.5557
2432/8083 [========>.....................] - ETA: 5s - loss: 1.9668 - acc: 0.5576
2528/8083 [========>.....................] - ETA: 5s - loss: 1.9449 - acc: 0.5613
2624/8083 [========>.....................] - ETA: 5s - loss: 1.9250 - acc: 0.5659
2720/8083 [=========>....................] - ETA: 5s - loss: 1.9058 - acc: 0.5680
2816/8083 [=========>....................] - ETA: 5s - loss: 1.8853 - acc: 0.5721
2912/8083 [=========>....................] - ETA: 5s - loss: 1.8656 - acc: 0.5773
3008/8083 [==========>...................] - ETA: 4s - loss: 1.8517 - acc: 0.5805
3104/8083 [==========>...................] - ETA: 4s - loss: 1.8358 - acc: 0.5847
3200/8083 [==========>...................] - ETA: 4s - loss: 1.8247 - acc: 0.5881
3296/8083 [===========>..................] - ETA: 4s - loss: 1.8135 - acc: 0.5910
3392/8083 [===========>..................] - ETA: 4s - loss: 1.7937 - acc: 0.5958
3488/8083 [===========>..................] - ETA: 4s - loss: 1.7827 - acc: 0.5972
3584/8083 [============>.................] - ETA: 4s - loss: 1.7773 - acc: 0.5971
3680/8083 [============>.................] - ETA: 3s - loss: 1.7637 - acc: 0.6003
3776/8083 [=============>................] - ETA: 3s - loss: 1.7527 - acc: 0.6035
3872/8083 [=============>................] - ETA: 3s - loss: 1.7417 - acc: 0.6056
3968/8083 [=============>................] - ETA: 3s - loss: 1.7334 - acc: 0.6081
4064/8083 [==============>...............] - ETA: 3s - loss: 1.7197 - acc: 0.6117
4160/8083 [==============>...............] - ETA: 3s - loss: 1.7103 - acc: 0.6142
4256/8083 [==============>...............] - ETA: 3s - loss: 1.6982 - acc: 0.6172
4352/8083 [===============>..............] - ETA: 3s - loss: 1.6937 - acc: 0.6195
4448/8083 [===============>..............] - ETA: 3s - loss: 1.6904 - acc: 0.6196
4544/8083 [===============>..............] - ETA: 3s - loss: 1.6827 - acc: 0.6219
4640/8083 [================>.............] - ETA: 2s - loss: 1.6704 - acc: 0.6248
4736/8083 [================>.............] - ETA: 2s - loss: 1.6587 - acc: 0.6273
4832/8083 [================>.............] - ETA: 2s - loss: 1.6452 - acc: 0.6306
4928/8083 [=================>............] - ETA: 2s - loss: 1.6364 - acc: 0.6325
5024/8083 [=================>............] - ETA: 2s - loss: 1.6278 - acc: 0.6342
5120/8083 [==================>...........] - ETA: 2s - loss: 1.6181 - acc: 0.6363
5216/8083 [==================>...........] - ETA: 2s - loss: 1.6072 - acc: 0.6384
5312/8083 [==================>...........] - ETA: 2s - loss: 1.6039 - acc: 0.6391
5408/8083 [===================>..........] - ETA: 2s - loss: 1.5954 - acc: 0.6413
5504/8083 [===================>..........] - ETA: 2s - loss: 1.5865 - acc: 0.6423
5600/8083 [===================>..........] - ETA: 1s - loss: 1.5832 - acc: 0.6432
5696/8083 [====================>.........] - ETA: 1s - loss: 1.5755 - acc: 0.6455
5792/8083 [====================>.........] - ETA: 1s - loss: 1.5650 - acc: 0.6473
5888/8083 [====================>.........] - ETA: 1s - loss: 1.5572 - acc: 0.6491
5984/8083 [=====================>........] - ETA: 1s - loss: 1.5538 - acc: 0.6501
6080/8083 [=====================>........] - ETA: 1s - loss: 1.5452 - acc: 0.6521
6176/8083 [=====================>........] - ETA: 1s - loss: 1.5352 - acc: 0.6543
6272/8083 [======================>.......] - ETA: 1s - loss: 1.5286 - acc: 0.6559
6368/8083 [======================>.......] - ETA: 1s - loss: 1.5254 - acc: 0.6566
6464/8083 [======================>.......] - ETA: 1s - loss: 1.5119 - acc: 0.6597
6560/8083 [=======================>......] - ETA: 1s - loss: 1.5041 - acc: 0.6619
6656/8083 [=======================>......] - ETA: 1s - loss: 1.4964 - acc: 0.6633
6752/8083 [========================>.....] - ETA: 1s - loss: 1.4944 - acc: 0.6645
6848/8083 [========================>.....] - ETA: 0s - loss: 1.4859 - acc: 0.6662
6944/8083 [========================>.....] - ETA: 0s - loss: 1.4833 - acc: 0.6672
7072/8083 [=========================>....] - ETA: 0s - loss: 1.4771 - acc: 0.6690
7200/8083 [=========================>....] - ETA: 0s - loss: 1.4743 - acc: 0.6693
7328/8083 [==========================>...] - ETA: 0s - loss: 1.4662 - acc: 0.6706
7424/8083 [==========================>...] - ETA: 0s - loss: 1.4594 - acc: 0.6725
7520/8083 [==========================>...] - ETA: 0s - loss: 1.4541 - acc: 0.6733
7616/8083 [===========================>..] - ETA: 0s - loss: 1.4507 - acc: 0.6740
7712/8083 [===========================>..] - ETA: 0s - loss: 1.4480 - acc: 0.6752
7808/8083 [===========================>..] - ETA: 0s - loss: 1.4446 - acc: 0.6757
7904/8083 [============================>.] - ETA: 0s - loss: 1.4388 - acc: 0.6767
8000/8083 [============================>.] - ETA: 0s - loss: 1.4351 - acc: 0.6776
8083/8083 [==============================] - 6s 764us/step - loss: 1.4294 - acc: 0.6790 - val_loss: 1.0882 - val_acc: 0.7653
Epoch 2/5
32/8083 [..............................] - ETA: 5s - loss: 0.7124 - acc: 0.8750
128/8083 [..............................] - ETA: 5s - loss: 0.8841 - acc: 0.8047
224/8083 [..............................] - ETA: 5s - loss: 0.7674 - acc: 0.8214
320/8083 [>.............................] - ETA: 5s - loss: 0.8246 - acc: 0.8094
416/8083 [>.............................] - ETA: 5s - loss: 0.8406 - acc: 0.8053
512/8083 [>.............................] - ETA: 4s - loss: 0.7904 - acc: 0.8184
608/8083 [=>............................] - ETA: 4s - loss: 0.7585 - acc: 0.8257
704/8083 [=>............................] - ETA: 4s - loss: 0.7785 - acc: 0.8153
800/8083 [=>............................] - ETA: 4s - loss: 0.7968 - acc: 0.8150
896/8083 [==>...........................] - ETA: 4s - loss: 0.8327 - acc: 0.8103
992/8083 [==>...........................] - ETA: 4s - loss: 0.8205 - acc: 0.8115
1088/8083 [===>..........................] - ETA: 4s - loss: 0.8446 - acc: 0.8107
1184/8083 [===>..........................] - ETA: 4s - loss: 0.8434 - acc: 0.8117
1280/8083 [===>..........................] - ETA: 4s - loss: 0.8423 - acc: 0.8094
1376/8083 [====>.........................] - ETA: 3s - loss: 0.8330 - acc: 0.8096
1472/8083 [====>.........................] - ETA: 3s - loss: 0.8371 - acc: 0.8071
1568/8083 [====>.........................] - ETA: 3s - loss: 0.8473 - acc: 0.8055
1664/8083 [=====>........................] - ETA: 3s - loss: 0.8433 - acc: 0.8071
1760/8083 [=====>........................] - ETA: 3s - loss: 0.8403 - acc: 0.8097
1856/8083 [=====>........................] - ETA: 3s - loss: 0.8454 - acc: 0.8098
1952/8083 [======>.......................] - ETA: 3s - loss: 0.8421 - acc: 0.8105
2048/8083 [======>.......................] - ETA: 3s - loss: 0.8402 - acc: 0.8115
2144/8083 [======>.......................] - ETA: 3s - loss: 0.8517 - acc: 0.8088
2240/8083 [=======>......................] - ETA: 3s - loss: 0.8418 - acc: 0.8116
2336/8083 [=======>......................] - ETA: 3s - loss: 0.8375 - acc: 0.8121
2432/8083 [========>.....................] - ETA: 3s - loss: 0.8373 - acc: 0.8121
2528/8083 [========>.....................] - ETA: 3s - loss: 0.8400 - acc: 0.8105
2624/8083 [========>.....................] - ETA: 3s - loss: 0.8350 - acc: 0.8114
2720/8083 [=========>....................] - ETA: 3s - loss: 0.8348 - acc: 0.8118
2816/8083 [=========>....................] - ETA: 3s - loss: 0.8370 - acc: 0.8118
2912/8083 [=========>....................] - ETA: 3s - loss: 0.8272 - acc: 0.8139
3008/8083 [==========>...................] - ETA: 3s - loss: 0.8246 - acc: 0.8148
3104/8083 [==========>...................] - ETA: 2s - loss: 0.8219 - acc: 0.8138
3200/8083 [==========>...................] - ETA: 2s - loss: 0.8210 - acc: 0.8137
3296/8083 [===========>..................] - ETA: 2s - loss: 0.8150 - acc: 0.8152
3392/8083 [===========>..................] - ETA: 2s - loss: 0.8131 - acc: 0.8149
3488/8083 [===========>..................] - ETA: 2s - loss: 0.8131 - acc: 0.8159
3584/8083 [============>.................] - ETA: 2s - loss: 0.8129 - acc: 0.8158
3680/8083 [============>.................] - ETA: 2s - loss: 0.8192 - acc: 0.8149
3776/8083 [=============>................] - ETA: 2s - loss: 0.8221 - acc: 0.8151
3872/8083 [=============>................] - ETA: 2s - loss: 0.8258 - acc: 0.8133
3968/8083 [=============>................] - ETA: 2s - loss: 0.8252 - acc: 0.8128
4064/8083 [==============>...............] - ETA: 2s - loss: 0.8244 - acc: 0.8127
4160/8083 [==============>...............] - ETA: 2s - loss: 0.8189 - acc: 0.8130
4256/8083 [==============>...............] - ETA: 2s - loss: 0.8131 - acc: 0.8146
4352/8083 [===============>..............] - ETA: 2s - loss: 0.8100 - acc: 0.8150
4448/8083 [===============>..............] - ETA: 2s - loss: 0.8068 - acc: 0.8161
4544/8083 [===============>..............] - ETA: 2s - loss: 0.8089 - acc: 0.8156
4640/8083 [================>.............] - ETA: 2s - loss: 0.8072 - acc: 0.8157
4736/8083 [================>.............] - ETA: 1s - loss: 0.8000 - acc: 0.8165
4832/8083 [================>.............] - ETA: 1s - loss: 0.8038 - acc: 0.8156
4928/8083 [=================>............] - ETA: 1s - loss: 0.8021 - acc: 0.8155
5024/8083 [=================>............] - ETA: 1s - loss: 0.8015 - acc: 0.8159
5120/8083 [==================>...........] - ETA: 1s - loss: 0.7987 - acc: 0.8170
5216/8083 [==================>...........] - ETA: 1s - loss: 0.8014 - acc: 0.8167
5312/8083 [==================>...........] - ETA: 1s - loss: 0.8024 - acc: 0.8163
5408/8083 [===================>..........] - ETA: 1s - loss: 0.7989 - acc: 0.8168
5536/8083 [===================>..........] - ETA: 1s - loss: 0.8014 - acc: 0.8158
5664/8083 [====================>.........] - ETA: 1s - loss: 0.8051 - acc: 0.8146
5760/8083 [====================>.........] - ETA: 1s - loss: 0.8003 - acc: 0.8158
5856/8083 [====================>.........] - ETA: 1s - loss: 0.7981 - acc: 0.8171
5952/8083 [=====================>........] - ETA: 1s - loss: 0.7945 - acc: 0.8177
6048/8083 [=====================>........] - ETA: 1s - loss: 0.7908 - acc: 0.8188
6144/8083 [=====================>........] - ETA: 1s - loss: 0.7925 - acc: 0.8179
6240/8083 [======================>.......] - ETA: 1s - loss: 0.7906 - acc: 0.8183
6336/8083 [======================>.......] - ETA: 1s - loss: 0.7956 - acc: 0.8161
6432/8083 [======================>.......] - ETA: 0s - loss: 0.7954 - acc: 0.8161
6528/8083 [=======================>......] - ETA: 0s - loss: 0.7946 - acc: 0.8166
6624/8083 [=======================>......] - ETA: 0s - loss: 0.7943 - acc: 0.8172
6720/8083 [=======================>......] - ETA: 0s - loss: 0.7952 - acc: 0.8171
6816/8083 [========================>.....] - ETA: 0s - loss: 0.7957 - acc: 0.8176
6912/8083 [========================>.....] - ETA: 0s - loss: 0.7924 - acc: 0.8181
7008/8083 [=========================>....] - ETA: 0s - loss: 0.7906 - acc: 0.8186
7072/8083 [=========================>....] - ETA: 0s - loss: 0.7910 - acc: 0.8186
7168/8083 [=========================>....] - ETA: 0s - loss: 0.7887 - acc: 0.8189
7264/8083 [=========================>....] - ETA: 0s - loss: 0.7873 - acc: 0.8188
7360/8083 [==========================>...] - ETA: 0s - loss: 0.7882 - acc: 0.8183
7456/8083 [==========================>...] - ETA: 0s - loss: 0.7896 - acc: 0.8177
7520/8083 [==========================>...] - ETA: 0s - loss: 0.7902 - acc: 0.8180
7616/8083 [===========================>..] - ETA: 0s - loss: 0.7913 - acc: 0.8172
7712/8083 [===========================>..] - ETA: 0s - loss: 0.7901 - acc: 0.8174
7808/8083 [===========================>..] - ETA: 0s - loss: 0.7897 - acc: 0.8176
7904/8083 [============================>.] - ETA: 0s - loss: 0.7902 - acc: 0.8177
8000/8083 [============================>.] - ETA: 0s - loss: 0.7890 - acc: 0.8180
8083/8083 [==============================] - 5s 611us/step - loss: 0.7898 - acc: 0.8183 - val_loss: 0.9405 - val_acc: 0.7898
Epoch 3/5
32/8083 [..............................] - ETA: 4s - loss: 0.3389 - acc: 0.8438
128/8083 [..............................] - ETA: 4s - loss: 0.4424 - acc: 0.8906
224/8083 [..............................] - ETA: 4s - loss: 0.5585 - acc: 0.8661
320/8083 [>.............................] - ETA: 4s - loss: 0.5832 - acc: 0.8688
416/8083 [>.............................] - ETA: 4s - loss: 0.5746 - acc: 0.8654
512/8083 [>.............................] - ETA: 4s - loss: 0.5356 - acc: 0.8730
608/8083 [=>............................] - ETA: 4s - loss: 0.5647 - acc: 0.8668
704/8083 [=>............................] - ETA: 4s - loss: 0.5697 - acc: 0.8665
800/8083 [=>............................] - ETA: 4s - loss: 0.5659 - acc: 0.8688
896/8083 [==>...........................] - ETA: 4s - loss: 0.5861 - acc: 0.8571
992/8083 [==>...........................] - ETA: 4s - loss: 0.5851 - acc: 0.8599
1088/8083 [===>..........................] - ETA: 4s - loss: 0.5778 - acc: 0.8640
1184/8083 [===>..........................] - ETA: 4s - loss: 0.5759 - acc: 0.8640
1280/8083 [===>..........................] - ETA: 4s - loss: 0.5731 - acc: 0.8656
1376/8083 [====>.........................] - ETA: 4s - loss: 0.5688 - acc: 0.8648
1472/8083 [====>.........................] - ETA: 4s - loss: 0.5546 - acc: 0.8682
1568/8083 [====>.........................] - ETA: 3s - loss: 0.5594 - acc: 0.8642
1664/8083 [=====>........................] - ETA: 3s - loss: 0.5556 - acc: 0.8654
1760/8083 [=====>........................] - ETA: 3s - loss: 0.5655 - acc: 0.8659
1856/8083 [=====>........................] - ETA: 3s - loss: 0.5628 - acc: 0.8658
1952/8083 [======>.......................] - ETA: 3s - loss: 0.5562 - acc: 0.8673
2048/8083 [======>.......................] - ETA: 3s - loss: 0.5507 - acc: 0.8672
2144/8083 [======>.......................] - ETA: 3s - loss: 0.5538 - acc: 0.8680
2240/8083 [=======>......................] - ETA: 3s - loss: 0.5484 - acc: 0.8696
2336/8083 [=======>......................] - ETA: 3s - loss: 0.5522 - acc: 0.8694
2432/8083 [========>.....................] - ETA: 3s - loss: 0.5514 - acc: 0.8701
2528/8083 [========>.....................] - ETA: 3s - loss: 0.5504 - acc: 0.8691
2624/8083 [========>.....................] - ETA: 3s - loss: 0.5494 - acc: 0.8689
2720/8083 [=========>....................] - ETA: 3s - loss: 0.5515 - acc: 0.8676
2816/8083 [=========>....................] - ETA: 3s - loss: 0.5472 - acc: 0.8683
2912/8083 [=========>....................] - ETA: 3s - loss: 0.5532 - acc: 0.8661
3008/8083 [==========>...................] - ETA: 3s - loss: 0.5492 - acc: 0.8674
3104/8083 [==========>...................] - ETA: 2s - loss: 0.5532 - acc: 0.8660
3200/8083 [==========>...................] - ETA: 2s - loss: 0.5526 - acc: 0.8666
3296/8083 [===========>..................] - ETA: 2s - loss: 0.5538 - acc: 0.8665
3392/8083 [===========>..................] - ETA: 2s - loss: 0.5571 - acc: 0.8662
3488/8083 [===========>..................] - ETA: 2s - loss: 0.5584 - acc: 0.8661
3584/8083 [============>.................] - ETA: 2s - loss: 0.5527 - acc: 0.8675
3680/8083 [============>.................] - ETA: 2s - loss: 0.5502 - acc: 0.8682
3776/8083 [=============>................] - ETA: 2s - loss: 0.5459 - acc: 0.8694
3872/8083 [=============>................] - ETA: 2s - loss: 0.5454 - acc: 0.8688
3968/8083 [=============>................] - ETA: 2s - loss: 0.5411 - acc: 0.8700
4096/8083 [==============>...............] - ETA: 2s - loss: 0.5456 - acc: 0.8684
4192/8083 [==============>...............] - ETA: 2s - loss: 0.5451 - acc: 0.8683
4320/8083 [===============>..............] - ETA: 2s - loss: 0.5419 - acc: 0.8692
4448/8083 [===============>..............] - ETA: 2s - loss: 0.5440 - acc: 0.8680
4544/8083 [===============>..............] - ETA: 2s - loss: 0.5453 - acc: 0.8675
4640/8083 [================>.............] - ETA: 2s - loss: 0.5440 - acc: 0.8677
4736/8083 [================>.............] - ETA: 1s - loss: 0.5447 - acc: 0.8680
4832/8083 [================>.............] - ETA: 1s - loss: 0.5450 - acc: 0.8688
4928/8083 [=================>............] - ETA: 1s - loss: 0.5469 - acc: 0.8687
5024/8083 [=================>............] - ETA: 1s - loss: 0.5469 - acc: 0.8680
5120/8083 [==================>...........] - ETA: 1s - loss: 0.5474 - acc: 0.8680
5216/8083 [==================>...........] - ETA: 1s - loss: 0.5506 - acc: 0.8660
5312/8083 [==================>...........] - ETA: 1s - loss: 0.5535 - acc: 0.8641
5408/8083 [===================>..........] - ETA: 1s - loss: 0.5530 - acc: 0.8643
5504/8083 [===================>..........] - ETA: 1s - loss: 0.5530 - acc: 0.8643
5600/8083 [===================>..........] - ETA: 1s - loss: 0.5518 - acc: 0.8650
5696/8083 [====================>.........] - ETA: 1s - loss: 0.5502 - acc: 0.8653
5760/8083 [====================>.........] - ETA: 1s - loss: 0.5476 - acc: 0.8658
5856/8083 [====================>.........] - ETA: 1s - loss: 0.5526 - acc: 0.8648
5952/8083 [=====================>........] - ETA: 1s - loss: 0.5510 - acc: 0.8656
6048/8083 [=====================>........] - ETA: 1s - loss: 0.5520 - acc: 0.8652
6144/8083 [=====================>........] - ETA: 1s - loss: 0.5517 - acc: 0.8647
6240/8083 [======================>.......] - ETA: 1s - loss: 0.5503 - acc: 0.8649
6336/8083 [======================>.......] - ETA: 1s - loss: 0.5498 - acc: 0.8647
6432/8083 [======================>.......] - ETA: 0s - loss: 0.5496 - acc: 0.8646
6528/8083 [=======================>......] - ETA: 0s - loss: 0.5498 - acc: 0.8641
6592/8083 [=======================>......] - ETA: 0s - loss: 0.5475 - acc: 0.8650
6688/8083 [=======================>......] - ETA: 0s - loss: 0.5510 - acc: 0.8644
6784/8083 [========================>.....] - ETA: 0s - loss: 0.5497 - acc: 0.8645
6880/8083 [========================>.....] - ETA: 0s - loss: 0.5501 - acc: 0.8648
6976/8083 [========================>.....] - ETA: 0s - loss: 0.5488 - acc: 0.8650
7072/8083 [=========================>....] - ETA: 0s - loss: 0.5481 - acc: 0.8651
7168/8083 [=========================>....] - ETA: 0s - loss: 0.5495 - acc: 0.8650
7264/8083 [=========================>....] - ETA: 0s - loss: 0.5495 - acc: 0.8651
7360/8083 [==========================>...] - ETA: 0s - loss: 0.5485 - acc: 0.8652
7456/8083 [==========================>...] - ETA: 0s - loss: 0.5479 - acc: 0.8651
7552/8083 [===========================>..] - ETA: 0s - loss: 0.5487 - acc: 0.8644
7648/8083 [===========================>..] - ETA: 0s - loss: 0.5473 - acc: 0.8644
7744/8083 [===========================>..] - ETA: 0s - loss: 0.5478 - acc: 0.8642
7840/8083 [============================>.] - ETA: 0s - loss: 0.5488 - acc: 0.8638
7936/8083 [============================>.] - ETA: 0s - loss: 0.5500 - acc: 0.8638
8032/8083 [============================>.] - ETA: 0s - loss: 0.5490 - acc: 0.8640
8083/8083 [==============================] - 5s 620us/step - loss: 0.5504 - acc: 0.8638 - val_loss: 0.8922 - val_acc: 0.7964
Epoch 4/5
32/8083 [..............................] - ETA: 4s - loss: 0.2811 - acc: 0.9375
128/8083 [..............................] - ETA: 4s - loss: 0.3770 - acc: 0.9062
224/8083 [..............................] - ETA: 4s - loss: 0.3453 - acc: 0.9062
320/8083 [>.............................] - ETA: 4s - loss: 0.3930 - acc: 0.8906
416/8083 [>.............................] - ETA: 4s - loss: 0.4034 - acc: 0.8870
512/8083 [>.............................] - ETA: 4s - loss: 0.4199 - acc: 0.8848
608/8083 [=>............................] - ETA: 4s - loss: 0.4016 - acc: 0.8898
704/8083 [=>............................] - ETA: 4s - loss: 0.3962 - acc: 0.8935
800/8083 [=>............................] - ETA: 4s - loss: 0.4286 - acc: 0.8925
896/8083 [==>...........................] - ETA: 4s - loss: 0.4078 - acc: 0.9007
992/8083 [==>...........................] - ETA: 4s - loss: 0.4029 - acc: 0.9022
1088/8083 [===>..........................] - ETA: 4s - loss: 0.4140 - acc: 0.8980
1184/8083 [===>..........................] - ETA: 4s - loss: 0.4148 - acc: 0.8986
1280/8083 [===>..........................] - ETA: 4s - loss: 0.4089 - acc: 0.8984
1376/8083 [====>.........................] - ETA: 4s - loss: 0.4141 - acc: 0.8975
1472/8083 [====>.........................] - ETA: 4s - loss: 0.4042 - acc: 0.9008
1600/8083 [====>.........................] - ETA: 3s - loss: 0.4074 - acc: 0.9006
1728/8083 [=====>........................] - ETA: 3s - loss: 0.4068 - acc: 0.8993
1824/8083 [=====>........................] - ETA: 3s - loss: 0.4127 - acc: 0.8975
1920/8083 [======>.......................] - ETA: 3s - loss: 0.4045 - acc: 0.9010
2016/8083 [======>.......................] - ETA: 3s - loss: 0.4104 - acc: 0.8988
2112/8083 [======>.......................] - ETA: 3s - loss: 0.4042 - acc: 0.9001
2208/8083 [=======>......................] - ETA: 3s - loss: 0.3996 - acc: 0.9008
2304/8083 [=======>......................] - ETA: 3s - loss: 0.3975 - acc: 0.9015
2400/8083 [=======>......................] - ETA: 3s - loss: 0.3953 - acc: 0.9017
2496/8083 [========>.....................] - ETA: 3s - loss: 0.3929 - acc: 0.9014
2592/8083 [========>.....................] - ETA: 3s - loss: 0.3910 - acc: 0.9020
2688/8083 [========>.....................] - ETA: 3s - loss: 0.3918 - acc: 0.9010
2784/8083 [=========>....................] - ETA: 3s - loss: 0.3904 - acc: 0.9012
2880/8083 [=========>....................] - ETA: 3s - loss: 0.3911 - acc: 0.9010
2976/8083 [==========>...................] - ETA: 3s - loss: 0.3896 - acc: 0.9005
3072/8083 [==========>...................] - ETA: 3s - loss: 0.3914 - acc: 0.9007
3168/8083 [==========>...................] - ETA: 2s - loss: 0.3927 - acc: 0.9003
3264/8083 [===========>..................] - ETA: 2s - loss: 0.3877 - acc: 0.9017
3360/8083 [===========>..................] - ETA: 2s - loss: 0.3838 - acc: 0.9030
3456/8083 [===========>..................] - ETA: 2s - loss: 0.3891 - acc: 0.9016
3552/8083 [============>.................] - ETA: 2s - loss: 0.3878 - acc: 0.9020
3648/8083 [============>.................] - ETA: 2s - loss: 0.3906 - acc: 0.9010
3744/8083 [============>.................] - ETA: 2s - loss: 0.3900 - acc: 0.9009
3840/8083 [=============>................] - ETA: 2s - loss: 0.3843 - acc: 0.9026
3936/8083 [=============>................] - ETA: 2s - loss: 0.3836 - acc: 0.9024
4032/8083 [=============>................] - ETA: 2s - loss: 0.3896 - acc: 0.9013
4128/8083 [==============>...............] - ETA: 2s - loss: 0.3875 - acc: 0.9021
4224/8083 [==============>...............] - ETA: 2s - loss: 0.3862 - acc: 0.9015
4320/8083 [===============>..............] - ETA: 2s - loss: 0.3874 - acc: 0.9016
4416/8083 [===============>..............] - ETA: 2s - loss: 0.3901 - acc: 0.9013
4512/8083 [===============>..............] - ETA: 2s - loss: 0.3894 - acc: 0.9020
4608/8083 [================>.............] - ETA: 2s - loss: 0.3908 - acc: 0.9021
4704/8083 [================>.............] - ETA: 2s - loss: 0.3912 - acc: 0.9018
4800/8083 [================>.............] - ETA: 2s - loss: 0.3896 - acc: 0.9019
4896/8083 [=================>............] - ETA: 1s - loss: 0.3884 - acc: 0.9020
4992/8083 [=================>............] - ETA: 1s - loss: 0.3956 - acc: 0.9004
5088/8083 [=================>............] - ETA: 1s - loss: 0.3939 - acc: 0.9011
5184/8083 [==================>...........] - ETA: 1s - loss: 0.3902 - acc: 0.9022
5280/8083 [==================>...........] - ETA: 1s - loss: 0.3929 - acc: 0.9011
5376/8083 [==================>...........] - ETA: 1s - loss: 0.3954 - acc: 0.9012
5472/8083 [===================>..........] - ETA: 1s - loss: 0.3963 - acc: 0.9013
5568/8083 [===================>..........] - ETA: 1s - loss: 0.3950 - acc: 0.9012
5664/8083 [====================>.........] - ETA: 1s - loss: 0.3965 - acc: 0.9008
5760/8083 [====================>.........] - ETA: 1s - loss: 0.4030 - acc: 0.9003
5856/8083 [====================>.........] - ETA: 1s - loss: 0.4034 - acc: 0.9001
5952/8083 [=====================>........] - ETA: 1s - loss: 0.4018 - acc: 0.9002
6048/8083 [=====================>........] - ETA: 1s - loss: 0.4028 - acc: 0.9001
6144/8083 [=====================>........] - ETA: 1s - loss: 0.4067 - acc: 0.8991
6240/8083 [======================>.......] - ETA: 1s - loss: 0.4065 - acc: 0.8984
6336/8083 [======================>.......] - ETA: 1s - loss: 0.4067 - acc: 0.8984
6432/8083 [======================>.......] - ETA: 1s - loss: 0.4054 - acc: 0.8985
6528/8083 [=======================>......] - ETA: 0s - loss: 0.4066 - acc: 0.8986
6624/8083 [=======================>......] - ETA: 0s - loss: 0.4089 - acc: 0.8984
6720/8083 [=======================>......] - ETA: 0s - loss: 0.4097 - acc: 0.8981
6816/8083 [========================>.....] - ETA: 0s - loss: 0.4094 - acc: 0.8980
6912/8083 [========================>.....] - ETA: 0s - loss: 0.4094 - acc: 0.8987
7008/8083 [=========================>....] - ETA: 0s - loss: 0.4109 - acc: 0.8981
7104/8083 [=========================>....] - ETA: 0s - loss: 0.4113 - acc: 0.8984
7200/8083 [=========================>....] - ETA: 0s - loss: 0.4142 - acc: 0.8969
7296/8083 [==========================>...] - ETA: 0s - loss: 0.4124 - acc: 0.8975
7392/8083 [==========================>...] - ETA: 0s - loss: 0.4140 - acc: 0.8975
7488/8083 [==========================>...] - ETA: 0s - loss: 0.4163 - acc: 0.8969
7584/8083 [===========================>..] - ETA: 0s - loss: 0.4173 - acc: 0.8968
7680/8083 [===========================>..] - ETA: 0s - loss: 0.4174 - acc: 0.8965
7808/8083 [===========================>..] - ETA: 0s - loss: 0.4185 - acc: 0.8959
7936/8083 [============================>.] - ETA: 0s - loss: 0.4186 - acc: 0.8963
8064/8083 [============================>.] - ETA: 0s - loss: 0.4155 - acc: 0.8973
8083/8083 [==============================] - 5s 626us/step - loss: 0.4159 - acc: 0.8973 - val_loss: 0.8845 - val_acc: 0.8076
Epoch 5/5
32/8083 [..............................] - ETA: 5s - loss: 0.1721 - acc: 0.9688
128/8083 [..............................] - ETA: 4s - loss: 0.2283 - acc: 0.9531
224/8083 [..............................] - ETA: 4s - loss: 0.3462 - acc: 0.9152
320/8083 [>.............................] - ETA: 4s - loss: 0.3501 - acc: 0.9156
416/8083 [>.............................] - ETA: 4s - loss: 0.3644 - acc: 0.9087
512/8083 [>.............................] - ETA: 4s - loss: 0.3662 - acc: 0.9062
608/8083 [=>............................] - ETA: 4s - loss: 0.3662 - acc: 0.9062
704/8083 [=>............................] - ETA: 4s - loss: 0.3625 - acc: 0.9091
800/8083 [=>............................] - ETA: 4s - loss: 0.3581 - acc: 0.9150
896/8083 [==>...........................] - ETA: 4s - loss: 0.3648 - acc: 0.9118
992/8083 [==>...........................] - ETA: 4s - loss: 0.3500 - acc: 0.9163
1088/8083 [===>..........................] - ETA: 4s - loss: 0.3475 - acc: 0.9182
1152/8083 [===>..........................] - ETA: 4s - loss: 0.3417 - acc: 0.9184
1248/8083 [===>..........................] - ETA: 4s - loss: 0.3344 - acc: 0.9199
1344/8083 [===>..........................] - ETA: 4s - loss: 0.3267 - acc: 0.9211
1440/8083 [====>.........................] - ETA: 4s - loss: 0.3182 - acc: 0.9243
1536/8083 [====>.........................] - ETA: 4s - loss: 0.3102 - acc: 0.9264
1632/8083 [=====>........................] - ETA: 4s - loss: 0.3057 - acc: 0.9283
1728/8083 [=====>........................] - ETA: 4s - loss: 0.3031 - acc: 0.9282
1824/8083 [=====>........................] - ETA: 3s - loss: 0.3088 - acc: 0.9276
1888/8083 [======>.......................] - ETA: 3s - loss: 0.3167 - acc: 0.9258
1952/8083 [======>.......................] - ETA: 3s - loss: 0.3118 - acc: 0.9267
2048/8083 [======>.......................] - ETA: 3s - loss: 0.3135 - acc: 0.9263
2144/8083 [======>.......................] - ETA: 3s - loss: 0.3079 - acc: 0.9277
2208/8083 [=======>......................] - ETA: 3s - loss: 0.3046 - acc: 0.9293
2304/8083 [=======>......................] - ETA: 3s - loss: 0.3022 - acc: 0.9301
2400/8083 [=======>......................] - ETA: 3s - loss: 0.2981 - acc: 0.9304
2496/8083 [========>.....................] - ETA: 3s - loss: 0.3026 - acc: 0.9287
2592/8083 [========>.....................] - ETA: 3s - loss: 0.3036 - acc: 0.9286
2688/8083 [========>.....................] - ETA: 3s - loss: 0.3041 - acc: 0.9282
2784/8083 [=========>....................] - ETA: 3s - loss: 0.3063 - acc: 0.9267
2880/8083 [=========>....................] - ETA: 3s - loss: 0.3086 - acc: 0.9247
2976/8083 [==========>...................] - ETA: 3s - loss: 0.3057 - acc: 0.9251
3072/8083 [==========>...................] - ETA: 3s - loss: 0.3009 - acc: 0.9268
3168/8083 [==========>...................] - ETA: 3s - loss: 0.3024 - acc: 0.9261
3264/8083 [===========>..................] - ETA: 3s - loss: 0.3020 - acc: 0.9262
3360/8083 [===========>..................] - ETA: 3s - loss: 0.2982 - acc: 0.9274
3456/8083 [===========>..................] - ETA: 2s - loss: 0.2991 - acc: 0.9259
3552/8083 [============>.................] - ETA: 2s - loss: 0.3035 - acc: 0.9245
3616/8083 [============>.................] - ETA: 2s - loss: 0.3050 - acc: 0.9242
3712/8083 [============>.................] - ETA: 2s - loss: 0.3037 - acc: 0.9248
3808/8083 [=============>................] - ETA: 2s - loss: 0.3018 - acc: 0.9254
3840/8083 [=============>................] - ETA: 2s - loss: 0.3024 - acc: 0.9250
3904/8083 [=============>................] - ETA: 2s - loss: 0.3043 - acc: 0.9244
4000/8083 [=============>................] - ETA: 2s - loss: 0.3076 - acc: 0.9233
4096/8083 [==============>...............] - ETA: 2s - loss: 0.3098 - acc: 0.9231
4192/8083 [==============>...............] - ETA: 2s - loss: 0.3101 - acc: 0.9232
4288/8083 [==============>...............] - ETA: 2s - loss: 0.3098 - acc: 0.9233
4384/8083 [===============>..............] - ETA: 2s - loss: 0.3132 - acc: 0.9220
4480/8083 [===============>..............] - ETA: 2s - loss: 0.3134 - acc: 0.9223
4576/8083 [===============>..............] - ETA: 2s - loss: 0.3117 - acc: 0.9229
4672/8083 [================>.............] - ETA: 2s - loss: 0.3088 - acc: 0.9238
4768/8083 [================>.............] - ETA: 2s - loss: 0.3108 - acc: 0.9230
4864/8083 [=================>............] - ETA: 2s - loss: 0.3096 - acc: 0.9229
4960/8083 [=================>............] - ETA: 2s - loss: 0.3094 - acc: 0.9228
5056/8083 [=================>............] - ETA: 1s - loss: 0.3086 - acc: 0.9227
5152/8083 [==================>...........] - ETA: 1s - loss: 0.3071 - acc: 0.9226
5248/8083 [==================>...........] - ETA: 1s - loss: 0.3098 - acc: 0.9219
5344/8083 [==================>...........] - ETA: 1s - loss: 0.3078 - acc: 0.9222
5440/8083 [===================>..........] - ETA: 1s - loss: 0.3091 - acc: 0.9217
5536/8083 [===================>..........] - ETA: 1s - loss: 0.3090 - acc: 0.9218
5632/8083 [===================>..........] - ETA: 1s - loss: 0.3084 - acc: 0.9222
5728/8083 [====================>.........] - ETA: 1s - loss: 0.3074 - acc: 0.9228
5856/8083 [====================>.........] - ETA: 1s - loss: 0.3069 - acc: 0.9226
5984/8083 [=====================>........] - ETA: 1s - loss: 0.3065 - acc: 0.9228
6080/8083 [=====================>........] - ETA: 1s - loss: 0.3088 - acc: 0.9225
6176/8083 [=====================>........] - ETA: 1s - loss: 0.3103 - acc: 0.9223
6272/8083 [======================>.......] - ETA: 1s - loss: 0.3110 - acc: 0.9219
6368/8083 [======================>.......] - ETA: 1s - loss: 0.3102 - acc: 0.9221
6464/8083 [======================>.......] - ETA: 1s - loss: 0.3102 - acc: 0.9217
6560/8083 [=======================>......] - ETA: 0s - loss: 0.3123 - acc: 0.9215
6656/8083 [=======================>......] - ETA: 0s - loss: 0.3157 - acc: 0.9207
6752/8083 [========================>.....] - ETA: 0s - loss: 0.3153 - acc: 0.9208
6848/8083 [========================>.....] - ETA: 0s - loss: 0.3157 - acc: 0.9203
6944/8083 [========================>.....] - ETA: 0s - loss: 0.3168 - acc: 0.9202
7040/8083 [=========================>....] - ETA: 0s - loss: 0.3181 - acc: 0.9197
7136/8083 [=========================>....] - ETA: 0s - loss: 0.3185 - acc: 0.9197
7232/8083 [=========================>....] - ETA: 0s - loss: 0.3213 - acc: 0.9191
7328/8083 [==========================>...] - ETA: 0s - loss: 0.3215 - acc: 0.9188
7392/8083 [==========================>...] - ETA: 0s - loss: 0.3215 - acc: 0.9188
7488/8083 [==========================>...] - ETA: 0s - loss: 0.3197 - acc: 0.9195
7584/8083 [===========================>..] - ETA: 0s - loss: 0.3187 - acc: 0.9196
7680/8083 [===========================>..] - ETA: 0s - loss: 0.3177 - acc: 0.9201
7776/8083 [===========================>..] - ETA: 0s - loss: 0.3199 - acc: 0.9195
7872/8083 [============================>.] - ETA: 0s - loss: 0.3242 - acc: 0.9183
7968/8083 [============================>.] - ETA: 0s - loss: 0.3248 - acc: 0.9180
8064/8083 [============================>.] - ETA: 0s - loss: 0.3243 - acc: 0.9183
8083/8083 [==============================] - 5s 664us/step - loss: 0.3254 - acc: 0.9181 - val_loss: 0.9151 - val_acc: 0.7987
32/2246 [..............................] - ETA: 0s
384/2246 [====>.........................] - ETA: 0s
704/2246 [========>.....................] - ETA: 0s
1056/2246 [=============>................] - ETA: 0s
1408/2246 [=================>............] - ETA: 0s
1728/2246 [======================>.......] - ETA: 0s
2080/2246 [==========================>...] - ETA: 0s
2246/2246 [==============================] - 0s 152us/step
Test score: 0.8895948799401654
Test accuracy: 0.7929652715939448
Process finished with exit code 0
Keras详细介绍
中文:http://keras-cn.readthedocs.io/en/latest/
实例下载
https://github.com/keras-team/keras
https://github.com/keras-team/keras/tree/master/examples
完整项目下载
方便没积分童鞋,请加企鹅452205574,共享文件夹。
包括:代码、数据集合(图片)、已生成model、安装库文件等。