Python torchvision.models.vgg13_bn() Examples
The following are 7
code examples of torchvision.models.vgg13_bn().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
torchvision.models
, or try the search function
.
Example #1
Source File: test-ww.py From AutoDL-Projects with MIT License | 6 votes |
def main(): # model = models.vgg19_bn(pretrained=True) # _, summary = weight_watcher.analyze(model, alphas=False) # for key, value in summary.items(): # print('{:10s} : {:}'.format(key, value)) _, summary = weight_watcher.analyze(models.vgg13(pretrained=True), alphas=False) print('vgg-13 : {:}'.format(summary['lognorm'])) _, summary = weight_watcher.analyze(models.vgg13_bn(pretrained=True), alphas=False) print('vgg-13-BN : {:}'.format(summary['lognorm'])) _, summary = weight_watcher.analyze(models.vgg16(pretrained=True), alphas=False) print('vgg-16 : {:}'.format(summary['lognorm'])) _, summary = weight_watcher.analyze(models.vgg16_bn(pretrained=True), alphas=False) print('vgg-16-BN : {:}'.format(summary['lognorm'])) _, summary = weight_watcher.analyze(models.vgg19(pretrained=True), alphas=False) print('vgg-19 : {:}'.format(summary['lognorm'])) _, summary = weight_watcher.analyze(models.vgg19_bn(pretrained=True), alphas=False) print('vgg-19-BN : {:}'.format(summary['lognorm']))
Example #2
Source File: featureModels.py From multi-modal-regression with MIT License | 6 votes |
def __init__(self, model_type='vgg13', layer_type='fc6'): super().__init__() # get model if model_type == 'vgg13': self.original_model = models.vgg13_bn(pretrained=True) elif model_type == 'vgg16': self.original_model = models.vgg16_bn(pretrained=True) else: raise NameError('Unknown model_type passed') self.features = self.original_model.features if layer_type == 'fc6': self.classifier = nn.Sequential(*list(self.original_model.classifier.children())[:2]) elif layer_type == 'fc7': self.classifier = nn.Sequential(*list(self.original_model.classifier.children())[:-2]) else: raise NameError('Uknown layer_type passed')
Example #3
Source File: torchvision_models.py From pretorched-x with MIT License | 5 votes |
def vgg13_bn(num_classes=1000, pretrained='imagenet'): """VGG 13-layer model (configuration "B") with batch normalization """ model = models.vgg13_bn(pretrained=False) if pretrained is not None: settings = pretrained_settings['vgg13_bn'][pretrained] model = load_pretrained(model, num_classes, settings) model = modify_vggs(model) return model
Example #4
Source File: tools.py From perceptron-benchmark with Apache License 2.0 | 5 votes |
def _load_pytorch_model(model_name, summary): import torchvision.models as models switcher = { 'alexnet': lambda: models.alexnet(pretrained=True).eval(), "vgg11": lambda: models.vgg11(pretrained=True).eval(), "vgg11_bn": lambda: models.vgg11_bn(pretrained=True).eval(), "vgg13": lambda: models.vgg13(pretrained=True).eval(), "vgg13_bn": lambda: models.vgg13_bn(pretrained=True).eval(), "vgg16": lambda: models.vgg16(pretrained=True).eval(), "vgg16_bn": lambda: models.vgg16_bn(pretrained=True).eval(), "vgg19": lambda: models.vgg19(pretrained=True).eval(), "vgg19_bn": lambda: models.vgg19_bn(pretrained=True).eval(), "resnet18": lambda: models.resnet18(pretrained=True).eval(), "resnet34": lambda: models.resnet34(pretrained=True).eval(), "resnet50": lambda: models.resnet50(pretrained=True).eval(), "resnet101": lambda: models.resnet101(pretrained=True).eval(), "resnet152": lambda: models.resnet152(pretrained=True).eval(), "squeezenet1_0": lambda: models.squeezenet1_0(pretrained=True).eval(), "squeezenet1_1": lambda: models.squeezenet1_1(pretrained=True).eval(), "densenet121": lambda: models.densenet121(pretrained=True).eval(), "densenet161": lambda: models.densenet161(pretrained=True).eval(), "densenet201": lambda: models.densenet201(pretrained=True).eval(), "inception_v3": lambda: models.inception_v3(pretrained=True).eval(), } _load_model = switcher.get(model_name, None) _model = _load_model() import torch if torch.cuda.is_available(): _model = _model.cuda() from perceptron.models.classification.pytorch import PyTorchModel as ClsPyTorchModel import numpy as np mean = np.array([0.485, 0.456, 0.406]).reshape((3, 1, 1)) std = np.array([0.229, 0.224, 0.225]).reshape((3, 1, 1)) pmodel = ClsPyTorchModel( _model, bounds=( 0, 1), num_classes=1000, preprocessing=( mean, std)) return pmodel
Example #5
Source File: tools.py From perceptron-benchmark with Apache License 2.0 | 5 votes |
def load_pytorch_model(model_name): import torchvision.models as models switcher = { 'alexnet': lambda: models.alexnet(pretrained=True).eval(), "vgg11": lambda: models.vgg11(pretrained=True).eval(), "vgg11_bn": lambda: models.vgg11_bn(pretrained=True).eval(), "vgg13": lambda: models.vgg13(pretrained=True).eval(), "vgg13_bn": lambda: models.vgg13_bn(pretrained=True).eval(), "vgg16": lambda: models.vgg16(pretrained=True).eval(), "vgg16_bn": lambda: models.vgg16_bn(pretrained=True).eval(), "vgg19": lambda: models.vgg19(pretrained=True).eval(), "vgg19_bn": lambda: models.vgg19_bn(pretrained=True).eval(), "resnet18": lambda: models.resnet18(pretrained=True).eval(), "resnet34": lambda: models.resnet34(pretrained=True).eval(), "resnet50": lambda: models.resnet50(pretrained=True).eval(), "resnet101": lambda: models.resnet101(pretrained=True).eval(), "resnet152": lambda: models.resnet152(pretrained=True).eval(), "squeezenet1_0": lambda: models.squeezenet1_0(pretrained=True).eval(), "squeezenet1_1": lambda: models.squeezenet1_1(pretrained=True).eval(), "densenet121": lambda: models.densenet121(pretrained=True).eval(), "densenet161": lambda: models.densenet161(pretrained=True).eval(), "densenet201": lambda: models.densenet201(pretrained=True).eval(), "inception_v3": lambda: models.inception_v3(pretrained=True).eval(), } _load_model = switcher.get(model_name, None) _model = _load_model() return _model
Example #6
Source File: torchvision_models.py From pretrained-models.pytorch with BSD 3-Clause "New" or "Revised" License | 5 votes |
def vgg13_bn(num_classes=1000, pretrained='imagenet'): """VGG 13-layer model (configuration "B") with batch normalization """ model = models.vgg13_bn(pretrained=False) if pretrained is not None: settings = pretrained_settings['vgg13_bn'][pretrained] model = load_pretrained(model, num_classes, settings) model = modify_vggs(model) return model
Example #7
Source File: torchvision_models.py From models-comparison.pytorch with BSD 3-Clause "New" or "Revised" License | 5 votes |
def vgg13_bn(num_classes=1000, pretrained='imagenet'): """VGG 13-layer model (configuration "B") with batch normalization """ model = models.vgg13_bn(pretrained=False) if pretrained is not None: settings = pretrained_settings['vgg13_bn'][pretrained] model = load_pretrained(model, num_classes, settings) return model