def resnet18_llsq(pretrained=False, **kwargs): """Constructs a ResNet-18 model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet """ model_name = sys._getframe().f_code.co_name quan_type = model_name.split('_')[-1] quan_factory = my_nn.QuantizationFactory(quan_type, **kwargs) model = _ResNetQ(_BasicBlockQ, [2, 2, 2, 2], qf=quan_factory) if pretrained: load_pre_state_dict(model, model_zoo.load_url(model_urls['resnet18']), '{}_map.json'.format(model_name)) return model
def cifar10_vggsmall_llsq(pretrained=False, **kwargs): """VGG small model (configuration "A") Please use [dataset]_[architecture]_[quan_type] as the function name Args: pretrained (bool): If True, returns a model pre-trained on ImageNet """ model_name = sys._getframe().f_code.co_name quan_type = model_name.split('_')[-1] quan_factory = my_nn.QuantizationFactory(quan_type, **kwargs) model = _VGGQ('VGG7', quan_factory) if pretrained: load_pre_state_dict(model, model_zoo.load_url(model_urls['vgg7']), '{}_map.json'.format(model_name)) return model