def create_fel_res(): inp = Input(getInputDim()) x = Conv2D(32, (3, 3), activation='relu')(inp) x = Conv2D(64, (3, 3), activation='relu', padding='same')(x) x = MaxPooling2D((3, 3), strides=2)(x) x = create_highway(x, 64, 1) x = create_highway(x, 64, 1) x = MaxPooling2D((3, 3), strides=2)(x) x = create_highway(x, 64, 2) x = MaxPooling2D((3, 3), strides=2)(x) x = Conv2D(32, (1, 1), activation='relu')(x) # x = GlobalAveragePooling2D()(x) # x = Activation('softmax')(x) x = Flatten()(x) x = Dense(128, activation='relu')(x) x = Dense(512, activation='sigmoid')(x) x = Dense(512, activation='sigmoid')(x) x = Dense(1, activation='sigmoid')(x) model = Model(inp, x) model.compile(loss='binary_crossentropy', optimizer='adagrad', metrics=[metrics.mitos_fscore, 'binary_accuracy']) return model
def create_simple_model(): model = Sequential() model.add( Conv2D(32, (3, 3), input_shape=getInputDim(), activation='relu', padding='same')) # model.add((Conv2D(32, (3,3), activation='relu', padding='same'))) model.add(MaxPooling2D((2, 2), strides=(2, 2))) model.add(Conv2D(32, (3, 3), activation='relu', padding='same')) model.add(MaxPooling2D((2, 2), strides=(2, 2))) model.add(Conv2D(64, (3, 3), activation='relu', padding='same')) model.add(MaxPooling2D((3, 3), strides=(2, 2))) model.add( Flatten()) # this converts our 3D feature maps to 1D feature vectors model.add(Dense(64)) model.add(Activation('relu')) model.add(Dropout(0.7)) model.add(Dense(1, activation='sigmoid')) model.compile(loss='binary_crossentropy', optimizer='adagrad', metrics=[metrics.mitos_fscore, 'binary_accuracy']) return model
def create_vgg16(): input_shape = getInputDim() img_input = Input(shape=input_shape) x = Conv2D(64, (3, 3), activation='relu', padding='valid', name='block1_conv1')(img_input) x = Conv2D(64, (3, 3), activation='relu', padding='valid', name='block1_conv2')(x) x = MaxPooling2D((2, 2), strides=(2, 2), name='block1_pool')(x) # Block 2 x = Conv2D(128, (3, 3), activation='relu', padding='same', name='block2_conv1')(x) x = Conv2D(128, (3, 3), activation='relu', padding='same', name='block2_conv2')(x) x = MaxPooling2D((2, 2), strides=(2, 2), name='block2_pool')(x) # Block 3 x = Conv2D(256, (3, 3), activation='relu', padding='same', name='block3_conv1')(x) x = Conv2D(256, (3, 3), activation='relu', padding='same', name='block3_conv2')(x) x = Conv2D(256, (3, 3), activation='relu', padding='same', name='block3_conv3')(x) x = MaxPooling2D((2, 2), strides=(2, 2), name='block3_pool')(x) # Block 4 x = Conv2D(512, (3, 3), activation='relu', padding='same', name='block4_conv1')(x) x = Conv2D(512, (3, 3), activation='relu', padding='same', name='block4_conv2')(x) x = Conv2D(512, (3, 3), activation='relu', padding='same', name='block4_conv3')(x) x = MaxPooling2D((2, 2), strides=(2, 2), name='block4_pool')(x) # Block 5 x = Conv2D(512, (3, 3), activation='relu', padding='same', name='block5_conv1')(x) x = Conv2D(512, (3, 3), activation='relu', padding='same', name='block5_conv2')(x) x = Conv2D(512, (3, 3), activation='relu', padding='same', name='block5_conv3')(x) x = MaxPooling2D((2, 2), strides=(2, 2), name='block5_pool')(x) # Classification block x = Flatten(name='flatten')(x) x = Dense(512, activation='relu', name='fc1')(x) x = Dense(512, activation='relu', name='fc2')(x) x = Dense(2, activation='softmax', name='predictions')(x) # Create model. model = Model(img_input, x, name='vgg16') model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=[metrics.mitos_fscore]) return model
def create_squeeze_net(): inp = Input(shape=getInputDim()) x = Conv2D(64, (3,3), padding='same', activation='relu')(inp) x = MaxPooling2D((3,3), strides=2)(x) x = create_fire_mod(x, 64, 128) x = MaxPooling2D((3,3), strides=2)(x) x = create_fire_mod(x, 64, 128) x = MaxPooling2D((3,3), strides=2)(x) x = Conv2D(32,(1,1), activation='relu')(x) x = Flatten()(x) x = Dense(64, activation='relu')(x) x = Dense(1, activation='sigmoid')(x) model = Model(inp, x) model.compile(loss='binary_crossentropy', optimizer='adagrad', metrics=['binary_accuracy',]) return model