def build_model(): """Builds and returns the network.""" # Create the inputs to the network. sky_images = Input(shape=(480, 480, 3), name='SkyImages') # sky images tsi = Input(shape=(480, 480), dtype='int64', name='TSIDecisionImages') # TSI's decision images # Main body of the network conv1 = Convolution2D(filters=32, kernel_size=3, padding='same', data_format='channels_last', activation='relu')(sky_images) maxpool1 = MaxPool2D(pool_size=(1, 100), strides=(1, 1), padding='same', data_format='channels_last')(conv1) maxpool2 = MaxPool2D(pool_size=(100, 1), strides=(1, 1), padding='same', data_format='channels_last')(conv1) concat1 = concatenate([conv1, maxpool1], axis=3) concat2 = concatenate([maxpool2, concat1], axis=3) concat3 = concatenate([concat2, sky_images], axis=3) conv2 = Convolution2D(filters=4, kernel_size=3, padding='same', data_format='channels_last', activation='relu')(concat3) decision = DecidePixelColors()(conv2) model = Model(inputs=[sky_images], outputs=[conv2, decision]) # in outputs, , decision return model
def feature_extractor(input_net): net_1 = Conv2D(96, 1, 1)(input_net) net_1 = ReLU()(net_1) net_1 = Conv2D(208, 3, 1)(net_1) net_1 = ReLU()(net_1) net_2 = MaxPool2D(3, 1)(input_net) net_2 = Conv2D(64, 1, 1)(net_2) net_2 = ReLU()(net_2) concat = concatenate(inputs=[net_1, net_2], axis=3) pooling_out = MaxPool2D(3, 2)(concat) return pooling_out
def generate_inceptionResnetv2_based_model(): irv2 = tf.keras.applications.inception_resnet_v2.InceptionResNetV2( include_top=False) irv2.trainable = False # This returns a tensor input1 = Input(shape=(299, 299, 3), name='input1') input2 = Input(shape=(299, 299, 3), name='input2') out1 = irv2(input1) out2 = irv2(input2) averPool = AveragePooling2D(pool_size=(8, 8)) out1 = averPool(out1) out2 = averPool(out2) y = concatenate([out1, out2]) dense = Dense(1) y = dense(y) activation = Activation('tanh') y = activation(y) y = Flatten()(y) model = Model(inputs=[input1, input2], outputs=y) return model