SHARE
TWEET

Untitled

a guest Aug 20th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. input_data = Input(shape=(28, 28,1))
  2. first_layer = Conv2D(filters=16, kernel_size=(5,5), activation='relu', padding='same', input_shape = input_shape, use_bias = False)(input_data)
  3. avg_1 = AveragePooling2D(pool_size=(2,2), data_format= 'channels_last')(first_layer)
  4. add = []
  5. random_matrix = np.random.randint(0,15,(4,32))
  6. for i in range(32):
  7.     group = []
  8.     for j in range(4):      
  9.         group_channel = Lambda(lambda x: x[:,:,:,random_matrix[j][i],np.newaxis])(avg_1)
  10.         conv_group = Conv2D(1, kernel_size=[5,5], strides=(stride,stride), activation = 'relu',padding='valid', data_format= 'channels_last',name = 'Conv_'+str(i*4+j)+'_Sparse', use_bias =False)(group_channel)
  11.         group.append(conv_group)
  12.     add_group = Add()(group)
  13.     add.append(add_group)
  14. second_layer = Concatenate()(add)    
  15. avg_2 = AveragePooling2D(pool_size=(2,2), data_format= 'channels_last')(second_layer)
  16. flatten = Flatten()(avg_2)
  17. dense = Dense(num_classes, name = 'dense_3', use_bias = False)(flatten)
  18. activation = Activation('softmax')(dense)
  19. model = Model(input_data, activation)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top