Created
          February 10, 2018 09:13 
        
      - 
      
 - 
        
Save whenyd/7ad89396e0b43b6893411f36891bc2ba to your computer and use it in GitHub Desktop.  
    Keras implementation of inception v1
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | from keras.layers import Conv2D, MaxPooling2D, Input, concatenate | |
| def inception(input, | |
| filters_1x1, | |
| filters_3x3_reduce, filters_3x3, | |
| filters_5x5_reduce, filters_5x5, | |
| filters_pool_proj): | |
| """ | |
| :param input: | |
| :param filters_1x1: | |
| :param filters_3x3_reduce: | |
| :param filters_3x3: | |
| :param filters_5x5_reduce: | |
| :param filters_5x5: | |
| :param filters_pool_proj: | |
| :return: | |
| """ | |
| same = 'same' | |
| relu = 'relu' | |
| conv_1x1 = Conv2D(filters_1x1, (1, 1), padding=same, activation=relu)(input) | |
| conv_3x3 = Conv2D(filters_3x3_reduce, (1, 1), padding=same, activation=relu)(input) | |
| conv_3x3 = Conv2D(filters_3x3, (3, 3), padding=same, activation=relu)(conv_3x3) | |
| conv_5x5 = Conv2D(filters_5x5_reduce, (1, 1), padding=same, activation=relu)(input) | |
| conv_5x5 = Conv2D(filters_5x5, (5, 5), padding=same, activation=relu)(conv_5x5) | |
| maxpool = MaxPooling2D((3, 3), strides=(1, 1), padding=same)(input) | |
| maxpool_proj = Conv2D(filters_pool_proj, (1, 1), padding=same, activation=relu)(maxpool) | |
| # concatenate by channels | |
| # axis=3 or axis=-1(default) for tf backend | |
| output = concatenate([conv_1x1, conv_3x3, conv_5x5, maxpool_proj], axis=3) | |
| return output | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment