You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@mxnet.apache.org by jnnk via MXNet Forum <mx...@discoursemail.com.INVALID> on 2021/04/30 14:15:23 UTC

[MXNet Forum] [Gluon] Split pre-trained network in two parts


Hi all,
I have a .json and a .params file of a pre-trained model which I want to use.
For demonstration let's assume the network consists of named-layers and looks like this:
    **A -> B -> C -> D -> E**

My goal is to split the network in two parts.
The first part should be **A -> B -> C** and the second part should be **C -> D -> E**.
This means, that the output of the first part is C after activation functions of B -> C are applied.
The input for the second part is the direct output of layer C but before weights of C -> D and activation functions are applied.

It works to get the first part, as I can specify C as the ouput layer of the network.
But I can not achieve to create the second part of the network, as creating the symbol
> E  = sym.get_internals()['E']
> second_network = mx.gluon.nn.SymbolBlock(outputs=E, inputs=[mx.sym.var('C')])
> second_network.collect_params().load(params_file, ignore_extra=True)

does not work. It throws an error that the input needs to be bound to data, I can not set C to the input.
Any help getting this to work is appreciated.

Please note, that simply setting the output of the network to **[C, E]** is not sufficient. I need to get C first and then put it into the second network.

Thank you very much.

Best,
Jan





---
[Visit Topic](https://discuss.mxnet.apache.org/t/split-pre-trained-network-in-two-parts/6944/1) or reply to this email to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.mxnet.apache.org/email/unsubscribe/4b3b586d30c4b4f25113d492de1e913a856ec3b2e864a13bfa99edeef1b680b8).