What did I misunderstand about the size of the kera layer?

As part of studying deep learning and Keras, I am trying to implement the following line of pipelines:

EEG Analysis Network from https://arxiv.org/abs/1610.01683

The idea is this:

  • EEG data input sections (6000x1 is what I will use for now)
  • run it through 20 1D filters (200x1)
  • make the maximum combination at the output of each of these filters with pool 20, step 10 (as a result, 20 data points 578x1 are obtained)
  • "drain" it into a 578x20 matrix
  • run this through a two-dimensional convolution with a kernel size of 30x20
  • Maxpool again, with pool (10.1), increments (2.1)
  • two consecutive fully connected levels
  • 5-class softmax function.

My code is:

model = Sequential()
model.add(Conv1D(input_shape=(6000,1),kernel_size=200,strides=1,
             activation='relu',filters=20,name='C1'))
model.add(MaxPooling1D(pool_size=20, strides=10,padding='valid',name='P1'))
model.add(Reshape(( 579, 20,1),name='S1'))
model.add(Conv2D(filters=400,kernel_size=(30,20),strides=(1,1), 
             activation='relu',name='C2'))
model.add(MaxPooling2D(pool_size=(10,1),strides=(2,1),padding='valid',name='P2'))
#model.add(Reshape((271*400,1,1),name='S2'))
model.add(Dense(500,activation='relu',name='F1'))
model.add(Dense(500,activation='relu',name='F2'))
model.add(Dense(5,activation='relu',name='output'))
model.add(Activation(activation='softmax',name='softmax'))

model.summary()

The result of this:

Layer (type)                 Output Shape              Param #   
=================================================================
C1 (Conv1D)                  (None, 5801, 20)          4020      
_________________________________________________________________
P1 (MaxPooling1D)            (None, 579, 20)           0         
_________________________________________________________________
S1 (Reshape)                 (None, 579, 20, 1)        0         
_________________________________________________________________
C2 (Conv2D)                  (None, 550, 1, 400)       240400    
_________________________________________________________________
P2 (MaxPooling2D)            (None, 271, 1, 400)       0         
_________________________________________________________________
F1 (Dense)                   (None, 271, 1, 500)       200500    
_________________________________________________________________
F2 (Dense)                   (None, 271, 1, 500)       250500    
_________________________________________________________________
output (Dense)               (None, 271, 1, 5)         2505      
_________________________________________________________________
softmax (Activation)         (None, 271, 1, 5)         0         
=================================================================
Total params: 697,925.0
Trainable params: 697,925.0
Non-trainable params: 0.0
_________________________________________________________________

. , F1 500x1 (500 ), , ? P2 F1? "model.add(Reshape ((271 * 400,1,1), name= 'S2'))" , P2 . "image_data_format": "channels_last" keras.json, , - - col-col-channel?

, .

+4
1

, Dense. , ( ), , .

doc Dense, , (batch_dim, dim1, dim2,..., last_dim) (batch_dim, dim1, dim2, ..., output_units).

, , Reshape((271*400,1,1),name='S2'), - (271*400,1,500). , (500,), S2 1D-, . Reshape((271*400,),name='S2') Flatten(), @maz . Flatten() - , 1D-.

, : -)

+1

Source: https://habr.com/ru/post/1673113/


All Articles