Skip to content

Commit

Permalink
fix pretty print (apache#7254)
Browse files Browse the repository at this point in the history
* fix pretty print

* add tests
  • Loading branch information
szha authored and piiswrong committed Jul 30, 2017
1 parent 13bcb5a commit 37e40be
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/mxnet/gluon/model_zoo/custom_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""Custom neural network layers in model_zoo."""

from ..block import Block, HybridBlock
from ..utils import _indent

class HybridConcurrent(HybridBlock):
"""Lays `HybridBlock`s concurrently.
Expand Down
22 changes: 22 additions & 0 deletions tests/python/unittest/test_gluon_model_zoo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import print_function
import mxnet as mx
from mxnet.gluon import nn
from mxnet.gluon.model_zoo.custom_layers import HybridConcurrent, Identity
from mxnet.gluon.model_zoo.vision import get_model


def test_concurrent():
Expand Down Expand Up @@ -28,6 +30,26 @@ def test_identity():
x.asnumpy())


def test_models():
all_models = ['resnet18_v1', 'resnet34_v1', 'resnet50_v1', 'resnet101_v1', 'resnet152_v1',
'resnet18_v2', 'resnet34_v2', 'resnet50_v2', 'resnet101_v2', 'resnet152_v2',
'vgg11', 'vgg13', 'vgg16', 'vgg19',
'vgg11_bn', 'vgg13_bn', 'vgg16_bn', 'vgg19_bn',
'alexnet', 'inceptionv3',
'densenet121', 'densenet161', 'densenet169', 'densenet201',
'squeezenet1.0', 'squeezenet1.1']
pretrained_to_test = set(['squeezenet1.1'])

for model_name in all_models:
test_pretrain = model_name in pretrained_to_test
model = get_model(model_name, pretrained=test_pretrain)
data_shape = (7, 3, 224, 224) if 'inception' not in model_name else (7, 3, 299, 299)
print(model)
if not test_pretrain:
model.collect_params().initialize()
model(mx.nd.random_uniform(shape=data_shape))


if __name__ == '__main__':
import nose
nose.runmodule()

0 comments on commit 37e40be

Please sign in to comment.