From b55232d4ad1051c48b67ae2a1370fe4d3e5958eb Mon Sep 17 00:00:00 2001 From: "Joshua Z. Zhang" Date: Mon, 15 Oct 2018 19:35:30 -0700 Subject: [PATCH] force mxnet>=1.3.0, replace load_params with load_parameters (#398) * force mxnet>=1.3.0, replace load_params with load_parameters * fix pylint --- .../classification/dive_deep_cifar10.py | 2 +- gluoncv/__init__.py | 9 ++- gluoncv/model_zoo/cifarresnet.py | 4 +- gluoncv/model_zoo/cifarresnext.py | 6 +- gluoncv/model_zoo/cifarwideresnet.py | 4 +- gluoncv/model_zoo/nasnet.py | 4 +- gluoncv/model_zoo/resnetv1b.py | 68 +++++++++---------- gluoncv/model_zoo/resnext.py | 12 ++-- gluoncv/model_zoo/se_resnet.py | 4 +- gluoncv/model_zoo/senet.py | 4 +- gluoncv/model_zoo/ssd/ssd.py | 2 +- gluoncv/model_zoo/ssd/vgg_atrous.py | 4 +- gluoncv/model_zoo/yolo/yolo3.py | 2 +- scripts/classification/cifar/demo_cifar10.py | 2 +- scripts/classification/cifar/train_cifar10.py | 2 +- .../cifar/train_mixup_cifar10.py | 2 +- .../classification/imagenet/demo_imagenet.py | 2 +- .../imagenet/verify_pretrained.py | 2 +- scripts/detection/ssd/demo_ssd.py | 2 +- scripts/detection/ssd/eval_ssd.py | 2 +- scripts/detection/ssd/train_ssd.py | 2 +- scripts/detection/yolo/eval_yolo.py | 2 +- scripts/gan/wgan/train_wgan.py | 4 +- 23 files changed, 73 insertions(+), 74 deletions(-) diff --git a/docs/tutorials/classification/dive_deep_cifar10.py b/docs/tutorials/classification/dive_deep_cifar10.py index 7a7f97ce3a..736589e677 100644 --- a/docs/tutorials/classification/dive_deep_cifar10.py +++ b/docs/tutorials/classification/dive_deep_cifar10.py @@ -317,7 +317,7 @@ def test(ctx, val_data): ################################################################ # Next time if you need to use it, just run -net.load_params('dive_deep_cifar10_resnet20_v2.params', ctx=ctx) +net.load_parameters('dive_deep_cifar10_resnet20_v2.params', ctx=ctx) ################################################################ # Next Step diff --git a/gluoncv/__init__.py b/gluoncv/__init__.py index 130e4e1505..2bab87d28a 100644 --- a/gluoncv/__init__.py +++ b/gluoncv/__init__.py @@ -7,18 +7,17 @@ mx_version = '1.3.0' try: import mxnet as mx - import warnings from distutils.version import LooseVersion if LooseVersion(mx.__version__) < LooseVersion(mx_version): msg = ( "Legacy mxnet=={} detected, some new modules may not work properly. " - "mxnet>={} is recommended. You can use pip to upgrade mxnet " - "`pip install mxnet --pre --upgrade`").format(mx.__version__, mx_version) - warnings.warn(msg) + "mxnet>={} is required. You can use pip to upgrade mxnet " + "`pip install mxnet/mxnet-cu90 --pre --upgrade`").format(mx.__version__, mx_version) + raise ImportError(msg) except ImportError: raise ImportError( "Unable to import dependency mxnet. " - "A quick tip is to install via `pip install mxnet --pre`. " + "A quick tip is to install via `pip install mxnet/mxnet-cu90 --pre`. " "please refer to https://gluon-cv.mxnet.io/#installation for details.") __version__ = '0.3.0' diff --git a/gluoncv/model_zoo/cifarresnet.py b/gluoncv/model_zoo/cifarresnet.py index 938be859f9..58f1c5f855 100644 --- a/gluoncv/model_zoo/cifarresnet.py +++ b/gluoncv/model_zoo/cifarresnet.py @@ -269,8 +269,8 @@ def get_cifar_resnet(version, num_layers, pretrained=False, ctx=cpu(), net = resnet_class(block_class, layers, channels, **kwargs) if pretrained: from .model_store import get_model_file - net.load_params(get_model_file('cifar_resnet%d_v%d'%(num_layers, version), - tag=pretrained, root=root), ctx=ctx) + net.load_parameters(get_model_file('cifar_resnet%d_v%d'%(num_layers, version), + tag=pretrained, root=root), ctx=ctx) return net def cifar_resnet20_v1(**kwargs): diff --git a/gluoncv/model_zoo/cifarresnext.py b/gluoncv/model_zoo/cifarresnext.py index 13ae03931e..4b8e12ec4a 100644 --- a/gluoncv/model_zoo/cifarresnext.py +++ b/gluoncv/model_zoo/cifarresnext.py @@ -163,9 +163,9 @@ def get_cifar_resnext(num_layers, cardinality=16, bottleneck_width=64, net = CIFARResNext(layers, cardinality, bottleneck_width, **kwargs) if pretrained: from .model_store import get_model_file - net.load_params(get_model_file('cifar_resnext%d_%dx%dd'%(num_layers, cardinality, - bottleneck_width), - tag=pretrained, root=root), ctx=ctx) + net.load_parameters(get_model_file('cifar_resnext%d_%dx%dd'%(num_layers, cardinality, + bottleneck_width), + tag=pretrained, root=root), ctx=ctx) return net def cifar_resnext29_32x4d(**kwargs): diff --git a/gluoncv/model_zoo/cifarwideresnet.py b/gluoncv/model_zoo/cifarwideresnet.py index dec2feacfb..c77d63439b 100644 --- a/gluoncv/model_zoo/cifarwideresnet.py +++ b/gluoncv/model_zoo/cifarwideresnet.py @@ -166,8 +166,8 @@ def get_cifar_wide_resnet(num_layers, width_factor=1, drop_rate=0.0, net = CIFARWideResNet(CIFARBasicBlockV2, layers, channels, drop_rate, **kwargs) if pretrained: from .model_store import get_model_file - net.load_params(get_model_file('cifar_wideresnet%d_%d'%(num_layers, width_factor), - tag=pretrained, root=root), ctx=ctx) + net.load_parameters(get_model_file('cifar_wideresnet%d_%d'%(num_layers, width_factor), + tag=pretrained, root=root), ctx=ctx) return net def cifar_wideresnet16_10(**kwargs): diff --git a/gluoncv/model_zoo/nasnet.py b/gluoncv/model_zoo/nasnet.py index 3b5cc53716..09aadb8c05 100644 --- a/gluoncv/model_zoo/nasnet.py +++ b/gluoncv/model_zoo/nasnet.py @@ -620,8 +620,8 @@ def get_nasnet(repeat=6, penultimate_filters=4032, net = NASNetALarge(repeat=repeat, penultimate_filters=penultimate_filters, **kwargs) if pretrained: from .model_store import get_model_file - net.load_params(get_model_file('nasnet_%d_%d'%(repeat, penultimate_filters), - tag=pretrained, root=root), ctx=ctx) + net.load_parameters(get_model_file('nasnet_%d_%d'%(repeat, penultimate_filters), + tag=pretrained, root=root), ctx=ctx) from ..data import ImageNet1kAttr attrib = ImageNet1kAttr() net.synset = attrib.synset diff --git a/gluoncv/model_zoo/resnetv1b.py b/gluoncv/model_zoo/resnetv1b.py index 433c98e231..74e26be8f4 100644 --- a/gluoncv/model_zoo/resnetv1b.py +++ b/gluoncv/model_zoo/resnetv1b.py @@ -279,8 +279,8 @@ def resnet18_v1b(pretrained=False, root='~/.mxnet/models', ctx=cpu(0), **kwargs) model = ResNetV1b(BasicBlockV1b, [2, 2, 2, 2], **kwargs) if pretrained: from .model_store import get_model_file - model.load_params(get_model_file('resnet%d_v%db'%(18, 1), - tag=pretrained, root=root), ctx=ctx) + model.load_parameters(get_model_file('resnet%d_v%db'%(18, 1), + tag=pretrained, root=root), ctx=ctx) from ..data import ImageNet1kAttr attrib = ImageNet1kAttr() model.synset = attrib.synset @@ -314,8 +314,8 @@ def resnet34_v1b(pretrained=False, root='~/.mxnet/models', ctx=cpu(0), **kwargs) model = ResNetV1b(BasicBlockV1b, [3, 4, 6, 3], **kwargs) if pretrained: from .model_store import get_model_file - model.load_params(get_model_file('resnet%d_v%db'%(34, 1), - tag=pretrained, root=root), ctx=ctx) + model.load_parameters(get_model_file('resnet%d_v%db'%(34, 1), + tag=pretrained, root=root), ctx=ctx) from ..data import ImageNet1kAttr attrib = ImageNet1kAttr() model.synset = attrib.synset @@ -349,8 +349,8 @@ def resnet50_v1b(pretrained=False, root='~/.mxnet/models', ctx=cpu(0), **kwargs) model = ResNetV1b(BottleneckV1b, [3, 4, 6, 3], **kwargs) if pretrained: from .model_store import get_model_file - model.load_params(get_model_file('resnet%d_v%db'%(50, 1), - tag=pretrained, root=root), ctx=ctx) + model.load_parameters(get_model_file('resnet%d_v%db'%(50, 1), + tag=pretrained, root=root), ctx=ctx) from ..data import ImageNet1kAttr attrib = ImageNet1kAttr() model.synset = attrib.synset @@ -384,8 +384,8 @@ def resnet101_v1b(pretrained=False, root='~/.mxnet/models', ctx=cpu(0), **kwargs model = ResNetV1b(BottleneckV1b, [3, 4, 23, 3], **kwargs) if pretrained: from .model_store import get_model_file - model.load_params(get_model_file('resnet%d_v%db'%(101, 1), - tag=pretrained, root=root), ctx=ctx) + model.load_parameters(get_model_file('resnet%d_v%db'%(101, 1), + tag=pretrained, root=root), ctx=ctx) from ..data import ImageNet1kAttr attrib = ImageNet1kAttr() model.synset = attrib.synset @@ -419,8 +419,8 @@ def resnet152_v1b(pretrained=False, root='~/.mxnet/models', ctx=cpu(0), **kwargs model = ResNetV1b(BottleneckV1b, [3, 8, 36, 3], **kwargs) if pretrained: from .model_store import get_model_file - model.load_params(get_model_file('resnet%d_v%db'%(152, 1), - tag=pretrained, root=root), ctx=ctx) + model.load_parameters(get_model_file('resnet%d_v%db'%(152, 1), + tag=pretrained, root=root), ctx=ctx) from ..data import ImageNet1kAttr attrib = ImageNet1kAttr() model.synset = attrib.synset @@ -448,8 +448,8 @@ def resnet50_v1c(pretrained=False, root='~/.mxnet/models', ctx=cpu(0), **kwargs) model = ResNetV1b(BottleneckV1b, [3, 4, 6, 3], deep_stem=True, **kwargs) if pretrained: from .model_store import get_model_file - model.load_params(get_model_file('resnet%d_v%dc'%(50, 1), - tag=pretrained, root=root), ctx=ctx) + model.load_parameters(get_model_file('resnet%d_v%dc'%(50, 1), + tag=pretrained, root=root), ctx=ctx) from ..data import ImageNet1kAttr attrib = ImageNet1kAttr() model.synset = attrib.synset @@ -478,8 +478,8 @@ def resnet101_v1c(pretrained=False, root='~/.mxnet/models', ctx=cpu(0), **kwargs model = ResNetV1b(BottleneckV1b, [3, 4, 23, 3], deep_stem=True, **kwargs) if pretrained: from .model_store import get_model_file - model.load_params(get_model_file('resnet%d_v%dc'%(101, 1), - tag=pretrained, root=root), ctx=ctx) + model.load_parameters(get_model_file('resnet%d_v%dc'%(101, 1), + tag=pretrained, root=root), ctx=ctx) from ..data import ImageNet1kAttr attrib = ImageNet1kAttr() model.synset = attrib.synset @@ -507,8 +507,8 @@ def resnet152_v1c(pretrained=False, root='~/.mxnet/models', ctx=cpu(0), **kwargs model = ResNetV1b(BottleneckV1b, [3, 8, 36, 3], deep_stem=True, **kwargs) if pretrained: from .model_store import get_model_file - model.load_params(get_model_file('resnet%d_v%dc'%(152, 1), - tag=pretrained, root=root), ctx=ctx) + model.load_parameters(get_model_file('resnet%d_v%dc'%(152, 1), + tag=pretrained, root=root), ctx=ctx) from ..data import ImageNet1kAttr attrib = ImageNet1kAttr() model.synset = attrib.synset @@ -536,8 +536,8 @@ def resnet50_v1d(pretrained=False, root='~/.mxnet/models', ctx=cpu(0), **kwargs) model = ResNetV1b(BottleneckV1b, [3, 4, 6, 3], deep_stem=True, avg_down=True, **kwargs) if pretrained: from .model_store import get_model_file - model.load_params(get_model_file('resnet%d_v%dd'%(50, 1), - tag=pretrained, root=root), ctx=ctx) + model.load_parameters(get_model_file('resnet%d_v%dd'%(50, 1), + tag=pretrained, root=root), ctx=ctx) from ..data import ImageNet1kAttr attrib = ImageNet1kAttr() model.synset = attrib.synset @@ -565,8 +565,8 @@ def resnet101_v1d(pretrained=False, root='~/.mxnet/models', ctx=cpu(0), **kwargs model = ResNetV1b(BottleneckV1b, [3, 4, 23, 3], deep_stem=True, avg_down=True, **kwargs) if pretrained: from .model_store import get_model_file - model.load_params(get_model_file('resnet%d_v%dd'%(101, 1), - tag=pretrained, root=root), ctx=ctx) + model.load_parameters(get_model_file('resnet%d_v%dd'%(101, 1), + tag=pretrained, root=root), ctx=ctx) from ..data import ImageNet1kAttr attrib = ImageNet1kAttr() model.synset = attrib.synset @@ -594,8 +594,8 @@ def resnet152_v1d(pretrained=False, root='~/.mxnet/models', ctx=cpu(0), **kwargs model = ResNetV1b(BottleneckV1b, [3, 8, 36, 3], deep_stem=True, avg_down=True, **kwargs) if pretrained: from .model_store import get_model_file - model.load_params(get_model_file('resnet%d_v%dd'%(152, 1), - tag=pretrained, root=root), ctx=ctx) + model.load_parameters(get_model_file('resnet%d_v%dd'%(152, 1), + tag=pretrained, root=root), ctx=ctx) from ..data import ImageNet1kAttr attrib = ImageNet1kAttr() model.synset = attrib.synset @@ -624,8 +624,8 @@ def resnet50_v1e(pretrained=False, root='~/.mxnet/models', ctx=cpu(0), **kwargs) deep_stem=True, avg_down=True, stem_width=64, **kwargs) if pretrained: from .model_store import get_model_file - model.load_params(get_model_file('resnet%d_v%dd'%(50, 1), - tag=pretrained, root=root), ctx=ctx) + model.load_parameters(get_model_file('resnet%d_v%dd'%(50, 1), + tag=pretrained, root=root), ctx=ctx) from ..data import ImageNet1kAttr attrib = ImageNet1kAttr() model.synset = attrib.synset @@ -654,8 +654,8 @@ def resnet101_v1e(pretrained=False, root='~/.mxnet/models', ctx=cpu(0), **kwargs deep_stem=True, avg_down=True, stem_width=64, **kwargs) if pretrained: from .model_store import get_model_file - model.load_params(get_model_file('resnet%d_v%dd'%(101, 1), - tag=pretrained, root=root), ctx=ctx) + model.load_parameters(get_model_file('resnet%d_v%dd'%(101, 1), + tag=pretrained, root=root), ctx=ctx) from ..data import ImageNet1kAttr attrib = ImageNet1kAttr() model.synset = attrib.synset @@ -684,8 +684,8 @@ def resnet152_v1e(pretrained=False, root='~/.mxnet/models', ctx=cpu(0), **kwargs deep_stem=True, avg_down=True, stem_width=64, **kwargs) if pretrained: from .model_store import get_model_file - model.load_params(get_model_file('resnet%d_v%dd'%(152, 1), - tag=pretrained, root=root), ctx=ctx) + model.load_parameters(get_model_file('resnet%d_v%dd'%(152, 1), + tag=pretrained, root=root), ctx=ctx) from ..data import ImageNet1kAttr attrib = ImageNet1kAttr() model.synset = attrib.synset @@ -714,8 +714,8 @@ def resnet50_v1s(pretrained=False, root='~/.mxnet/models', ctx=cpu(0), **kwargs) model = ResNetV1b(BottleneckV1b, [3, 4, 6, 3], deep_stem=True, stem_width=64, **kwargs) if pretrained: from .model_store import get_model_file - model.load_params(get_model_file('resnet%d_v%ds'%(50, 1), - tag=pretrained, root=root), ctx=ctx) + model.load_parameters(get_model_file('resnet%d_v%ds'%(50, 1), + tag=pretrained, root=root), ctx=ctx) from ..data import ImageNet1kAttr attrib = ImageNet1kAttr() model.synset = attrib.synset @@ -744,8 +744,8 @@ def resnet101_v1s(pretrained=False, root='~/.mxnet/models', ctx=cpu(0), **kwargs model = ResNetV1b(BottleneckV1b, [3, 4, 23, 3], deep_stem=True, stem_width=64, **kwargs) if pretrained: from .model_store import get_model_file - model.load_params(get_model_file('resnet%d_v%ds'%(101, 1), - tag=pretrained, root=root), ctx=ctx) + model.load_parameters(get_model_file('resnet%d_v%ds'%(101, 1), + tag=pretrained, root=root), ctx=ctx) from ..data import ImageNet1kAttr attrib = ImageNet1kAttr() model.synset = attrib.synset @@ -774,8 +774,8 @@ def resnet152_v1s(pretrained=False, root='~/.mxnet/models', ctx=cpu(0), **kwargs model = ResNetV1b(BottleneckV1b, [3, 8, 36, 3], deep_stem=True, stem_width=64, **kwargs) if pretrained: from .model_store import get_model_file - model.load_params(get_model_file('resnet%d_v%ds'%(152, 1), - tag=pretrained, root=root), ctx=ctx) + model.load_parameters(get_model_file('resnet%d_v%ds'%(152, 1), + tag=pretrained, root=root), ctx=ctx) from ..data import ImageNet1kAttr attrib = ImageNet1kAttr() model.synset = attrib.synset diff --git a/gluoncv/model_zoo/resnext.py b/gluoncv/model_zoo/resnext.py index a2cea01f14..f83a203c86 100644 --- a/gluoncv/model_zoo/resnext.py +++ b/gluoncv/model_zoo/resnext.py @@ -203,13 +203,13 @@ def get_resnext(num_layers, cardinality=32, bottleneck_width=4, use_se=False, if pretrained: from .model_store import get_model_file if not use_se: - net.load_params(get_model_file('resnext%d_%dx%dd'%(num_layers, cardinality, - bottleneck_width), - tag=pretrained, root=root), ctx=ctx) + net.load_parameters(get_model_file('resnext%d_%dx%dd'%(num_layers, cardinality, + bottleneck_width), + tag=pretrained, root=root), ctx=ctx) else: - net.load_params(get_model_file('se_resnext%d_%dx%dd'%(num_layers, cardinality, - bottleneck_width), - tag=pretrained, root=root), ctx=ctx) + net.load_parameters(get_model_file('se_resnext%d_%dx%dd'%(num_layers, cardinality, + bottleneck_width), + tag=pretrained, root=root), ctx=ctx) from ..data import ImageNet1kAttr attrib = ImageNet1kAttr() net.synset = attrib.synset diff --git a/gluoncv/model_zoo/se_resnet.py b/gluoncv/model_zoo/se_resnet.py index 91b2ba0c19..0d032b0395 100644 --- a/gluoncv/model_zoo/se_resnet.py +++ b/gluoncv/model_zoo/se_resnet.py @@ -432,8 +432,8 @@ def get_se_resnet(version, num_layers, pretrained=False, ctx=cpu(), net = resnet_class(block_class, layers, channels, **kwargs) if pretrained: from .model_store import get_model_file - net.load_params(get_model_file('se_resnet%d_v%d'%(num_layers, version), - tag=pretrained, root=root), ctx=ctx) + net.load_parameters(get_model_file('se_resnet%d_v%d'%(num_layers, version), + tag=pretrained, root=root), ctx=ctx) from ..data import ImageNet1kAttr attrib = ImageNet1kAttr() net.synset = attrib.synset diff --git a/gluoncv/model_zoo/senet.py b/gluoncv/model_zoo/senet.py index cceea71b29..dc1d2a7e5d 100644 --- a/gluoncv/model_zoo/senet.py +++ b/gluoncv/model_zoo/senet.py @@ -195,8 +195,8 @@ def get_senet(num_layers, cardinality=64, bottleneck_width=4, net = SENet(layers, cardinality, bottleneck_width, **kwargs) if pretrained: from .model_store import get_model_file - net.load_params(get_model_file('senet_%d'%(num_layers+2), - root=root), ctx=ctx) + net.load_parameters(get_model_file('senet_%d'%(num_layers+2), + root=root), ctx=ctx) from ..data import ImageNet1kAttr attrib = ImageNet1kAttr() net.synset = attrib.synset diff --git a/gluoncv/model_zoo/ssd/ssd.py b/gluoncv/model_zoo/ssd/ssd.py index c098c616dd..3971893b95 100644 --- a/gluoncv/model_zoo/ssd/ssd.py +++ b/gluoncv/model_zoo/ssd/ssd.py @@ -299,7 +299,7 @@ def get_ssd(name, base_size, features, filters, sizes, ratios, steps, classes, if pretrained: from ..model_store import get_model_file full_name = '_'.join(('ssd', str(base_size), name, dataset)) - net.load_params(get_model_file(full_name, tag=pretrained, root=root), ctx=ctx) + net.load_parameters(get_model_file(full_name, tag=pretrained, root=root), ctx=ctx) return net def ssd_300_vgg16_atrous_voc(pretrained=False, pretrained_base=True, **kwargs): diff --git a/gluoncv/model_zoo/ssd/vgg_atrous.py b/gluoncv/model_zoo/ssd/vgg_atrous.py index 713febe0ae..d1e4ab52f7 100644 --- a/gluoncv/model_zoo/ssd/vgg_atrous.py +++ b/gluoncv/model_zoo/ssd/vgg_atrous.py @@ -196,8 +196,8 @@ def get_vgg_atrous_extractor(num_layers, im_size, pretrained=False, ctx=mx.cpu() from ..model_store import get_model_file batch_norm_suffix = '_bn' if kwargs.get('batch_norm') else '' net.initialize(ctx=ctx) - net.load_params(get_model_file('vgg%d_atrous%s'%(num_layers, batch_norm_suffix), - tag=pretrained, root=root), ctx=ctx, allow_missing=True) + net.load_parameters(get_model_file('vgg%d_atrous%s'%(num_layers, batch_norm_suffix), + tag=pretrained, root=root), ctx=ctx, allow_missing=True) return net def vgg16_atrous_300(**kwargs): diff --git a/gluoncv/model_zoo/yolo/yolo3.py b/gluoncv/model_zoo/yolo/yolo3.py index 70f5da194e..a0f961b451 100644 --- a/gluoncv/model_zoo/yolo/yolo3.py +++ b/gluoncv/model_zoo/yolo/yolo3.py @@ -475,7 +475,7 @@ def get_yolov3(name, stages, filters, anchors, strides, classes, if pretrained: from ..model_store import get_model_file full_name = '_'.join(('yolo3', name, dataset)) - net.load_params(get_model_file(full_name, tag=pretrained, root=root), ctx=ctx) + net.load_parameters(get_model_file(full_name, tag=pretrained, root=root), ctx=ctx) return net def yolo3_darknet53_voc(pretrained_base=True, pretrained=False, num_sync_bn_devices=-1, **kwargs): diff --git a/scripts/classification/cifar/demo_cifar10.py b/scripts/classification/cifar/demo_cifar10.py index 8871ab7e60..71567afae2 100644 --- a/scripts/classification/cifar/demo_cifar10.py +++ b/scripts/classification/cifar/demo_cifar10.py @@ -31,7 +31,7 @@ net = get_model(model_name, **kwargs) if not pretrained: - net.load_params(opt.saved_params, ctx = context) + net.load_parameters(opt.saved_params, ctx = context) # Load Images img = image.imread(opt.input_pic) diff --git a/scripts/classification/cifar/train_cifar10.py b/scripts/classification/cifar/train_cifar10.py index f14effb8df..c7058c9c80 100644 --- a/scripts/classification/cifar/train_cifar10.py +++ b/scripts/classification/cifar/train_cifar10.py @@ -72,7 +72,7 @@ kwargs = {'classes': classes} net = get_model(model_name, **kwargs) if opt.resume_from: - net.load_params(opt.resume_from, ctx = context) + net.load_parameters(opt.resume_from, ctx = context) optimizer = 'nag' save_period = opt.save_period diff --git a/scripts/classification/cifar/train_mixup_cifar10.py b/scripts/classification/cifar/train_mixup_cifar10.py index 0c597fbe29..df36f700e6 100644 --- a/scripts/classification/cifar/train_mixup_cifar10.py +++ b/scripts/classification/cifar/train_mixup_cifar10.py @@ -83,7 +83,7 @@ net = get_model(model_name, **kwargs) model_name += '_mixup' if opt.resume_from: - net.load_params(opt.resume_from, ctx = context) + net.load_parameters(opt.resume_from, ctx = context) optimizer = 'nag' save_period = opt.save_period diff --git a/scripts/classification/imagenet/demo_imagenet.py b/scripts/classification/imagenet/demo_imagenet.py index 3de9bb00a0..c81e24f121 100644 --- a/scripts/classification/imagenet/demo_imagenet.py +++ b/scripts/classification/imagenet/demo_imagenet.py @@ -23,7 +23,7 @@ net = get_model(model_name, pretrained=True) if not pretrained: - net.load_params(opt.saved_params) + net.load_parameters(opt.saved_params) # Load Images img = image.imread(opt.input_pic) diff --git a/scripts/classification/imagenet/verify_pretrained.py b/scripts/classification/imagenet/verify_pretrained.py index 66f80cacca..df3f5d7f77 100644 --- a/scripts/classification/imagenet/verify_pretrained.py +++ b/scripts/classification/imagenet/verify_pretrained.py @@ -54,7 +54,7 @@ net = get_model(model_name, **kwargs) net.cast(opt.dtype) if opt.params_file: - net.load_params(opt.params_file, ctx=ctx) + net.load_parameters(opt.params_file, ctx=ctx) net.hybridize() acc_top1 = mx.metric.Accuracy() diff --git a/scripts/detection/ssd/demo_ssd.py b/scripts/detection/ssd/demo_ssd.py index 0e8f12efa6..873e4aeca8 100644 --- a/scripts/detection/ssd/demo_ssd.py +++ b/scripts/detection/ssd/demo_ssd.py @@ -37,7 +37,7 @@ def parse_args(): net = gcv.model_zoo.get_model(args.network, pretrained=True) else: net = gcv.model_zoo.get_model(args.network, pretrained=False, pretrained_base=False) - net.load_params(args.pretrained) + net.load_parameters(args.pretrained) net.set_nms(0.45, 200) net.collect_params().reset_ctx(ctx = ctx) diff --git a/scripts/detection/ssd/eval_ssd.py b/scripts/detection/ssd/eval_ssd.py index 2f04e8da5e..d75ea81cad 100644 --- a/scripts/detection/ssd/eval_ssd.py +++ b/scripts/detection/ssd/eval_ssd.py @@ -105,7 +105,7 @@ def validate(net, val_data, ctx, classes, size, metric): net = gcv.model_zoo.get_model(net_name, pretrained=True) else: net = gcv.model_zoo.get_model(net_name, pretrained=False) - net.load_params(args.pretrained.strip()) + net.load_parameters(args.pretrained.strip()) # training data val_dataset, val_metric = get_dataset(args.dataset, args.data_shape) diff --git a/scripts/detection/ssd/train_ssd.py b/scripts/detection/ssd/train_ssd.py index 11bf14ec7e..d3a9c2cfd6 100644 --- a/scripts/detection/ssd/train_ssd.py +++ b/scripts/detection/ssd/train_ssd.py @@ -237,7 +237,7 @@ def train(net, train_data, val_data, eval_metric, ctx, args): args.save_prefix += net_name net = get_model(net_name, pretrained_base=True) if args.resume.strip(): - net.load_params(args.resume.strip()) + net.load_parameters(args.resume.strip()) else: for param in net.collect_params().values(): if param._data is not None: diff --git a/scripts/detection/yolo/eval_yolo.py b/scripts/detection/yolo/eval_yolo.py index 383cfca335..089ff14bf2 100644 --- a/scripts/detection/yolo/eval_yolo.py +++ b/scripts/detection/yolo/eval_yolo.py @@ -107,7 +107,7 @@ def validate(net, val_data, ctx, classes, size, metric): net = gcv.model_zoo.get_model(net_name, pretrained=True) else: net = gcv.model_zoo.get_model(net_name, pretrained=False) - net.load_params(args.pretrained.strip()) + net.load_parameters(args.pretrained.strip()) # training data val_dataset, val_metric = get_dataset(args.dataset, args.data_shape) diff --git a/scripts/gan/wgan/train_wgan.py b/scripts/gan/wgan/train_wgan.py index 9ce84ce2a8..5a78e6af83 100644 --- a/scripts/gan/wgan/train_wgan.py +++ b/scripts/gan/wgan/train_wgan.py @@ -404,7 +404,7 @@ def weights_init(layers): netG.initialize(mx.init.Xavier(factor_type='in',magnitude=0.01),ctx=context) weights_init(netG.main) if opt.netG != '': # load checkpoint if needed - netG.load_params(opt.netG) + netG.load_parameters(opt.netG) print(netG) if opt.mlp_D: @@ -415,7 +415,7 @@ def weights_init(layers): netD.initialize(mx.init.Xavier(factor_type='in',magnitude=0.01), ctx=context) weights_init(netD.main) if opt.netD != '': - netD.load_params(opt.netD) + netD.load_parameters(opt.netD) print(netD) input = mx.nd.zeros((opt.batchSize, 3, opt.imageSize, opt.imageSize))