def add_parameter_update_ops()

in lib/models/model_builder_video.py [0:0]


def add_parameter_update_ops(model):
    def param_update_ops(model):
        lr = model.param_init_net.ConstantFill(
            [], 'lr', shape=[1], value=model.current_lr)
        weight_decay = model.param_init_net.ConstantFill(
            [], 'weight_decay', shape=[1], value=cfg.SOLVER.WEIGHT_DECAY
        )
        weight_decay_bn = model.param_init_net.ConstantFill(
            [], 'weight_decay_bn', shape=[1], value=cfg.SOLVER.WEIGHT_DECAY_BN
        )
        one = model.param_init_net.ConstantFill(
            [], "ONE", shape=[1], value=1.0
        )
        params = model.GetParams()
        curr_scope = scope.CurrentNameScope()
        # scope is of format 'gpu_{}/'.format(gpu_id), so remove the separator.
        trainable_params = model.TrainableParams(curr_scope[:-1])
        assert len(params) > 0, 'No trainable params found in model'
        for param in params:
            # Only update trainable params.
            if param in trainable_params:
                param_grad = model.param_to_grad[param]
                # The param grad is the summed gradient for the parameter across
                # all gpus/hosts.
                param_momentum = model.param_init_net.ConstantFill(
                    [param], param + '_momentum', value=0.0)

                if '_bn' in str(param):
                    model.WeightedSum(
                        [param_grad, one, param, weight_decay_bn],
                        param_grad)
                else:
                    model.WeightedSum(
                        [param_grad, one, param, weight_decay],
                        param_grad)
                model.net.MomentumSGDUpdate(
                    [param_grad, param_momentum, lr, param],
                    [param_grad, param_momentum, param],
                    momentum=cfg.SOLVER.MOMENTUM,
                    nesterov=cfg.SOLVER.NESTEROV,
                )
    return param_update_ops