Skip to content

Use an already trained network multiple times inside a larger network

Allison Brucker (Resources Online) edited this page May 30, 2017 · 3 revisions

This page has migrated to our new site. Please update any bookmarks.

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