Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[Feature Request] save symbol as well in gluon #7501

Closed
ShownX opened this issue Aug 16, 2017 · 8 comments
Closed

[Feature Request] save symbol as well in gluon #7501

ShownX opened this issue Aug 16, 2017 · 8 comments

Comments

@ShownX
Copy link

ShownX commented Aug 16, 2017

I start to use gluon but I found it cannot save the model into the symbol file. Is it possible to implement this function?

@piiswrong
Copy link
Contributor

Only hybridblock can be serialized to symbol. Normal blocks can only be pickled

@ShownX
Copy link
Author

ShownX commented Aug 17, 2017

how to serialize hybridblock?

@szha
Copy link
Member

szha commented Aug 17, 2017

you can call the .save_params() function on it.

@ShownX
Copy link
Author

ShownX commented Aug 17, 2017

Yes. I tried .save_params() function, it only saves the params. I cannot find the symbol file :(.
I checked all layers. All of them are inherited from hybridblock.

@szha
Copy link
Member

szha commented Aug 17, 2017

@ShownX ah sorry for missing that. To get the symbol out of a block, just feed the block with a symbol of the intended put variable. Something like block(sym.Variable('data')) and then you can use symbol.save.

@ShownX
Copy link
Author

ShownX commented Aug 18, 2017

Suppose I wrote the following code:

net = gluon.nn.HybridSwquential()
net.add(gluon.nn.Dense(512))

Is it possible to save net definition to a symbol file? I cannot find the API like you said above. What I only find is net.save_params() to save weights.

@szha
Copy link
Member

szha commented Aug 18, 2017

You can call net(mx.sym.Variable('data')) and the returned value is a symbol, with which you can save with the symbol API.

@ShownX
Copy link
Author

ShownX commented Aug 18, 2017

I see. Thanks.

@ShownX ShownX closed this as completed Aug 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants