---
dataset:
    task:
        background_class: {use: true}
        preprocess:
            shape:
                height: 224
                width: 224
                channels: 3
            validate: {type: central_crop, fraction: 0.875}
            final_cpu:
                - {type: resize, fill: false}
                - {type: linear_map, scale: 2.0, shift: -1.0}
_interval: 1.0
_quantize:
    activation: true
    normalization: true
model:
    name: mobilenet_v1
    description:
        MobileNet implementation from::
            https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet_v1.py
    layers:
        _regu: &regularizer
            type: tensorflow.contrib.layers.l2_regularizer
            scale: 0.00004
        _shift: &shift
            type: mayo.override.IncrementalQuantizer
            interval: $(_interval)
            stop_gradient: false
            count_zero: false
            quantizer:
                type: mayo.override.ShiftQuantizer
                width: 3
                bias: 2
                asymmetry: false
                overflow_rate: 0.0
                should_update: false
                stochastic: false
            _priority: 100
        _fixed: &fixed
            type: mayo.override.FixedPointQuantizer
            width: 9
            point: 4
            should_update: true
            stochastic: false
            _priority: 100
        _conv: &conv
            type: convolution
            kernel_size: 3
            stride: 2
            padding: same
            normalizer_fn: mayo.objects.normalize.custom_batch_norm
            normalizer_params:
                center: true
                scale: true
                decay: 0.997
                epsilon: 0.001
            weights_regularizer: *regularizer
            weights_initializer:
                type: tensorflow.truncated_normal_initializer
                stddev: 0.09
            activation_fn: tensorflow.nn.relu6
            overrider: &overriders
                weights: {shift: {<<: *shift}}
                depthwise_weights: {shift: {<<: *shift}}
                biases: {fixed: {<<: *fixed}}
                _activation_True: {fixed: {<<: *fixed}}
                _activation_False: null
                _normalization_True:
                    input:
                        noop:
                            type: mayo.override.EmptyOverrider
                            _priority: 100
                    scale: {fixed: {<<: *fixed, width: 16, point: 8}}
                    offset: {fixed: {<<: *fixed, width: 16, point: 8}}
                _normalization_False: null
                activation: $(._activation_$(_quantize.activation))
                normalization: $(._normalization_$(_quantize.normalization))
        _dsconv: &dsconv
            type: module
            kwargs: {stride: null, num_outputs: null}
            layers:
                depthwise:
                    <<: *conv
                    type: depthwise_convolution
                    stride: ^(stride)
                pointwise:
                    <<: *conv
                    kernel_size: [1, 1]
                    stride: 1
                    num_outputs: ^(num_outputs)
            graph: {from: input, with: [depthwise, pointwise], to: output}
        prep:
            type: identity
            overrider: {activation: {fixed: {<<: *fixed, point: 2}}}
        conv0: {<<: *conv, num_outputs: 32}
        conv1: {<<: *dsconv, stride: 1, num_outputs: 64}
        conv2: {<<: *dsconv, stride: 2, num_outputs: 128}
        conv3: {<<: *dsconv, stride: 1, num_outputs: 128}
        conv4: {<<: *dsconv, stride: 2, num_outputs: 256}
        conv5: {<<: *dsconv, stride: 1, num_outputs: 256}
        conv6: {<<: *dsconv, stride: 2, num_outputs: 512}
        conv7: {<<: *dsconv, stride: 1, num_outputs: 512}
        conv8: {<<: *dsconv, stride: 1, num_outputs: 512}
        conv9: {<<: *dsconv, stride: 1, num_outputs: 512}
        conv10: {<<: *dsconv, stride: 1, num_outputs: 512}
        conv11: {<<: *dsconv, stride: 1, num_outputs: 512}
        conv12: {<<: *dsconv, stride: 2, num_outputs: 1024}
        conv13: {<<: *dsconv, stride: 1, num_outputs: 1024}
        pool: {type: average_pool, kernel_size: 7, stride: 2, padding: valid}
        dropout: {type: dropout, keep_prob: 0.8}
        fc:
            type: convolution
            kernel_size: 1
            num_outputs: $(dataset.task.num_classes)
            activation_fn: null
            normalizer_fn: null
            weights_regularizer: *regularizer
            overrider:
                biases: {fixed: {<<: *fixed}}
                weights: {shift: {<<: *shift}}
                activation: null
        logits: {type: squeeze, axis: [1, 2]}
    graph:
        from: input
        with: [
            prep, conv0,
            conv1, conv2, conv3, conv4, conv5,
            conv6, conv7, conv8, conv9, conv10,
            conv11, conv12, conv13,
            pool, dropout, fc, logits]
        to: output
