```

    import tensorflow as tf
    import keras
    from keras import backend as K
    from keras.layers.convolutional import MaxPooling2D,Conv2D
    #使うレイヤーを選択
    from keras.layers import Input,Dense, Activation, Multiply,Concatenate,Lambda,LeakyReLU
    from keras.models import Model
    from keras import regularizers            #レギュラーライザー
    from keras.constraints import max_norm    #重みとかを２以上にしない（たぶん）
    from keras.optimizers import Adam         #アダムを使用
    import time
    from keras.utils import plot_model
    from collections import deque
    
    
    
    class QNetwork :
        def __init__(self,learning_rate, state_size, action_size):
            self.inputs = Input(shape=(statesize[0],statesize[1],statesize[2],))
    
            self.a=Conv2D(32,kernel_size=(3,3),strides=1,padding='same',activation=LeakyReLU(alpha=0.01),
                          use_bias=True,kernel_initializer='he_normal',bias_initializer='zeros',kernel_constraint=max_norm(2.),
                          bias_constraint=max_norm(2.))(self.inputs)#aaaaaaa
    
            self.a=MaxPooling2D(pool_size=(2, 2))
    
            self.a=Conv2D(64,kernel_size=(3, 3), padding='same', data_format=None, dilation_rate=(1, 1),activation=LeakyReLU(alpha=0.01),
                          use_bias=True,kernel_initializer='he_normal',bias_initializer='zeros',kernel_constraint=max_norm(2.),
                          bias_constraint=max_norm(2.))(self.a)
            self.a=MaxPooling2D(pool_size=(2, 2))(self.a)#vavavava
    
            self.a=Conv2D(128,kernel_size=(3, 3), padding='same', data_format=None, dilation_rate=(1, 1),activation=LeakyReLU(alpha=0.01),
                          use_bias=True,kernel_initializer='he_normal',bias_initializer='zeros',kernel_constraint=max_norm(2.),
                          bias_constraint=max_norm(2.))(self.a)
            self.a=MaxPooling2D(pool_size=(2, 2))(self.a)
    
    
            self.a=Flatten()(self.a)
    
    
            self.a=Dense(250,activation='relu',
                         use_bias=True,kernel_initializer='he_normal',bias_initializer='zeros',kernel_constraint=max_norm(2.),
                         bias_constraint=max_norm(2.))(self.a)
            self.a=Dense(250,activation='relu',
                         use_bias=True,kernel_initializer='he_normal',bias_initializer='zeros',kernel_constraint=max_norm(2.),
                         bias_constraint=max_norm(2.))(self.a)
    
    
            self.v=Dense(1,      
                         use_bias=True,kernel_initializer='he_normal',bias_initializer='zeros',kernel_constraint=max_norm(2.),
                         bias_constraint=max_norm(2.))(self.v)
    
            self.dv=Dense(500,activation='relu'
                         ,use_bias=True,kernel_initializer='he_normal',bias_initializer='zeros',kernel_constraint=max_norm(2.),
                         bias_constraint=max_norm(2.))(self.a)   
            self.dv=Dense(action_size
                         ,use_bias=True,kernel_initializer='he_normal',bias_initializer='zeros',kernel_constraint=max_norm(2.),
                         bias_constraint=max_norm(2.))(self.dv)
    
            self.a = Concatenate()([self.v,self.dv])
            self.a = Lambda(lambda a: K.expand_dims(a[:, 0], -1) + a[:, 1:] - K.mean(a[:, 1:], axis=1, keepdims=True), 
                            output_shape=(action_size,))(self.a)
    
            self.adm = Adam(lr=learning_rate,beta_1=0.9, beta_2=0.999, amsgrad=False)
            self.model = Model(inputs=self.inputs, outputs=self.a)
            self.model.compile(loss=huberloss, optimizer=self.adm,metrics=['accuracy'])
    
    
    learning_rate = 0.00001
    action_size=2 #モデルのoutput
    statesize=[400,400,3]   #モデルのinput
    
    mainQN = QNetwork(learning_rate=learning_rate,state_size=statesize,action_size=action_size)  # メインQネットワーク
    targetQN = QNetwork(learning_rate=learning_rate,state_size=statesize,action_size=action_size)  # 価値計算Qネットワーク
    
```
CC BY-SA 4.0
2020-05-03T13:55:15.247
66252
2020-05-03T16:43:41.920
2020-05-03T16:43:41.920
3060
39967
question
python jupyter-notebook keras
kerasでCNNをしようとしたんですがMaxPoolingでエラーが出ます