You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/10/10 18:31:16 UTC

[GitHub] indhub closed pull request #12719: fix cnn visualization tutorial

indhub closed pull request #12719: fix cnn visualization tutorial
URL: https://github.com/apache/incubator-mxnet/pull/12719
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/docs/tutorials/vision/cnn_visualization.md b/docs/tutorials/vision/cnn_visualization.md
index ea027dff09a..940c261efc8 100644
--- a/docs/tutorials/vision/cnn_visualization.md
+++ b/docs/tutorials/vision/cnn_visualization.md
@@ -99,12 +99,18 @@ def get_vgg(num_layers, ctx=mx.cpu(), root=os.path.join('~', '.mxnet', 'models')
     # Get the number of convolution layers and filters
     layers, filters = vgg_spec[num_layers]
 
-    # Build the VGG network
+    # Build the modified VGG network
     net = VGG(layers, filters, **kwargs)
-
-    # Load pretrained weights from model zoo
-    from mxnet.gluon.model_zoo.model_store import get_model_file
-    net.load_params(get_model_file('vgg%d' % num_layers, root=root), ctx=ctx)
+    net.initialize(ctx=ctx)
+    
+    # Get the pretrained model
+    vgg = mx.gluon.model_zoo.vision.get_vgg(num_layers, pretrained=True, ctx=ctx)
+    
+    # Set the parameters in the new network
+    params = vgg.collect_params()
+    for key in params:
+        param = params[key]
+        net.collect_params()[net.prefix+key.replace(vgg.prefix, '')].set_data(param.data())
 
     return net
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services