Skip to content

Use an already trained network multiple times inside a larger network

Vadim Mazalov edited this page Sep 30, 2016 · 1 revision

Use the CloneFunction() operation. E.g.:

BrainScriptNetworkBuilder = {
    smallnet = BS.Network.Load ("pathToYourModel")
    subnet1 = CloneFunction (smallnet.input, smallnet.output, parameters="learnable" )
    subnet2 = CloneFunction (smallnet.input, smallnet.output, parameters="constant" )
    subnet3 = CloneFunction (smallnet.input, smallnet.output, parameters="shared" )
    subnet4 = CloneFunction (smallnet.input, smallnet.output, parameters="shared" )
    # now use subnet1, subnet2, subnet3, and subnet4 as regular Brainscript functions
}

subnet1() will get a copy of its learnable parameters, which will continue to be updated in training. subnet2() will get a read-only copy of learnable parameters. subnet3() and subnet4() will share the same set of learnable parameters, which will get updated jointly during training.

Clone this wiki locally