8000 squeezenet.py for MXNet-master by jinboci · Pull Request #1521 · dmlc/gluon-cv · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

squeezenet.py for MXNet-master #1521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 85 commits into from
Dec 18, 2020
Merged

Conversation

jinboci
Copy link
@jinboci jinboci commented Nov 12, 2020

squeezenet for MXNet-master
Have Not Passed tests for squeezenet.py at test_imagenet_models() in test_model_zoo.py on my local sever:

$ python /home/ubuntu/Documents/gluon-cv/tests/model_zoo/test_model_zoo.py
[19:55:44] ../src/storage/storage.cc:199: Using Pooled (Naive) StorageManager for CPU
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS.INFO:root:Model file not found. Downloading.
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): apache-mxnet.s3-accelerate.dualstack.amazonaws.com:443
DEBUG:urllib3.connectionpool:https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com:443 "GET /gluon/models/squeezenet1.0-264ba497.zip HTTP/1.1" 200 4660838
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4552/4552 [00:00<00:00, 6706.61KB/s]
F
======================================================================
FAIL: __main__.test_imagenet_models
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/ubuntu/Documents/gluon-cv/tests/model_zoo/test_model_zoo.py", line 155, in test_imagenet_models
    _test_model_list(models, ctx, x)
  File "/home/ubuntu/Documents/gluon-cv/tests/model_zoo/test_model_zoo.py", line 49, in _test_model_list
    net = gcv.model_zoo.get_model(model, pretrained=True, **kwargs)
  File "/home/ubuntu/.local/lib/python3.7/site-packages/gluoncv-0.9.0-py3.7.egg/gluoncv/model_zoo/model_zoo.py", line 403, in get_model
    net = _models[name](**kwargs)
  File "/home/ubuntu/.local/lib/python3.7/site-packages/gluoncv-0.9.0-py3.7.egg/gluoncv/model_zoo/squeezenet.py", line 160, in squeezenet1_0
    return get_squeezenet('1.0', **kwargs)
  File "/home/ubuntu/.local/lib/python3.7/site-packages/gluoncv-0.9.0-py3.7.egg/gluoncv/model_zoo/squeezenet.py", line 138, in get_squeezenet
    tag=pretrained, root=root), ctx=ctx)
  File "/home/ubuntu/Documents/mxnet/python/mxnet/util.py", line 298, in _with_np_shape
    return func(*args, **kwargs)
  File "/home/ubuntu/Documents/mxnet/python/mxnet/util.py", line 482, in _with_np_array
    return func(*args, **kwargs)
  File "/home/ubuntu/Documents/mxnet/python/mxnet/gluon/block.py", line 429, in load_parameters
    self.load_dict(full_dict, ctx, allow_missing, ignore_extra, cast_dtype, dtype_source)
  File "/home/ubuntu/Documents/mxnet/python/mxnet/util.py", line 298, in _with_np_shape
    return func(*args, **kwargs)
  File "/home/ubuntu/Documents/mxnet/python/mxnet/util.py", line 482, in _with_np_array
    return func(*args, **kwargs)
  File "/home/ubuntu/Documents/mxnet/python/mxnet/gluon/block.py", line 474, in load_dict
    name, error_str, _brief_print_list(loaded.keys()))
AssertionError: Parameter 'features.0.weight' is missing in 'file: /home/ubuntu/.mxnet/models/squeezenet1.0-264ba497.params', which contains parameters: 'conv25_bias', 'conv20_bias', 'conv15_weight', ..., 'conv25_weight', 'conv20_weight', 'conv19_bias', 'conv10_bias'. Set allow_missing=True to ignore missing parameters.
-------------------- >> begin captured stdout << ---------------------
Downloading /home/ubuntu/.mxnet/models/squeezenet1.0-264ba497.zip from https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/models/squeezenet1.0-264ba497.zip...

--------------------- >> end captured stdout << ----------------------
-------------------- >> begin captured logging << --------------------
root: INFO: Model file not found. Downloading.
urllib3.connectionpool: DEBUG: Starting new HTTPS connection (1): apache-mxnet.s3-accelerate.dualstack.amazonaws.com:443
urllib3.connectionpool: DEBUG: https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com:443 "GET /gluon/models/squeezenet1.0-264ba497.zip HTTP/1.1" 200 4660838
--------------------- >> end captured logging << ----
10000
-----------------

----------------------------------------------------------------------
Ran 36 tests in 41.110s

FAILED (SKIP=34, failures=1)

Debugging:

(Pdb) loaded.keys()
dict_keys(['conv25_bias', 'conv20_bias', 'conv15_weight', 'conv23_weight', 'conv3_weight', 'conv17_weight', 'conv14_weight', 'conv11_bias', 'conv21_weight', 'conv24_bias', 'conv3_bias', 'conv15_bias', 'conv23_bias', 'conv6_weight', 'conv14_bias', 'conv22_bias', 'conv19_weight', 'conv17_bias', 'conv24_weight', 'conv0_weight', 'conv7_weight', 'conv4_weight', 'conv2_bias', 'conv9_weight', 'conv12_weight', 'conv1_weight', 'conv8_weight', 'conv16_weight', 'conv18_weight', 'conv16_bias', 'conv7_bias', 'conv12_bias', 'conv4_bias', 'conv11_weight', 'conv9_bias', 'conv21_bias', 'conv8_bias', 'conv22_weight', 'conv0_bias', 'conv18_bias', 'conv5_bias', 'conv13_weight', 'conv1_bias', 'conv10_weight', 'conv13_bias', 'conv5_weight', 'conv2_weight', 'conv6_bias', 'conv25_weight', 'conv20_weight', 'conv19_bias', 'conv10_bias'])
(Pdb) params.keys()
dict_keys(['features.0.weight', 'features.0.bias', 'features.3.0.0.weight', 'features.3.0.0.bias', 'features.3.1.0.0.weight', 'features.3.1.0.0.bias', 'features.3.1.1.0.weight', 'features.3.1.1.0.bias', 'features.4.0.0.weight', 'features.4.0.0.bias', 'features.4.1.0.0.weight', 'features.4.1.0.0.bias', 'features.4.1.1.0.weight', 'features.4.1.1.0.bias', 'features.5.0.0.weight', 'features.5.0.0.bias', 'features.5.1.0.0.weight', 'features.5.1.0.0.bias', 'features.5.1.1.0.weight', 'features.5.1.1.0.bias', 'features.7.0.0.weight', 'features.7.0.0.bias', 'features.7.1.0.0.weight', 'features.7.1.0.0.bias', 'features.7.1.1.0.weight', 'features.7.1.1.0.bias', 'features.8.0.0.weight', 'features.8.0.0.bias', 'features.8.1.0.0.weight', 'features.8.1.0.0.bias', 'features.8.1.1.0.weight', 'features.8.1.1.0.bias', 'features.9.0.0.weight', 'features.9.0.0.bias', 'features.9.1.0.0.weight', 'features.9.1.0.0.bias', 'features.9.1.1.0.weight', 'features.9.1.1.0.bias', 'features.10.0.0.weight', 'features.10.0.0.bias', 'features.10.1.0.0.weight', 'features.10.1.0.0.bias', 'features.10.1.1.0.weight', 'features.10.1.1.0.bias', 'features.12.0.0.weight', 'features.12.0.0.bias', 'features.12.1.0.0.weight', 'features.12.1.0.0.bias', 'features.12.1.1.0.weight', 'features.12.1.1.0.bias', 'output.0.weight', 'output.0.bias'])

Changes due to mxnet-master's different implementations from 1.7:

jinboci and others added 30 commits August 7, 2020 06:27
* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy
* bump up to 0.9 pre

* fix nightly build mxnet
This reverts commit d2daaa3.
Comment on lines 40 to 41
# ('264ba4970a0cc87a4f15c96e25246a1307caf523', 'squeezenet1.0'),
# ('33ba0f93753c83d86e1eb397f38a667eaf2e9376', 'squeezenet1.1'),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid loading pretrained models

@mli
Copy link
Member
mli commented Nov 17, 2020

Job PR-1521-2 is done.
Docs are uploaded to http://gluon-vision-staging.s3-website-us-west-2.amazonaws.com/PR-1521/2/index.html
Code coverage of this PR: pr.svg vs. Master: master.svg

@mli
Copy link
Member
mli commented Nov 17, 2020

Job PR-1521-4 is done.
Docs are uploaded to http://gluon-vision-staging.s3-website-us-west-2.amazonaws.com/PR-1521/4/index.html
Code coverage of this PR: pr.svg vs. Master: master.svg

@jinboci jinboci marked this pull request as ready for review December 3, 2020 05:36
@mli
Copy link
Member
mli commented Dec 3, 2020

Job PR-1521-5 is done.
Docs are uploaded to http://gluon-vision-staging.s3-website-us-west-2.amazonaws.com/PR-1521/5/index.html
Code coverage of this PR: pr.svg vs. Master: master.svg

@zhreshold zhreshold merged commit eb85893 into dmlc:numpy Dec 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0