Deserialize to HybridBlock, or convert SymbolBlock to HybridBlock

If I have a network described in an object of type HybridBlock or something inheriting from HybridBlock, I can call net.export and then SymbolBlock.imports to serialize and deserialize the network (in mxnet 1.2.1). But the object I get back is of type SymbolBlock. Is there any way to start with a HybridBlock or HybridSequential object, which may be a container for other blocks, and after serializing and deserializing still have an object of the same type?

Alternatively, is there a way to convert a SymbolBlock to a HybridBlock? I want to be able to call net._children and get access to the components of the network as gluon objects.

In short, what you want is not possible. The reason for this limitation is that the serialization is for computational graph of the network, not the python code that generates the computational graph. To achieve what you want, you can simply create your network in python and use net.save_parameters() or net.load_parameters() to save and load only the parameters of the network.

Just to be completely clear, the concept of a Block is a python-only concept and if you’re interested in serializing the python code that generates the computational graph, you might as well save the actual python file :slight_smile: