samskalicky commented on issue #14728: [MXNET-1386] fix for shape mismatch
URL: https://github.com/apache/incubator-mxnet/pull/14728#issuecomment-485939545
 
 
   @reminisce heres what i tried, to reproduce the example graph from the 
issue, but it does not fail:
   
   ```
   import os
   import mxnet as mx
   from collections import namedtuple
   from mxnet.base import _LIB, check_call, c_str, mx_uint, c_str_array
   Batch = namedtuple('Batch', ['data'])
   
   #setup whitelist
   op_names = ['elemwise_mul']
   check_call(_LIB.MXSetSubgraphPropertyOpNames(c_str("default"),
                                                mx_uint(len(op_names)),
                                                c_str_array(op_names)))
   os.environ['MXNET_SUBGRAPH_BACKEND'] = 'default'
   
   #setup graph
   e = mx.sym.var('e')
   f = mx.sym.var('f')
   c = mx.sym.var('c')
   h = mx.sym.var('h')
   k = mx.sym.var('k')
   
   d = e * f
   b = c * d
   g = h * d
   j = k + g
   a = b + j
   
   #bind data
   ctx = mx.cpu()
   c_data = mx.nd.ones((1),ctx=ctx)
   e_data = mx.nd.ones((1),ctx=ctx)
   f_data = mx.nd.ones((1),ctx=ctx)
   h_data = mx.nd.ones((1),ctx=ctx)
   k_data = mx.nd.ones((1),ctx=ctx)
   
   args = {'c': c_data, 'e': e_data, 'h': h_data, 'k': k_data}
   aux = {}
   
   mod = 
mx.mod.Module(symbol=a,data_names=['f'],label_names=None,context=mx.cpu())
   mod.bind(for_training=False, data_shapes=[('f',(1,))], 
label_shapes=mod._label_shapes)
   mod.set_params(args,aux)
   
   #export to symbol/params files
   mod.save_checkpoint('test',0)
   
   #reload from files
   sym, arg_params, aux_params = mx.model.load_checkpoint('test', 0)
   mod = mx.mod.Module(symbol=sym, context=ctx, label_names=None, 
data_names=['f'])
   mod.bind(for_training=False, data_shapes=[('f', (1,))],
        label_shapes=mod._label_shapes)
   mod.set_params(arg_params, aux_params, allow_missing=True)
   
   #infer
   mod.forward(Batch([mx.nd.ones((1))]))
   print(mod.get_outputs())
   ```
   
   

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


With regards,
Apache Git Services

Reply via email to