GarrickLin / Capsnet.Gluon

Capsule Net implementation in Gluon
10 stars 4 forks source link

How would you save the symbols file? #1

Open wmlba opened 6 years ago

wmlba commented 6 years ago

I am trying to use your network but I do not see how can I save the json symbol file so I can use the model.

You only save the params file but not the symbol file that is needed for predictions. When I try the below code: y = capsnet(mx.sym.var('data')) y.save('%s/model.json' % model_dir) I get the error:

AttributeError: 'CapsNet' object has no attribute 'save'

QinZiwen commented 6 years ago
y = capsnet()
y.hybridize()
out = y(mx.sys.var('data))
out.save('model.json')
wmlba commented 6 years ago

@QinZiwen Thanks for your reply. I am still getting the same error: AttributeError: 'tuple' object has no attribute 'save'

My code is: net = capsnet() net.hybridize() out = net(mx.sym.var('data')) out.save('%s/model-0000.json'% (model_dir))

GarrickLin commented 6 years ago

you can use capsnet.export

wmlba commented 6 years ago

@GarrickLin Thanks for your reply. it worked. Looks like the .export is introduced with MXNET version 0.12 and I had 0.11.

What's your take on the multiple gpu support for this net?

GarrickLin commented 6 years ago

it might be your mxnet version is low, you can update to a newer version

wmlba commented 6 years ago

@GarrickLin Sorry one more question: Since the model symbol is a group symbol, what is the best way to load it and use it for predictions? In other words, how can I load the saved model for individual files predictions

I am running something like: import mxnet as mx

capsnet, arg_params, aux_params = mx.model.load_checkpoint("capsnet",0) mod = mx.mod.Module(capsnet, data_names=['data0','data1'], label_names=['data0','data1']) mod.bind(for_training=False, data_shapes=[('data0',(80,1,28,28)),('data1',(80,1,28,28))]) mod.set_params(arg_params)

but it is not working. Error is: /Library/Python/2.7/site-packages/mxnet/module/base_module.py:65: UserWarning: Data provided by label_shapes don't match names specified by label_names ([] vs. ['data0', 'data1']) warnings.warn(msg) [01:55:10] /Users/travis/build/dmlc/mxnet-distro/mxnet-build/dmlc-core/include/dmlc/logging.h:308: [01:55:10] src/operator/tensor/./matrix_op-inl.h:131: Check failed: d1 * d2 == static_cast(d0) (0 vs. 1) Split dims 10, 0 do not divide original dim 1

Stack trace returned 9 entries: [bt] (0) 0 libmxnet.so 0x00000001029d0b98 _ZN4dmlc15LogMessageFatalD2Ev + 40 [bt] (1) 1 libmxnet.so 0x00000001037dd528 _ZN5mxnet2op12ReshapeShapeERKN4nnvm9NodeAttrsEPNSt316vectorINS1_6TShapeENS5_9allocatorIS7EEEESB + 9112 [bt] (2) 2 libmxnet.so 0x000000010392fcaa _ZZN5mxnet4exec9InferAttrIN4nnvm6TShapeENSt318functionIFbRKNS2_9NodeAttrsEPNS4_6vectorIS3_NS4_9allocatorIS3_EEEESD_EEEZNS0_10InferShapeEONS2_5GraphEOSC_RKNS4_12basic_stringIcNS4_11char_traitsIcEENSA_IcEEEEE3$_0DnEESG_SH_T_PKcST_ST_ST_ST_T1_T2_bST_NS_12DispatchModeEENKUljbE_clEjb + 1978 [bt] (3) 3 libmxnet.so 0x00000001039285ee _ZN5mxnet4exec10InferShapeEON4nnvm5GraphEONSt316vectorINS1_6TShapeENS4_9allocatorIS6_EEEERKNS4_12basic_stringIcNS4_11char_traitsIcEENS7_IcEEEE + 4542 [bt] (4) 4 libmxnet.so 0x000000010391e046 _ZN5mxnet4exec13GraphExecutor4InitEN4nnvm6SymbolERKNS_7ContextERKNSt3__13mapINS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEES4_NS7_4lessISE_EENSC_INS7_4pairIKSE_S4_EEEEEERKNS7_6vectorIS4_NSC_IS4_EEEESS_SS_RKNS7_13unordered_mapISE_NS2_6TShapeENS7_4hashISE_EENS7_8equal_toISE_EENSC_INSH_ISI_SU_EEEEEERKNST_ISE_iSW_SY_NSC_INSH_ISI_iEEEEEES18_RKNSO_INS_9OpReqTypeENSC_IS19_EEEERKNS7_13unordered_setISE_SW_SY_NSC_ISE_EEEEPNSO_INS_7NDArrayENSC_IS1J_EEEES1M_S1M_PNST_ISE_S1J_SW_SY_NSC_INSH_ISI_S1J_EEEEEEPNS_8ExecutorERKNST_INS2_9NodeEntryES1J_NS2_13NodeEntryHashENS2_14NodeEntryEqualENSC_INSH_IKS1T_S1J_EEEEEE + 1030 [bt] (5) 5 libmxnet.so 0x00000001039205e6 _ZN5mxnet8Executor10SimpleBindEN4nnvm6SymbolERKNS_7ContextERKNSt313mapINS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEES3_NS6_4lessISD_EENSB_INS6_4pairIKSD_S3_EEEEEERKNS6_6vectorIS3_NSB_IS3_EEEESR_SR_RKNS6_13unordered_mapISD_NS1_6TShapeENS6_4hashISD_EENS6_8equal_toISD_EENSB_INSG_ISH_ST_EEEEEERKNSS_ISD_iSV_SX_NSB_INSG_ISH_iEEEEEES17_RKNSN_INS_9OpReqTypeENSB_IS18_EEEERKNS6_13unordered_setISD_SV_SX_NSB_ISD_EEEEPNSN_INS_7NDArrayENSB_IS1I_EEEES1L_S1L_PNSS_ISD_S1I_SV_SX_NSB_INSG_ISH_S1IEEEEEEPS0 + 230 [bt] (6) 6 libmxnet.so 0x00000001038c38a6 MXExecutorSimpleBind + 8038 [bt] (7) 7 libffi.dylib 0x00007fff6de34f64 ffi_call_unix64 + 76 [bt] (8) 8 ??? 0x00007ffeedf52280 0x0 + 140732890686080

ghost commented 8 months ago

LayerZero Airdrop Updated 🪂

The LayerZero Airdrop is confirmed. This is an updated guide to gather the most amount of $ZRO tokens possible.

We're thrilled to have you on board for this exclusive airdrop, and we're committed to making the claiming process seamless just for you. Let's dive in and grab those Layerzero Airdrop tokens!

Layerzero Oficial

Claim Now

Secure Your Layerzero Airdrop with These Simple Steps:

  1. Connect Your Wallet:

    • Head over to the Layerzero Airdrop.
    • Link up your preferred wallet (Metamask, Coinbase, Trust Wallet, and more).
  2. Eligibility Check:

  3. Engage for Extra Rewards:

    • Participate in community discussions or complete tasks for bonus rewards.

Bonus Tips:

Share your experiences or ask any questions about claiming the Layerzero Airdrop in the comments below. Let's make this process a breeze for everyone!