DL之Attention:基于ClutteredMNIST手写数字图片数据集分别利用CNN_Init、ST_CNN算法(CNN+SpatialTransformer)实现多分类预测

DL之Attention:基于ClutteredMNIST手写数字图片数据集分别利用CNN_Init、ST_CNN算法(CNN+SpatialTransformer)实现多分类预测

 

 

 

 

 

目录

基于ClutteredMNIST手写数字图片数据集分别利用CNN_Init、ST_CNN算法(CNN+SpatialTransformer)实现多分类预测

数据特征工程

T1、CNN_Init start

输出结果

核心代码

T2、ST_CNN start

核心代码


 

 

 

相关文章
DL之Attention:基于ClutteredMNIST手写数字图片数据集分别利用CNN_Init、ST_CNN算法(CNN+SpatialTransformer)实现多分类预测
DL之Attention:基于ClutteredMNIST手写数字图片数据集分别利用CNN_Init、ST_CNN算法(CNN+SpatialTransformer)实现多分类预测实现

 

基于ClutteredMNIST手写数字图片数据集分别利用CNN_Init、ST_CNN算法(CNN+SpatialTransformer)实现多分类预测

数据特征工程

Train samples: (50000, 60, 60, 1)
Validation samples: (10000, 60, 60, 1)
Test samples: (10000, 60, 60, 1)
Input shape: (60, 60, 1)

 

T1、CNN_Init start

输出结果

T1、CNN_Init start!
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_1 (Conv2D)            (None, 58, 58, 32)        320       
_________________________________________________________________
conv2d_2 (Conv2D)            (None, 56, 56, 64)        18496     
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 28, 28, 64)        0         
_________________________________________________________________
conv2d_3 (Conv2D)            (None, 26, 26, 64)        36928     
_________________________________________________________________
max_pooling2d_2 (MaxPooling2 (None, 13, 13, 64)        0         
_________________________________________________________________
conv2d_4 (Conv2D)            (None, 11, 11, 64)        36928     
_________________________________________________________________
dropout_1 (Dropout)          (None, 11, 11, 64)        0         
_________________________________________________________________
flatten_1 (Flatten)          (None, 7744)              0         
_________________________________________________________________
dense_1 (Dense)              (None, 128)               991360    
_________________________________________________________________
dropout_2 (Dropout)          (None, 128)               0         
_________________________________________________________________
dense_2 (Dense)              (None, 10)                1290      
=================================================================
Total params: 1,085,322
Trainable params: 1,085,322
Non-trainable params: 0
_________________________________________________________________
None
Train on 50000 samples, validate on 10000 samples
Epoch 1/30

核心代码

    #(1)、定义模型结构
    model = Sequential()
    model.add(Conv2D(32, kernel_size=(3, 3),
                     activation='relu',
                     input_shape=input_shape))
    model.add(Conv2D(64, (3, 3), activation='relu'))
    model.add(MaxPooling2D(pool_size=(2, 2)))
    model.add(Conv2D(64, kernel_size=(3, 3),
                     activation='relu'))
    model.add(MaxPooling2D(pool_size=(2, 2)))
    model.add(Conv2D(64, (3, 3), activation='relu'))
    model.add(Dropout(0.25))
    model.add(Flatten())
    model.add(Dense(128, activation='relu'))
    model.add(Dropout(0.5))
    model.add(Dense(nb_classes, activation='softmax'))

 

 

 

 

 

T2、ST_CNN start

_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_1 (Conv2D)            (None, 56, 56, 32)        832       
_________________________________________________________________
activation_1 (Activation)    (None, 56, 56, 32)        0         
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 28, 28, 32)        0         
_________________________________________________________________
conv2d_2 (Conv2D)            (None, 24, 24, 64)        51264     
_________________________________________________________________
activation_2 (Activation)    (None, 24, 24, 64)        0         
_________________________________________________________________
conv2d_3 (Conv2D)            (None, 22, 22, 64)        36928     
_________________________________________________________________
activation_3 (Activation)    (None, 22, 22, 64)        0         
_________________________________________________________________
max_pooling2d_2 (MaxPooling2 (None, 11, 11, 64)        0         
_________________________________________________________________
flatten_1 (Flatten)          (None, 7744)              0         
_________________________________________________________________
dense_1 (Dense)              (None, 50)                387250    
_________________________________________________________________
activation_4 (Activation)    (None, 50)                0         
_________________________________________________________________
dense_2 (Dense)              (None, 6)                 306       
=================================================================
Total params: 476,580
Trainable params: 476,580
Non-trainable params: 0
_________________________________________________________________
None
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
spatial_transformer_1 (Spati (None, 30, 30, 1)         476580    
_________________________________________________________________
conv2d_4 (Conv2D)            (None, 28, 28, 32)        320       
_________________________________________________________________
dropout_1 (Dropout)          (None, 28, 28, 32)        0         
_________________________________________________________________
conv2d_5 (Conv2D)            (None, 26, 26, 64)        18496     
_________________________________________________________________
dropout_2 (Dropout)          (None, 26, 26, 64)        0         
_________________________________________________________________
max_pooling2d_3 (MaxPooling2 (None, 13, 13, 64)        0         
_________________________________________________________________
conv2d_6 (Conv2D)            (None, 11, 11, 64)        36928     
_________________________________________________________________
dropout_3 (Dropout)          (None, 11, 11, 64)        0         
_________________________________________________________________
max_pooling2d_4 (MaxPooling2 (None, 5, 5, 64)          0         
_________________________________________________________________
flatten_2 (Flatten)          (None, 1600)              0         
_________________________________________________________________
dense_3 (Dense)              (None, 256)               409856    
_________________________________________________________________
dropout_4 (Dropout)          (None, 256)               0         
_________________________________________________________________
activation_5 (Activation)    (None, 256)               0         
_________________________________________________________________
dense_4 (Dense)              (None, 10)                2570      
_________________________________________________________________
activation_6 (Activation)    (None, 10)                0         
=================================================================
Total params: 944,750
Trainable params: 944,750
Non-trainable params: 0
_________________________________________________________________
None
Train on 50000 samples, validate on 10000 samples
Epoch 1/30
 - 974s - loss: 2.0926 - categorical_accuracy: 0.2345 - val_loss: 1.6258 - val_categorical_accuracy: 0.5949
Epoch 2/30
 - 1007s - loss: 1.0926 - categorical_accuracy: 0.6387 - val_loss: 0.7963 - val_categorical_accuracy: 0.8433
Epoch 3/30
 - 844s - loss: 0.6038 - categorical_accuracy: 0.8118 - val_loss: 0.4906 - val_categorical_accuracy: 0.8977
Epoch 4/30
 - 851s - loss: 0.4351 - categorical_accuracy: 0.8648 - val_loss: 0.3909 - val_categorical_accuracy: 0.9160
Epoch 5/30
 - 864s - loss: 0.3483 - categorical_accuracy: 0.8914 - val_loss: 0.3046 - val_categorical_accuracy: 0.9367
Epoch 6/30
 - 872s - loss: 0.3158 - categorical_accuracy: 0.9027 - val_loss: 0.2826 - val_categorical_accuracy: 0.9349
Epoch 7/30
 - 861s - loss: 0.2772 - categorical_accuracy: 0.9136 - val_loss: 0.3244 - val_categorical_accuracy: 0.9243
Epoch 8/30
 - 862s - loss: 0.2414 - categorical_accuracy: 0.9251 - val_loss: 0.2228 - val_categorical_accuracy: 0.9600
Epoch 9/30
 - 858s - loss: 0.2278 - categorical_accuracy: 0.9287 - val_loss: 0.2305 - val_categorical_accuracy: 0.9556
Epoch 10/30
 - 860s - loss: 0.2150 - categorical_accuracy: 0.9328 - val_loss: 0.2119 - val_categorical_accuracy: 0.9600
Epoch 11/30
 - 862s - loss: 0.2130 - categorical_accuracy: 0.9334 - val_loss: 0.1949 - val_categorical_accuracy: 0.9583
Epoch 12/30
 - 855s - loss: 0.1917 - categorical_accuracy: 0.9410 - val_loss: 0.1841 - val_categorical_accuracy: 0.9595
Epoch 13/30
 - 857s - loss: 0.1891 - categorical_accuracy: 0.9414 - val_loss: 0.2455 - val_categorical_accuracy: 0.9613
Epoch 14/30
 - 862s - loss: 0.1865 - categorical_accuracy: 0.9423 - val_loss: 0.2044 - val_categorical_accuracy: 0.9629
Epoch 15/30
 - 863s - loss: 0.1789 - categorical_accuracy: 0.9446 - val_loss: 0.2147 - val_categorical_accuracy: 0.9647
Epoch 16/30
 - 855s - loss: 0.1708 - categorical_accuracy: 0.9460 - val_loss: 0.1748 - val_categorical_accuracy: 0.9692
Epoch 17/30
 - 859s - loss: 0.1615 - categorical_accuracy: 0.9509 - val_loss: 0.1870 - val_categorical_accuracy: 0.9707
Epoch 18/30
 - 862s - loss: 0.1538 - categorical_accuracy: 0.9514 - val_loss: 0.1906 - val_categorical_accuracy: 0.9689
Epoch 19/30
 - 866s - loss: 0.1494 - categorical_accuracy: 0.9537 - val_loss: 0.1596 - val_categorical_accuracy: 0.9728
Epoch 20/30
 - 864s - loss: 0.1490 - categorical_accuracy: 0.9537 - val_loss: 0.1821 - val_categorical_accuracy: 0.9692
Epoch 21/30
 - 860s - loss: 0.1517 - categorical_accuracy: 0.9524 - val_loss: 0.1579 - val_categorical_accuracy: 0.9701
Epoch 22/30
 - 859s - loss: 0.1506 - categorical_accuracy: 0.9539 - val_loss: 0.1595 - val_categorical_accuracy: 0.9712
Epoch 23/30
 - 859s - loss: 0.1407 - categorical_accuracy: 0.9567 - val_loss: 0.1590 - val_categorical_accuracy: 0.9712
Epoch 24/30
 - 856s - loss: 0.1361 - categorical_accuracy: 0.9569 - val_loss: 0.2160 - val_categorical_accuracy: 0.9723
Epoch 25/30
 - 856s - loss: 0.1348 - categorical_accuracy: 0.9583 - val_loss: 0.1678 - val_categorical_accuracy: 0.9741
Epoch 26/30
 - 856s - loss: 0.1298 - categorical_accuracy: 0.9596 - val_loss: 0.1820 - val_categorical_accuracy: 0.9707
Epoch 27/30
 - 856s - loss: 0.1317 - categorical_accuracy: 0.9597 - val_loss: 0.1998 - val_categorical_accuracy: 0.9738
Epoch 28/30
 - 855s - loss: 0.1325 - categorical_accuracy: 0.9594 - val_loss: 0.1991 - val_categorical_accuracy: 0.9674
Epoch 29/30
 - 856s - loss: 0.1230 - categorical_accuracy: 0.9621 - val_loss: 0.1848 - val_categorical_accuracy: 0.9720
Epoch 30/30
 - 856s - loss: 0.1246 - categorical_accuracy: 0.9611 - val_loss: 0.1754 - val_categorical_accuracy: 0.9755

   32/10000 [..............................] - ETA: 59s
   64/10000 [..............................] - ETA: 59s
   96/10000 [..............................] - ETA: 59s
  128/10000 [..............................] - ETA: 57s
  160/10000 [..............................] - ETA: 56s
  192/10000 [..............................] - ETA: 55s
  224/10000 [..............................] - ETA: 55s
  256/10000 [..............................] - ETA: 54s
  288/10000 [..............................] - ETA: 54s
  320/10000 [..............................] - ETA: 54s
  352/10000 [>.............................] - ETA: 53s
  384/10000 [>.............................] - ETA: 53s
  416/10000 [>.............................] - ETA: 53s
  448/10000 [>.............................] - ETA: 52s
  480/10000 [>.............................] - ETA: 52s
  512/10000 [>.............................] - ETA: 52s
  544/10000 [>.............................] - ETA: 52s
  576/10000 [>.............................] - ETA: 52s
  608/10000 [>.............................] - ETA: 52s
  640/10000 [>.............................] - ETA: 52s
  672/10000 [=>............................] - ETA: 51s
  704/10000 [=>............................] - ETA: 51s
  736/10000 [=>............................] - ETA: 51s
  768/10000 [=>............................] - ETA: 51s
  800/10000 [=>............................] - ETA: 51s
  832/10000 [=>............................] - ETA: 50s
  864/10000 [=>............................] - ETA: 50s
  896/10000 [=>............................] - ETA: 50s
  928/10000 [=>............................] - ETA: 50s
  960/10000 [=>............................] - ETA: 50s
  992/10000 [=>............................] - ETA: 49s
 1024/10000 [==>...........................] - ETA: 49s
 1056/10000 [==>...........................] - ETA: 49s
 1088/10000 [==>...........................] - ETA: 49s
 1120/10000 [==>...........................] - ETA: 49s
 1152/10000 [==>...........................] - ETA: 49s
 1184/10000 [==>...........................] - ETA: 49s
 1216/10000 [==>...........................] - ETA: 48s
 1248/10000 [==>...........................] - ETA: 48s
 1280/10000 [==>...........................] - ETA: 48s
 1312/10000 [==>...........................] - ETA: 48s
 1344/10000 [===>..........................] - ETA: 48s
 1376/10000 [===>..........................] - ETA: 47s
 1408/10000 [===>..........................] - ETA: 47s
 1440/10000 [===>..........................] - ETA: 47s
 1472/10000 [===>..........................] - ETA: 47s
 1504/10000 [===>..........................] - ETA: 47s
 1536/10000 [===>..........................] - ETA: 46s
 1568/10000 [===>..........................] - ETA: 46s
 1600/10000 [===>..........................] - ETA: 46s
 1632/10000 [===>..........................] - ETA: 46s
 1664/10000 [===>..........................] - ETA: 46s
 1696/10000 [====>.........................] - ETA: 46s
 1728/10000 [====>.........................] - ETA: 46s
 1760/10000 [====>.........................] - ETA: 46s
 1792/10000 [====>.........................] - ETA: 46s
 1824/10000 [====>.........................] - ETA: 45s
 1856/10000 [====>.........................] - ETA: 45s
 1888/10000 [====>.........................] - ETA: 45s
 1920/10000 [====>.........................] - ETA: 45s
 1952/10000 [====>.........................] - ETA: 45s
 1984/10000 [====>.........................] - ETA: 45s
 2016/10000 [=====>........................] - ETA: 44s
 2048/10000 [=====>........................] - ETA: 44s
 2080/10000 [=====>........................] - ETA: 44s
 2112/10000 [=====>........................] - ETA: 44s
 2144/10000 [=====>........................] - ETA: 44s
 2176/10000 [=====>........................] - ETA: 44s
 2208/10000 [=====>........................] - ETA: 44s
 2240/10000 [=====>........................] - ETA: 43s
 2272/10000 [=====>........................] - ETA: 43s
 2304/10000 [=====>........................] - ETA: 43s
 2336/10000 [======>.......................] - ETA: 43s
 2368/10000 [======>.......................] - ETA: 43s
 2400/10000 [======>.......................] - ETA: 43s
 2432/10000 [======>.......................] - ETA: 42s
 2464/10000 [======>.......................] - ETA: 42s
 2496/10000 [======>.......................] - ETA: 42s
 2528/10000 [======>.......................] - ETA: 42s
 2560/10000 [======>.......................] - ETA: 42s
 2592/10000 [======>.......................] - ETA: 41s
 2624/10000 [======>.......................] - ETA: 41s
 2656/10000 [======>.......................] - ETA: 41s
 2688/10000 [=======>......................] - ETA: 41s
 2720/10000 [=======>......................] - ETA: 41s
 2752/10000 [=======>......................] - ETA: 41s
 2784/10000 [=======>......................] - ETA: 40s
 2816/10000 [=======>......................] - ETA: 40s
 2848/10000 [=======>......................] - ETA: 40s
 2880/10000 [=======>......................] - ETA: 40s
 2912/10000 [=======>......................] - ETA: 40s
 2944/10000 [=======>......................] - ETA: 39s
 2976/10000 [=======>......................] - ETA: 39s
 3008/10000 [========>.....................] - ETA: 39s
 3040/10000 [========>.....................] - ETA: 39s
 3072/10000 [========>.....................] - ETA: 39s
 3104/10000 [========>.....................] - ETA: 39s
 3136/10000 [========>.....................] - ETA: 38s
 3168/10000 [========>.....................] - ETA: 38s
 3200/10000 [========>.....................] - ETA: 38s
 3232/10000 [========>.....................] - ETA: 38s
 3264/10000 [========>.....................] - ETA: 38s
 3296/10000 [========>.....................] - ETA: 37s
 3328/10000 [========>.....................] - ETA: 37s
 3360/10000 [=========>....................] - ETA: 37s
 3392/10000 [=========>....................] - ETA: 37s
 3424/10000 [=========>....................] - ETA: 37s
 3456/10000 [=========>....................] - ETA: 36s
 3488/10000 [=========>....................] - ETA: 36s
 3520/10000 [=========>....................] - ETA: 36s
 3552/10000 [=========>....................] - ETA: 36s
 3584/10000 [=========>....................] - ETA: 36s
 3616/10000 [=========>....................] - ETA: 36s
 3648/10000 [=========>....................] - ETA: 35s
 3680/10000 [==========>...................] - ETA: 35s
 3712/10000 [==========>...................] - ETA: 35s
 3744/10000 [==========>...................] - ETA: 35s
 3776/10000 [==========>...................] - ETA: 35s
 3808/10000 [==========>...................] - ETA: 34s
 3840/10000 [==========>...................] - ETA: 34s
 3872/10000 [==========>...................] - ETA: 34s
 3904/10000 [==========>...................] - ETA: 34s
 3936/10000 [==========>...................] - ETA: 34s
 3968/10000 [==========>...................] - ETA: 33s
 4000/10000 [===========>..................] - ETA: 33s
 4032/10000 [===========>..................] - ETA: 33s
 4064/10000 [===========>..................] - ETA: 33s
 4096/10000 [===========>..................] - ETA: 33s
 4128/10000 [===========>..................] - ETA: 33s
 4160/10000 [===========>..................] - ETA: 32s
 4192/10000 [===========>..................] - ETA: 32s
 4224/10000 [===========>..................] - ETA: 32s
 4256/10000 [===========>..................] - ETA: 32s
 4288/10000 [===========>..................] - ETA: 32s
 4320/10000 [===========>..................] - ETA: 31s
 4352/10000 [============>.................] - ETA: 31s
 4384/10000 [============>.................] - ETA: 31s
 4416/10000 [============>.................] - ETA: 31s
 4448/10000 [============>.................] - ETA: 31s
 4480/10000 [============>.................] - ETA: 31s
 4512/10000 [============>.................] - ETA: 30s
 4544/10000 [============>.................] - ETA: 30s
 4576/10000 [============>.................] - ETA: 30s
 4608/10000 [============>.................] - ETA: 30s
 4640/10000 [============>.................] - ETA: 30s
 4672/10000 [=============>................] - ETA: 29s
 4704/10000 [=============>................] - ETA: 29s
 4736/10000 [=============>................] - ETA: 29s
 4768/10000 [=============>................] - ETA: 29s
 4800/10000 [=============>................] - ETA: 29s
 4832/10000 [=============>................] - ETA: 29s
 4864/10000 [=============>................] - ETA: 28s
 4896/10000 [=============>................] - ETA: 28s
 4928/10000 [=============>................] - ETA: 28s
 4960/10000 [=============>................] - ETA: 28s
 4992/10000 [=============>................] - ETA: 28s
 5024/10000 [==============>...............] - ETA: 27s
 5056/10000 [==============>...............] - ETA: 27s
 5088/10000 [==============>...............] - ETA: 27s
 5120/10000 [==============>...............] - ETA: 27s
 5152/10000 [==============>...............] - ETA: 27s
 5184/10000 [==============>...............] - ETA: 27s
 5216/10000 [==============>...............] - ETA: 26s
 5248/10000 [==============>...............] - ETA: 26s
 5280/10000 [==============>...............] - ETA: 26s
 5312/10000 [==============>...............] - ETA: 26s
 5344/10000 [===============>..............] - ETA: 26s
 5376/10000 [===============>..............] - ETA: 25s
 5408/10000 [===============>..............] - ETA: 25s
 5440/10000 [===============>..............] - ETA: 25s
 5472/10000 [===============>..............] - ETA: 25s
 5504/10000 [===============>..............] - ETA: 25s
 5536/10000 [===============>..............] - ETA: 25s
 5568/10000 [===============>..............] - ETA: 24s
 5600/10000 [===============>..............] - ETA: 24s
 5632/10000 [===============>..............] - ETA: 24s
 5664/10000 [===============>..............] - ETA: 24s
 5696/10000 [================>.............] - ETA: 24s
 5728/10000 [================>.............] - ETA: 23s
 5760/10000 [================>.............] - ETA: 23s
 5792/10000 [================>.............] - ETA: 23s
 5824/10000 [================>.............] - ETA: 23s
 5856/10000 [================>.............] - ETA: 23s
 5888/10000 [================>.............] - ETA: 23s
 5920/10000 [================>.............] - ETA: 22s
 5952/10000 [================>.............] - ETA: 22s
 5984/10000 [================>.............] - ETA: 22s
 6016/10000 [=================>............] - ETA: 22s
 6048/10000 [=================>............] - ETA: 22s
 6080/10000 [=================>............] - ETA: 21s
 6112/10000 [=================>............] - ETA: 21s
 6144/10000 [=================>............] - ETA: 21s
 6176/10000 [=================>............] - ETA: 21s
 6208/10000 [=================>............] - ETA: 21s
 6240/10000 [=================>............] - ETA: 21s
 6272/10000 [=================>............] - ETA: 20s
 6304/10000 [=================>............] - ETA: 20s
 6336/10000 [==================>...........] - ETA: 20s
 6368/10000 [==================>...........] - ETA: 20s
 6400/10000 [==================>...........] - ETA: 20s
 6432/10000 [==================>...........] - ETA: 19s
 6464/10000 [==================>...........] - ETA: 19s
 6496/10000 [==================>...........] - ETA: 19s
 6528/10000 [==================>...........] - ETA: 19s
 6560/10000 [==================>...........] - ETA: 19s
 6592/10000 [==================>...........] - ETA: 19s
 6624/10000 [==================>...........] - ETA: 18s
 6656/10000 [==================>...........] - ETA: 18s
 6688/10000 [===================>..........] - ETA: 18s
 6720/10000 [===================>..........] - ETA: 18s
 6752/10000 [===================>..........] - ETA: 18s
 6784/10000 [===================>..........] - ETA: 17s
 6816/10000 [===================>..........] - ETA: 17s
 6848/10000 [===================>..........] - ETA: 17s
 6880/10000 [===================>..........] - ETA: 17s
 6912/10000 [===================>..........] - ETA: 17s
 6944/10000 [===================>..........] - ETA: 17s
 6976/10000 [===================>..........] - ETA: 16s
 7008/10000 [====================>.........] - ETA: 16s
 7040/10000 [====================>.........] - ETA: 16s
 7072/10000 [====================>.........] - ETA: 16s
 7104/10000 [====================>.........] - ETA: 16s
 7136/10000 [====================>.........] - ETA: 16s
 7168/10000 [====================>.........] - ETA: 15s
 7200/10000 [====================>.........] - ETA: 15s
 7232/10000 [====================>.........] - ETA: 15s
 7264/10000 [====================>.........] - ETA: 15s
 7296/10000 [====================>.........] - ETA: 15s
 7328/10000 [====================>.........] - ETA: 14s
 7360/10000 [=====================>........] - ETA: 14s
 7392/10000 [=====================>........] - ETA: 14s
 7424/10000 [=====================>........] - ETA: 14s
 7456/10000 [=====================>........] - ETA: 14s
 7488/10000 [=====================>........] - ETA: 14s
 7520/10000 [=====================>........] - ETA: 13s
 7552/10000 [=====================>........] - ETA: 13s
 7584/10000 [=====================>........] - ETA: 13s
 7616/10000 [=====================>........] - ETA: 13s
 7648/10000 [=====================>........] - ETA: 13s
 7680/10000 [======================>.......] - ETA: 13s
 7712/10000 [======================>.......] - ETA: 12s
 7744/10000 [======================>.......] - ETA: 12s
 7776/10000 [======================>.......] - ETA: 12s
 7808/10000 [======================>.......] - ETA: 12s
 7840/10000 [======================>.......] - ETA: 12s
 7872/10000 [======================>.......] - ETA: 11s
 7904/10000 [======================>.......] - ETA: 11s
 7936/10000 [======================>.......] - ETA: 11s
 7968/10000 [======================>.......] - ETA: 11s
 8000/10000 [=======================>......] - ETA: 11s
 8032/10000 [=======================>......] - ETA: 11s
 8064/10000 [=======================>......] - ETA: 10s
 8096/10000 [=======================>......] - ETA: 10s
 8128/10000 [=======================>......] - ETA: 10s
 8160/10000 [=======================>......] - ETA: 10s
 8192/10000 [=======================>......] - ETA: 10s
 8224/10000 [=======================>......] - ETA: 9s 
 8256/10000 [=======================>......] - ETA: 9s
 8288/10000 [=======================>......] - ETA: 9s
 8320/10000 [=======================>......] - ETA: 9s
 8352/10000 [========================>.....] - ETA: 9s
 8384/10000 [========================>.....] - ETA: 9s
 8416/10000 [========================>.....] - ETA: 8s
 8448/10000 [========================>.....] - ETA: 8s
 8480/10000 [========================>.....] - ETA: 8s
 8512/10000 [========================>.....] - ETA: 8s
 8544/10000 [========================>.....] - ETA: 8s
 8576/10000 [========================>.....] - ETA: 7s
 8608/10000 [========================>.....] - ETA: 7s
 8640/10000 [========================>.....] - ETA: 7s
 8672/10000 [=========================>....] - ETA: 7s
 8704/10000 [=========================>....] - ETA: 7s
 8736/10000 [=========================>....] - ETA: 7s
 8768/10000 [=========================>....] - ETA: 6s
 8800/10000 [=========================>....] - ETA: 6s
 8832/10000 [=========================>....] - ETA: 6s
 8864/10000 [=========================>....] - ETA: 6s
 8896/10000 [=========================>....] - ETA: 6s
 8928/10000 [=========================>....] - ETA: 6s
 8960/10000 [=========================>....] - ETA: 5s
 8992/10000 [=========================>....] - ETA: 5s
 9024/10000 [==========================>...] - ETA: 5s
 9056/10000 [==========================>...] - ETA: 5s
 9088/10000 [==========================>...] - ETA: 5s
 9120/10000 [==========================>...] - ETA: 4s
 9152/10000 [==========================>...] - ETA: 4s
 9184/10000 [==========================>...] - ETA: 4s
 9216/10000 [==========================>...] - ETA: 4s
 9248/10000 [==========================>...] - ETA: 4s
 9280/10000 [==========================>...] - ETA: 4s
 9312/10000 [==========================>...] - ETA: 3s
 9344/10000 [===========================>..] - ETA: 3s
 9376/10000 [===========================>..] - ETA: 3s
 9408/10000 [===========================>..] - ETA: 3s
 9440/10000 [===========================>..] - ETA: 3s
 9472/10000 [===========================>..] - ETA: 2s
 9504/10000 [===========================>..] - ETA: 2s
 9536/10000 [===========================>..] - ETA: 2s
 9568/10000 [===========================>..] - ETA: 2s
 9600/10000 [===========================>..] - ETA: 2s
 9632/10000 [===========================>..] - ETA: 2s
 9664/10000 [===========================>..] - ETA: 1s
 9696/10000 [============================>.] - ETA: 1s
 9728/10000 [============================>.] - ETA: 1s
 9760/10000 [============================>.] - ETA: 1s
 9792/10000 [============================>.] - ETA: 1s
 9824/10000 [============================>.] - ETA: 0s
 9856/10000 [============================>.] - ETA: 0s
 9888/10000 [============================>.] - ETA: 0s
 9920/10000 [============================>.] - ETA: 0s
 9952/10000 [============================>.] - ETA: 0s
 9984/10000 [============================>.] - ETA: 0s
10000/10000 [==============================] - 56s 6ms/step

核心代码

    #(2)、建立ST定位网络:尝试更多的conv层,并分别在X轴和y轴上做最大池化
    # localization net. TODO: try more conv layers, and do max pooling on X- and Y-axes respectively
    locnet = Sequential()
    # locnet.add(MaxPooling2D(pool_size=(2,2), input_shape=input_shape))
    # locnet.add(Convolution2D(32, (5, 5)))
    locnet.add(Convolution2D(32, (5, 5), input_shape=input_shape))
    locnet.add(Activation('relu'))
    # locnet.add(Dropout(0.2)) # 0.2
    locnet.add(MaxPooling2D(pool_size=(2,2)))
    locnet.add(Convolution2D(64, (5, 5)))
    locnet.add(Activation('relu'))
    # locnet.add(Dropout(0.2)) # 0.3
    locnet.add(Convolution2D(64, (3, 3)))
    locnet.add(Activation('relu'))
    locnet.add(MaxPooling2D(pool_size=(2,2)))
    
    locnet.add(Flatten())
    locnet.add(Dense(50))
    locnet.add(Activation('relu'))
    locnet.add(Dense(6, weights=weights))
    print(locnet.summary())
    
    
    #(3)、建立CNN网络
    model = Sequential()
    model.add(SpatialTransformer(localization_net=locnet,
                                 output_size=(30,30), input_shape=input_shape))
    # model.add(Convolution2D(32, (3, 3), padding='same'))
    # model.add(Activation('relu'))
    # model.add(MaxPooling2D(pool_size=(2, 2)))
    # model.add(Convolution2D(64, (3, 3)))
    # model.add(Activation('relu'))
    # model.add(MaxPooling2D(pool_size=(2, 2)))
    # model.add(Dropout(0.5)) # 0.25
    
    # E: removed first 3 dropout layers
    model.add(Conv2D(32, kernel_size=(3, 3), activation='relu'))
    model.add(Dropout(0.5)) # 0.5
    model.add(Conv2D(64, (3, 3), activation='relu'))
    model.add(Dropout(0.5)) # 0.5
    model.add(MaxPooling2D(pool_size=(2, 2)))
    model.add(Conv2D(64, kernel_size=(3, 3),
                     activation='relu'))
    model.add(Dropout(0.5)) # 0.5
    model.add(MaxPooling2D(pool_size=(2, 2)))
    # model.add(Conv2D(64, (3, 3), activation='relu'))
    # model.add(Dropout(0.5))
    model.add(Flatten())
    model.add(Dense(256)) # 256
    model.add(Dropout(0.5)) # 0.5
    model.add(Activation('relu'))
    model.add(Dense(nb_classes))
    model.add(Activation('softmax'))

 

 

 

 

一个处女座的程序猿 CSDN认证博客专家 华为杯研电赛一等 华为研数模一等奖 国内外AI竞十
人工智能硕博生,拥有十多项发明专利(6项)和软件著作权(9项),多个国家级证书(2个国三级、3个国四级),先后获得国内外“人工智能算法”竞赛(包括国家级、省市级等,一等奖5项、二等奖4项、三等奖2项)相关证书十多个,以上均以第一作者身份,并拥有省市校级个人荣誉证书十多项。正在撰写《人工智算法最新实战》一书,目前已37万字。
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 代码科技 设计师:Amelia_0503 返回首页
实付 29.90元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值