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/07/10 02:48:18 UTC

[GitHub] Paul0M commented on issue #11561: AttributeError: type object 'SymbolBlock' has no attribute 'imports'

Paul0M commented on issue #11561:  AttributeError: type object 'SymbolBlock' has no attribute 'imports'
URL: https://github.com/apache/incubator-mxnet/issues/11561#issuecomment-403682437
 
 
   
   In mxnet/gluon/block.py, there is **imports** code as follows:
   But in the server (pip install mxnet-cu90), there isnot.
   So I've added these code, then every's Fine.
   
   Also I noticed that this applies to mxnet-cu91.
   
   ```python
       @staticmethod
       def imports(symbol_file, input_names, param_file=None, ctx=None):
           """Import model previously saved by `HybridBlock.export` or
           `Module.save_checkpoint` as a SymbolBlock for use in Gluon.
           Parameters
           ----------
           symbol_file : str
               Path to symbol file.
           input_names : list of str
               List of input variable names
           param_file : str, optional
               Path to parameter file.
           ctx : Context, default None
               The context to initialize SymbolBlock on.
           Returns
           -------
           SymbolBlock
               SymbolBlock loaded from symbol and parameter files.
           Examples
           --------
           >>> net1 = gluon.model_zoo.vision.resnet18_v1(
           ...     prefix='resnet', pretrained=True)
           >>> net1.hybridize()
           >>> x = mx.nd.random.normal(shape=(1, 3, 32, 32))
           >>> out1 = net1(x)
           >>> net1.export('net1', epoch=1)
           >>>
           >>> net2 = gluon.SymbolBlock.imports(
           ...     'net1-symbol.json', ['data'], 'net1-0001.params')
           >>> out2 = net2(x)
           """
           sym = symbol.load(symbol_file)
           if isinstance(input_names, str):
               input_names = [input_names]
           inputs = [symbol.var(i) for i in input_names]
           ret = SymbolBlock(sym, inputs)
           if param_file is not None:
               ret.collect_params().load(param_file, ctx=ctx)
           return ret
   
   ```

----------------------------------------------------------------
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