CNTK icon indicating copy to clipboard operation
CNTK copied to clipboard

Additional error posterior to the fix of Issue #181 using mean node on Examples/Image/MNIST/02_Convolution

Open tz579 opened this issue 10 years ago • 14 comments

Steps to reproduce the error for Examples/Image/MNIST/02_Convolution:

1. For 02_Convolution.cntk, change imageLayout to "legacy"

2. For 02_Convolution.cntk, add AutoAdjust inside SGD as below:

    AutoAdjust = [
        reduceLearnRateIfImproveLessThan = 0
        loadBestModel = true
        learnRateDecreaseFactor = 0.5
        autoAdjustLR = "adjustAfterEpoch"
    ]

3. For 02_Convolution.cntk, duplicate reader to form a fake cvreader as below:

cvreader = [
    readerType = "UCIFastReader"
    # To get the data (Train-28x28.txt) please run `python mnist_convert.py` 
    # from the 'AdditionalFiles' folder. See REAMDE.md for details.
    file = "$DataDir$/Train-28x28.txt"

    features = [
        dim = 784
        start = 1
    ]

    labels = [
        dim = 1
        start = 0
        labelDim = 10
        labelMappingFile = "$DataDir$/labelsmap.txt"
    ]
]    

4. For 02_Convolution.ndl, adding PerDimMeanVarNormalization by changing the following 2 lines:

    featScale = Constant(0.00390625)
    featScaled = Scale(featScale, features)

into:

    featMean = Mean(features)
    featStdDev = InvStdDev(features)
    featNorm = PerDimMeanVarNormalization(features, featMean, featStdDev)
    featScale = Constant(1) # does not need to divide 256 anymore when MVN presents
    featScaled = Scale(featScale, featNorm)

5. Run this example task 02_Convolution, the error will occur as below:

    Final Results: Minibatch[1-1875]: SamplesSeen = 60000    ce: CrossEntropyWithSoftmax/Sample = 0.17121576    Perplexity = 1.1867468    err: ErrorPrediction/Sample = 0.053383333    
    Finished Epoch[ 2 of 15]: [Validation Set] TrainLossPerSample = 0.17121576; EvalErrPerSample = 0.053383333
    Loading previous model with best training-criterion value: ../Output/Models/02_Convolution.1.

    EXCEPTION occurred: featMean Mean operation: Precomputed parameter does not match input dimensions.

Which is after the fake cross-validation stage for Epoch 2, right before the SGD learner prepares to shrink the learningRate by 0.5.

To sum up, this error occurs by applying MeanVarNormalization on legacy layout of image feature, during the Newbob-style training process using autoAdjust in AdjustAfterEpoch mode.

tz579 avatar Mar 06 '16 04:03 tz579

Yikes. I see what happens. Thanks for reporting this.

As a temporary fix, I think you can just change PrecomputeNodeBase::Validate() (in PreComputeNodes.h) by replacing this code:

    if (!m_hasComputed) // this node retains state, and state gets destroyed by Resize(), so we must be careful
        SetDims(Input(0)->GetSampleLayout(), false);
    else if (!GetSampleLayout().IsElementwiseCompatibleWith(Input(0)->GetSampleLayout()))
        InvalidArgument("%ls %ls operation: Precomputed parameter does not match input dimensions.", NodeName().c_str(), OperationName().c_str());

by this:

    SetDims(Input(0)->GetSampleLayout(), false);

Could you let me know whether that works?

frankseide avatar Mar 06 '16 04:03 frankseide

@frankseide Thanks a lot! I confirmed that applying the temporary fix on PreComputeNodes.h works on the example mentioned in the 1st post.

tz579 avatar Mar 06 '16 05:03 tz579

Thanks! The fix will land after code review in the next commit to master, probably Monday. Closing.

frankseide avatar Mar 06 '16 05:03 frankseide

@frankseide Thanks a lot and the latest version inside fseide/pack has also been checked by me to have fixed this issue.

A new problem is discovered for multi-task training that shows up since the commit f786583 which is the merge of fseide/s2s into master. A new issue #219 has been opened to help duplicate this error.

tz579 avatar Mar 09 '16 18:03 tz579

@frankseide Hi! As mentioned in the last post, a new issue #219 has been opened to deal with an error that shows up since the merge of fseide/s2s into master (commit f786583). Does this potential conflict between fseide/s2s and the master a known issue?

tz579 avatar Mar 11 '16 02:03 tz579

@frankseide Thanks and sorry for bothering you again! This is just a cue that 2 new posts have been made on the main thread of issue #219, on Thursday and Saturday respectively, in case you have problems receiving notifications on that thread. Those are the validation outputs from one of the recent master branch build (on Mar. 08) and the very last "good" build (on Mar. 01). Detailed explanations are within those posts.

tz579 avatar Mar 13 '16 21:03 tz579

@frankseide You can ignore the last post here if you have no problem receiving updates on the main thread of issue #219. Thx!

tz579 avatar Mar 13 '16 21:03 tz579

@frankseide Thanks for your quick response on the main thread of issue #219 . So far I have 2 quick questions:

  1. To prevent from running the more complicated NVidia Nsight version of Eclipse to debug the GPU version, I am trying to debug the CPU version instead, using standard version of Eclipse (with CDT plugin for working with C/C++ projects). The CPU version of CNTK will crash as always, either running stand-alone or inside Eclipse. Is this a know bug, or do I need to pass some variables into the configuration to limit the # of threads used? Also, do I need to set "ParallelTrain" into "false" for the test case to debug with GDB?
  2. For the 6 variable mentioned in your last post, did you mean shapeA, shapeB, shapeC, a.m_shape, b.m_shape, and m_shape, which are listed in TensorView.cpp?

Thanks!

tz579 avatar Mar 14 '16 05:03 tz579

@frankseide Note that a same question in the last post has been posted onto the main thread of issue #219. Do you have any problems receiving updates/notification on that thread? If not, I will stop posting here and will post further communications only on thread #219.

tz579 avatar Mar 14 '16 15:03 tz579

I am receiving this. Sorry for not being able to respond immediately.

From: tz579 [mailto:[email protected]] Sent: Monday, March 14, 2016 8:41 To: Microsoft/CNTK [email protected] Cc: Frank Seide [email protected] Subject: Re: [CNTK] Additional error posterior to the fix of Issue #181 using mean node on Examples/Image/MNIST/02_Convolution (#210)

@frankseidehttps://github.com/frankseide Note that a same question in the last post has been posted onto the main thread of issue #219https://github.com/Microsoft/CNTK/issues/219. Do you have any problems receiving updates/notification on that thread? If not, I will stop posting here and will post further communications only on thread #219https://github.com/Microsoft/CNTK/issues/219.

— Reply to this email directly or view it on GitHubhttps://github.com/Microsoft/CNTK/issues/210#issuecomment-196372595.

frankseide avatar Mar 14 '16 15:03 frankseide

@frankseide So the question remains: Do you have any problems receiving update/notifications on the main thread of #219 instead of here? Because every time I posted there, no response will be received until I make a double post here. It is not a good way to keep on posting here (thread of issue #210) for an unrelated bug (issue #219).

Also, what do you think about my 2 questions posted both here and on the main thread #219?

tz579 avatar Mar 14 '16 15:03 tz579

@frankseide Reply for the main thread #219:

The CPU version will crash without error messages. It seems that it swallowed most of the CPU or memory resources after dealing with a few minibatches and the OS will stop responding until I kill the cntk manually. I will try to set "ParallelTrain" into "false" in the config to see what happens.

Also, do I need to set "ParallelTrain" into "false" in the config to debug with GDB?

Thanks!

tz579 avatar Mar 14 '16 16:03 tz579

Yes, for debugging I would disable parallel train so that you can run it without MPI.

From: tz579 [mailto:[email protected]] Sent: Monday, March 14, 2016 9:22 To: Microsoft/CNTK [email protected] Cc: Frank Seide [email protected] Subject: Re: [CNTK] Additional error posterior to the fix of Issue #181 using mean node on Examples/Image/MNIST/02_Convolution (#210)

@frankseidehttps://github.com/frankseide Reply for the main thread #219https://github.com/Microsoft/CNTK/issues/219:

The CPU version will crash without error messages. It seems that it swallowed most of the CPU or memory resources after dealing with a few minibatches and the OS will stop responding until I kill the cntk manually. I will try to set "ParallelTrain" into "false" in the config to see what happens.

Also, do I need to set "ParallelTrain" into "false" in the config to debug with GDB?

Thanks!

— Reply to this email directly or view it on GitHubhttps://github.com/Microsoft/CNTK/issues/210#issuecomment-196394106.

frankseide avatar Mar 14 '16 16:03 frankseide

@frankseide Thanks and I will try to run without parallel train.

It's totally fine for me about your speed of response. The last 2 questions about the update/notifications, as you see, are only to check if and why you may not receiving notifications on the main thread #219 but only on the unrelated thread #210 (here), so that I have to make comments on #210 and wait to see your response on #219, which is weird for us and also for anyone browsing those threads.

tz579 avatar Mar 14 '16 16:03 tz579