training/train.py
def build_model():
    """ Build new model through the following steps:
        1. Load ImageNet trained MobileNetV2 without fully-connected layer at the top of the network
        2. Freeze all layers except the top M layers. Top M layers will be trainable.
        3. Add final fully-connected (Dense) layer
    """
    input_tensor = layers.Input(shape=(img_size, img_size, 3))
    base_model = MobileNetV2(
        include_top=False,
        weights='imagenet',
        input_tensor=input_tensor,
        input_shape=(img_size, img_size, 3),
        pooling='avg'
    )

    # Only top M layers are trainable
    for layer in base_model.layers[:-trainable_layers]:
        layer.trainable = False
    
    output_tensor = layers.Dense(output_classes, activation='softmax')(base_model.output)
    model = models.Model(inputs=input_tensor, outputs=output_tensor)

    return model
 Build new model through the following steps:
        1. Load ImageNet trained MobileNetV2 without fully-connected layer at the top of the network
        2. Freeze all layers except the top M layers. Top M layers will be trainable.
        3. Add final fully-connected (Dense) layer
    
Build new model through the following steps:
1. Load ImageNet trained MobileNetV2 without fully-connected layer at the top of the network
2. Freeze all layers except the top M layers. Top M layers will be trainable.
3. Add final fully-connected (Dense) layer
Build new model through the following steps : 1 . Load ImageNet trained MobileNetV2 without fully - connected layer at the top of the network 2 . Freeze all layers except the top M layers . Top M layers will be trainable . 3 . Add final fully - connected ( Dense ) layer
def build_model():
    input_tensor = layers.Input(shape=(img_size, img_size, 3))
    base_model = MobileNetV2(
        include_top=False,
        weights='imagenet',
        input_tensor=input_tensor,
        input_shape=(img_size, img_size, 3),
        pooling='avg'
    )
    for layer in base_model.layers[:-trainable_layers]:
        layer.trainable = False
    output_tensor = layers.Dense(output_classes, activation='softmax')(base_model.output)
    model = models.Model(inputs=input_tensor, outputs=output_tensor)
    return model
def build_model ( ) : input_tensor = layers . Input ( shape = ( img_size , img_size , 3 ) ) base_model = MobileNetV2 ( include_top = False , weights = 'imagenet' , input_tensor = input_tensor , input_shape = ( img_size , img_size , 3 ) , pooling = 'avg' ) for layer in base_model . layers [ : - trainable_layers ] : layer . trainable = False output_tensor = layers . Dense ( output_classes , activation = 'softmax' ) ( base_model . output ) model = models . Model ( inputs = input_tensor , outputs = output_tensor ) return model
Build new model through the following steps:
1.
Build new model through the following steps : 1 .
""" Build new model through the following steps:
        1. Load ImageNet trained MobileNetV2 without fully-connected layer at the top of the network
        2. Freeze all layers except the top M layers. Top M layers will be trainable.
        3. Add final fully-connected (Dense) layer
    """ # Only top M layers are trainable