CNTK icon indicating copy to clipboard operation
CNTK copied to clipboard

Simple Regression NotifyFunctionValuesMBSizeModified Exception

Open whitmark opened this issue 10 years ago • 5 comments

I am attempting to run a simple regression using the UCIFastReader and SimpleNetworkBuilder (before attempting the same with NDL). The label value in the first position followed by 24 feature values:

L F1 F2 F3 F4 F5 . . .F24 (not in dataset)
7.8 1 0.1632 0.9583 0.9583 1.0000 . . .
4.3 -1 0.2123 0.4792 1.0000 2.0435 . . .
11.3 1 0.2584 0.7273 1.0435 0.3913 . . .
1.0 -1 0.3615 0.7742 2.0000 3.2083 . . .

There are 4000 training records and 350 test records. The "train" action seemingly works okay, but then in the "test" action I get the exception:

RandomOrdering: 58 retries for 350 elements (16.6%) to ensure window condition RandomOrdering: recached sequence for seed 0: 40, 28, ... EXCEPTION occurred: NotifyFunctionValuesMBSizeModified: labels InputValue operation had its col dimension 350 changed by the reader to 1, but different from MBLayout.

I have a couple of questions:

  1. I could only get the "train" action to run if I put minibatchSize=1 in the SGD. Not sure I understand why that is necessary.
  2. Unclear what is causing the "test" action to exception.

Using the following attached components and config file below:

DLT_DNN02.zip

dtl_dnn02_out_Train_Test_Output_dumpNodeInfo.zip

Would appreciate any suggestions.

# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.

# currentDirectory=$(SolutionDir)/<path to corresponding data folder> 
RootDir = ".."

ConfigDir = "$RootDir$/Config"
DataDir   = "$RootDir$/Data"
OutputDir = "$RootDir$/Output"
ModelDir  = "$OutputDir$/Models"

# which commands to run
command=Train:Test:Output:dumpNodeInfo

#required...
precision = "float"
modelPath="$OutputDir$/Models/dlt_dnn02.dnn"    # where to write the model to
ndlMacros="$ConfigDir$/Macros.ndl"

# uncomment the following line to write logs to a file 
stderr = "$OutputDir$/dtl_dnn02_out"
traceLevel=1
numMBsToShowResult=500

deviceId=-1                 # CPU < 0
inputDimension=24   # input data dimensions
labelDimension=1        # label dimensions

#######################################
#  TRAINING CONFIG                    #
#######################################
Train=[
    action="train"

SimpleNetworkBuilder = [
    #24 inputs, 2 hidden layers with 48 element nodes each, 1 output node
    layerSizes = 24:48*1:1
    trainingCriterion = "CrossEntropyWithSoftmax"
    evalCriterion = "ErrorPrediction"
    layerTypes = "Sigmoid"
#    applyMeanVarNorm = true
]   

#   NDLNetworkBuilder=[
#        networkDescription = "$ConfigDir$/dlt_dnn02.ndl"
#  ]

    SGD = [ 
        epochSize=0                         # =0 means size of the training set
        minibatchSize=1
        learningRatesPerMB=0.1            # learning rates per MB
        momentumPerMB = 0           
        maxEpochs=10
    ]

    # parameter values for the reader
    reader = [
        readerType = "UCIFastReader"
        file = "Train-DLT-dnn02.txt"
        verbosity = 2
        miniBatchMode = "partial"       
        labelType="Regression"                      
        #randomize = "auto"     

        labels=[
            start = 0 
            dim = 1
        ]

        features=[          
            start = 1
            dim = 24
        ]
    ]
]

#######################################
#  TEST CONFIG                        #
#######################################
Test=[

    action="test"

    reader=[
        readerType="UCIFastReader"
        file="Test-DLT-dnn02.txt"
        verbosity = 2       
        miniBatchMode = "partial"   
        labelType="Regression"                          
        #randomize = "auto" 

        labels=[
            start = 0
            dim = 1     
        ]

        features=[          
            start = 1
            dim = 24
        ]
    ]
]

whitmark avatar Apr 14 '16 16:04 whitmark

The UCIFastReader’s randomization code has many limitations I think. You might want to randomly order your training samples offline and then turn randomization off in your readers by specifying

randomize = "none"

dongyu888 avatar Apr 14 '16 16:04 dongyu888

Thanks for the quick response, unfortunately, setting randomize = "none" didn't solve it and I previously had randomize = "auto" commented out.

I would consider the CNTKTextFormat Reader, but it doesn't look like there is an option to read the regression values as labels.

whitmark avatar Apr 14 '16 17:04 whitmark

CNTKText is agnostic of the input type (regression/category/label/feature/etc) and will work just fine with this data/config.

raaaar avatar Apr 15 '16 14:04 raaaar

Thanks raaaar, I was able to get the following to work:

|L 7.8 |F 1 0.8836 0.6400 0.5161 0.6129 . . .
|L 1.5 |F -1 0.8991 0.4583 1.3750 2.8125 . . .
|L 0.5 |F 1 0.9216 1.1364 1.1364 0.0455 . . .
|L 1.8 |F -1 0.9455 2.5263 1.9200 1.8000 . . .
    reader = [
        readerType = "CNTKTextFormatReader"
        file = "Train-DLT-dnn02.txt"
        randomize = "none"
        maxErrors = 100
        traceLevel = 2

        input = [
            labels = [
                alias = "L"
                dim = 1
                format = "dense"
            ]
            features = [
                alias = "F"
                dim = 24
                format = "dense"
            ]
        ]   
    ]

whitmark avatar Apr 15 '16 19:04 whitmark

I am new to CNTK and want to get up to speed quickly. I managed to solve classification problems, but still cannot figure out how to generate predictions at the right scale for simple regression problems (NOT logistic regression). The examples here simply write out the OBSERVED features, not the predicted features (I applied a trained model to random numbers which should give me large errors instead of exact matches for predicted values).

So how can I specify the regression output (one or more outputs) at the original scale in a simple regression problem? Is there an example ANYWHERE? (Even with simple random numbers, or for simple linear regression).

Secondly, where can i find comprehensive documentation for the CNTK library interfaces (for the binary)?

Thank you for pointing me in the right direction.

DrTomHill avatar May 09 '16 15:05 DrTomHill