<jupyter_start><jupyter_text>Implementation of Inception Network ???  [Inception Network ??? Paper](http://arxiv.org/pdf/1602.07261v1.pdf) in Keras.<jupyter_code>from keras.layers import concatenate

def conv_block(x, nb_filters, kernel_size=(3,3), strides=1):

    x1 = Convolution2D(nb_filters, kernel_size, strides=strides, padding='same')(x)
    #x1 = BatchNormalization()(x1)
    x1 = Activation('relu')(x1)
    
    return x1

def res_conv_block(x, kernel_size=(3,3)):
    nb_filters = keras.backend.int_shape(x)[3]
    x1 = Convolution2D(nb_filters, kernel_size=(1,1), padding='same')(x)
    x1 = Convolution2D(nb_filters, kernel_size, padding='same')(x1)
    #x1 = BatchNormalization()(x1)
    out = add([x, x1])
    
    return Activation('relu')(out)

def inception_A(x):
    nb_filters1 = 32
    nb_filters2 = keras.backend.int_shape(x)[3]
    
    x1 = Convolution2D(nb_filters1, kernel_size=(1,1), padding='same')(x)
    
    x2 = Convolution2D(nb_filters1, kernel_size=(1,1), padding='same')(x)
    x2 = Convolution2D(nb_filters1, kernel_size=(3,3), padding='same')(x2)
    
    x3 = Convolution2D(nb_filters1, kernel_size=(1,1), padding='same')(x)
    x3 = Convolution2D(nb_filters1, kernel_size=(3,3), padding='same')(x3)
    x3 = Convolution2D(nb_filters1, kernel_size=(3,3), padding='same')(x3)
    
    x123 = concatenate([x1, x2, x3])
    x123 = Convolution2D(nb_filters2, kernel_size=(1,1), padding='same')(x123)
    
    out = add([x, x123])
    return Activation('relu')(out)

def reduction_A(x, filter_bank={'k':192,'l':224,'m':256,'n':384}):
    x1 = Convolution2D(filter_bank['k'], kernel_size=(1,1), padding='same')(x)
    x1 = Convolution2D(filter_bank['l'], kernel_size=(3,3), padding='same')(x1)
    x1 = Convolution2D(filter_bank['m'], kernel_size=(3,3), padding='same', strides=2)(x1)
    
    x2 = Convolution2D(filter_bank['n'], kernel_size=(3,3), padding='same', strides=2)(x)
    
    x3 = MaxPool2D(strides=2)(x)
    
    return concatenate([x1, x2, x3])    
init = Input((160, 320, 3))
x      = conv_block(init, 32)
x      = res_conv_block(x)
x      = conv_block(x, 64)
x      = inception_A(x)
x      = reduction_A(x, filter_bank={'k':24,'l':32,'m':48,'n':64})
x      = conv_block(x, 32, strides=2)
x      = conv_block(x, 32, strides=2)
x      = conv_block(x, 32, strides=2)
x      = conv_block(x, 32, strides=2)
x      = Flatten()(x)
x      = Dense(activation='relu', units=10)(x)
out    = Dense(units=1, use_bias=True)(x)
model1 = Model(init, out, name='Inception-v4')
model1.summary()
now = datetime.datetime.now
batch_size = 3
epochs = 1

model1.compile(loss='mse',
              optimizer='adadelta',
              metrics=['accuracy'])

t = now()
model1.fit(X_train, y_train,
          batch_size=batch_size,
          epochs=epochs,
          verbose=1,
          validation_data=(X_test, y_test))
print('Training time: %s' % (now() - t))
score = model1.evaluate(X_test, y_test, verbose=0)
print('Test score:', score[0])
print('Test accuracy:', score[1])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1772862330802245, 'fraction_numerical': 0.05744470122152526, 'mean_word_length': 4.3628318584070795, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '587526', 'license': 'MIT', 'n_tokens_mistral': 1268, 'n_tokens_neox': 1197, 'n_words': 197, 'path': 'behavioral_cloning_with_keras.ipynb', 'repo_name': 'twildhage/BehavioralCloning', 'size': '3029'}