Revision 7e54db0d330c73fb27f7c1845303898385ade190 authored by Project Philly on 17 October 2016, 11:13:52 UTC, committed by Project Philly on 17 October 2016, 11:13:52 UTC
2 parent s d3c1815 + 861f07a
Raw File
lr_bs_broken.cntk.txt
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.

# logistic regression cntk script -- using BrainScript network description language

featureDim = 2                   # input features data dimensions
labelDim = 1                     # label data dimensions

command=TrainLRModel:TestModel   # which commands to run

modelPath = "Models/LR_reg.dnn"  # where to write the model to
deviceId = "auto"                # -1 means CPU; use 0 for first GPU, 1 for second etc.
makeMode = false                 # start from scratch; do not resume from earlier runs
parallelTrain = false            # Enable parallel training

# training config
TrainLRModel = {                 # command=TrainLRModel --> CNTK looks for a section named TrainLRModel
    action = "train"             # execute CNTK's 'train' routine
    
    # network description
    BrainScriptNetworkBuilder = [

        # Logistic regression model definition
        model(features) = 
        {
            # parameters to learn
            b = ParameterTensor{$labelDim$}                   # bias
            w = ParameterTensor{($featureDim$ : $labelDim$)}  # projection

            # operations
            z = Sigmoid(w * features + b)
        }.z
    
        # inputs
        features = Input($featureDim$)
        labels   = Input($labelDim$)

        # apply model to features
        z = model(features)

        # connect to model training system
        lr   = Logistic(labels, z)                           # optimization criterion
        err  = SquareError (labels, z)                       # model evaluation

        featureNodes    = (features)
        labelNodes      = (labels)
        criterionNodes  = (lr)
        evaluationNodes = (err)
        outputNodes     = (z)
    ]   

    # configuration parameters of the SGD training procedure
    SGD = {
        epochSize = 0                  # 0 means size of the training set
        minibatchSize = 25
        learningRatesPerSample = 0.04  # gradient contribution from each sample
        maxEpochs = 10

        # Parallel training specific options; only applicable when 'parallelTrain=true' at top level
        parallelTrain = {
            parallelizationMethod = "DataParallelSGD"
            dataParallelSGD = { gradientBits = 1 }
        }
    }

    # configuration of data reading
    reader = {
        randomize = true
        deserializers = ({
            type = "CNTKTextFormatDeserializer" ; module = "CNTKTextFormatReader"
            file = "Train_cntk_text.txt"
            input = {
                features = { dim = $featureDim$ ; format = "dense" }
                labels =   { dim = $labelDim$   ; format = "dense" }
            }
        })
    }
}

# test config
TestModel = {
    action = "eval"
    reader = {
        randomize = true
        deserializers = ({
            type = "CNTKTextFormatDeserializer" ; module = "CNTKTextFormatReader"
            file = "Test_cntk_text.txt"
            input = {
                features = { dim = $featureDim$ ; format = "dense" }
                labels =   { dim = $labelDim$   ; format = "dense" }
            }
        })
    }
}
back to top