Defining a seed value in Branscripts for CNTK sequ

2019-07-26 06:11发布

问题:

This is respect to CNTK brain scripts. I went through [1] to figure out whether there is an option to specify the random seed value, although I couldn't find any (Yes there is an option to set the 'random seed' parameter through the ParameterTensor() function, but if I followed that approach, I might have to explicitly initialize all the LSTM weights separately(defining separate weights for input layer gate, forget layer gate etc. ), instead of using the model sequence as below). Is there any other option available to set the random seed value, preserving the following RNN layered sequence.

nn_Train = {
  action = train
  BrainScriptNetworkBuilder = {
    model = Sequential (
      RecurrentLSTMLayer {$stateDim$, usePeepholes = true}:
      DenseLayer {$labelDim$, bias=false}                  
    )


    z = model (inputs)
    inputs=Input($inputDim$)  # features
    labels=Input($labelDim$)

    # loss and metric
    ce = SquareError(labels, z)

    # node assignment
    featureNodes    = (inputs)
    labelNodes      = (labels)
    criterionNodes  = (ce)
    evaluationNodes = (ce)
    outputNodes     = (z)
  }

[1] https://github.com/microsoft/cntk/wiki/Parameters-And-Constants#random-initialization

回答1:

There isn't a global random seed option for parameters unfortunately. However, you can modify the cntk.core.bs file next to cntk.exe where all the layers are defined to support random seed for the layers you want.