Examples/torch/quantization/quantization_aware_training.py
def apply_bias_correction(model: torch.nn.Module, data_loader: torch_data.DataLoader):
    """
    Applies Bias-Correction on the model.
    :param model: The model to quantize
    :param evaluator: Evaluator used during quantization
    :param dataloader: DataLoader used during quantization
    :param logdir: Log directory used for storing log files
    :return: None
    """
    # Rounding mode can be 'nearest' or 'stochastic'
    rounding_mode = 'nearest'

    # Number of samples used during quantization
    num_quant_samples = 16

    # Number of samples used for bias correction
    num_bias_correct_samples = 16

    params = QuantParams(weight_bw=8, act_bw=8, round_mode=rounding_mode, quant_scheme='tf_enhanced')

    # Perform Bias Correction
    bias_correction.correct_bias(model.to(device="cuda"), params, num_quant_samples=num_quant_samples,
                                 data_loader=data_loader, num_bias_correct_samples=num_bias_correct_samples)

    Applies Bias-Correction on the model.
    :param model: The model to quantize
    :param evaluator: Evaluator used during quantization
    :param dataloader: DataLoader used during quantization
    :param logdir: Log directory used for storing log files
    :return: None
    
Applies Bias-Correction on the model.
Applies Bias - Correction on the model .
def apply_bias_correction(model: torch.nn.Module, data_loader: torch_data.DataLoader):
    rounding_mode = 'nearest'
    num_quant_samples = 16
    num_bias_correct_samples = 16
    params = QuantParams(weight_bw=8, act_bw=8, round_mode=rounding_mode, quant_scheme='tf_enhanced')
    bias_correction.correct_bias(model.to(device="cuda"), params, num_quant_samples=num_quant_samples,
                                 data_loader=data_loader, num_bias_correct_samples=num_bias_correct_samples)
def apply_bias_correction ( model : torch . nn . Module , data_loader : torch_data . DataLoader ) : rounding_mode = 'nearest' num_quant_samples = 16 num_bias_correct_samples = 16 params = QuantParams ( weight_bw = 8 , act_bw = 8 , round_mode = rounding_mode , quant_scheme = 'tf_enhanced' ) bias_correction . correct_bias ( model . to ( device = "cuda" ) , params , num_quant_samples = num_quant_samples , data_loader = data_loader , num_bias_correct_samples = num_bias_correct_samples )
Applies Bias-Correction on the model.
Applies Bias - Correction on the model .
"""
    Applies Bias-Correction on the model.
    :param model: The model to quantize
    :param evaluator: Evaluator used during quantization
    :param dataloader: DataLoader used during quantization
    :param logdir: Log directory used for storing log files
    :return: None
    """ # Rounding mode can be 'nearest' or 'stochastic' # Number of samples used during quantization # Number of samples used for bias correction # Perform Bias Correction
None
model
torch.nn.Module
The model to quantize
The model to quantize
data_loader
torch_data.DataLoader
evaluator
Evaluator used during quantization
Evaluator used during quantization
dataloader
DataLoader used during quantization
DataLoader used during quantization
logdir
Log directory used for storing log files
Log directory used for storing log files