0

我正在对 CNTK 进行一个相当简单的测试,但没有得到有意义的结果。我的训练/测试数据由一个特征和一个标签组成。特征是小数,标签是 0-5 之间的整数。在大多数情况下,标签的值将是 0 或 1,并且随着值的升高而变得越来越少。5 出现在大约 16/30,000 例中。

奇怪的是,当我输出结果时,它们表明每个可能的标签出现的机会大致相同。我预计 0 或 1 是最有可能的,而 5 是极不可能的。我希望 SO 可以阐明我在这里可能做错了什么。我在下面包含了一些示例数据、示例输出和配置文件。

配置:

# Parameters can be overwritten on the command line
# for example: cntk configFile=myConfigFile RootDir=../..
# For running from Visual Studio add
# currentDirectory=$(SolutionDir)/<path to corresponding data folder>
RootDir = ".."

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

# deviceId=-1 for CPU, >=0 for GPU devices, "auto" chooses the best GPU, or CPU if no usable GPU is available
deviceId = 0

command = Simple_Demo_Train:Simple_Demo_Train

precision = "float"
traceLevel = 1
modelPath = "$ModelDir$/simple.dnn"
outputNodeNames = ScaledLogLikelihood

#######################################
#  TRAINING CONFIG                    #
#######################################

Simple_Demo_Train = [
    action = "train"

    # Notation xxx:yyy*n:zzz is equivalent to xxx, then yyy repeated n times, then zzz
    # Example: 10:20*3:5 is equivalent to 10:20:20:20:5
    SimpleNetworkBuilder = [
        # 2 input, 2 50-element hidden, 2 output
        layerSizes = 1:50*3:6
        trainingCriterion = "CrossEntropyWithSoftmax"
        evalCriterion = "ErrorPrediction"
        layerTypes = "Sigmoid"
        initValueScale = 1.0
        applyMeanVarNorm = true
        uniformInit = true
        needPrior = true
    ]

    SGD = [
        # epochSize = 0 means epochSize is the size of the training set
        epochSize = 0
        minibatchSize = 25
        learningRatesPerMB = 0.5:0.2*20:0.1
        momentumPerMB = 0.9
        dropoutRate = 0.0
        maxEpochs = 10000
    ]

    # Parameter values for the reader
    reader = [
        readerType = "UCIFastReader"
        file = "$DataDir$/train.txt"
        miniBatchMode = "partial"
        randomize = "none"
        verbosity = 1

        features = [
            dim = 1        # two-dimensional input data
            start = 0      # Start with first element on line
        ]

        labels = [
            start = 1      # Skip two elements
            dim = 1        # One label dimension
            labelDim = 5   # Two labels possible
            labelMappingFile = "$DataDir$/mapping.txt"
        ]
    ]
]

########################################
#  TEST RESULTS                        #
#  (computes prediction error and      #
#   perplexity on a test set and       #
#   writes the output to the console.) #
########################################

Simple_Demo_Test = [
    action = "test"

    # Parameter values for the reader
    reader = [
        readerType = "UCIFastReader"
        file = "$DataDir$/test.txt"
        miniBatchMode = "partial"
        randomize = "none"
        verbosity = 1

        features = [
            dim = 1        # two-dimensional input data
            start = 0      # Start with first element on line
        ]

        labels = [
            start = 1      # Skip two elements
            dim = 1        # One label dimension
            labelDim = 5   # Two labels possible
            labelMappingFile = "$DataDir$/mapping.txt"
        ]
    ]
]

########################################
#  OUTPUT RESULTS                      #
#  (Computes the labels for a test set #
#   and writes the results to a file.) #
########################################

Simple_Demo_Output=[
    action = "write"

    # Parameter values for the reader
    reader = [
        readerType = "UCIFastReader"
        file = "$DataDir$/test.txt"
        miniBatchMode = "partial"
        randomize = "none"
        verbosity = 1

        features = [
            dim = 1        # two-dimensional input data
            start = 0      # Start with first element on line
        ]

        labels = [
            start = 1      # Skip two elements
            dim = 1        # One label dimension
            labelDim = 5   # Two labels possible
            labelMappingFile = "$DataDir$/mapping.txt"
        ]
    ]

    outputPath = "$OutputDir$/SimpleOutput"    # Dump output as text
]

样本训练数据:

0.86 2
0.84 0
6.818182 0
1.34 1
1 1
0.92 0
0.7692308 0
0.755102 1
0.86 2
5.466667 0
0.96 0
0.9459459 1
1 4
1 0
0.8421053 2
5.5 0
0.84 2
1.2 2
1.32 1
0.98 0
1 1
1.2 2
5.4 1
1.06 2
0.98 1
1.041667 3
0.82 2
7.333333 0

样本输出:

3.18673 3.18266 3.19894 3.18264 3.2388 3.235 
3.18683 3.18272 3.19895 3.18264 3.23872 3.23491 
3.18668 3.18263 3.19894 3.18263 3.23884 3.23505 
3.18653 3.18255 3.19893 3.18263 3.23895 3.23518 
6.53459 4.97457 3.46288 3.3192 0.668835 0.204602 
3.18667 3.18263 3.19894 3.18263 3.23884 3.23505 
3.18657 3.18258 3.19893 3.18263 3.23892 3.23515 
3.18655 3.18257 3.19893 3.18263 3.23894 3.23516 
3.18665 3.18262 3.19894 3.18263 3.23886 3.23507 
3.18656 3.18257 3.19893 3.18263 3.23893 3.23515 
3.18654 3.18256 3.19893 3.18263 3.23895 3.23517 
3.18688 3.18274 3.19895 3.18264 3.23869 3.23487 
3.18675 3.18267 3.19894 3.18264 3.23879 3.23498 
3.18679 3.18269 3.19895 3.18264 3.23875 3.23494 
3.1866 3.18259 3.19893 3.18263 3.2389 3.23512 
3.18655 3.18256 3.19893 3.18263 3.23894 3.23517 
3.18652 3.18255 3.19893 3.18263 3.23896 3.23519 
3.18656 3.18257 3.19893 3.18263 3.23893 3.23515 
3.18656 3.18257 3.19893 3.18263 3.23894 3.23516 
3.18688 3.18274 3.19895 3.18264 3.23869 3.23487 
3.18698 3.1828 3.19896 3.18265 3.23861 3.23477 

映射文件:

0
1
2
3
4
5
4

1 回答 1

0

根据所提供的信息,很难对您的问题给出明确的答案。最有可能发生的情况:您的网络还没有学到很多东西,并且仍处于相当“模糊”的状态,其中权重尚未与其初始值有太大的偏差。这很可能是因为与您正在学习的权重数量相比,您只使用了很少的训练(请注意,您在 1D 输入上使用 3 层 50 个神经元!)。当被要求对您的测试数据进行预测时,大多数测试数据与任何训练数据都不相似,您的网络将预测其“最佳猜测”,即所有类别的可能性均等。

要检查一些学习是否真的在进行,例如尝试将您的问题减少到二类设置,0 与其他设置,并降低网络复杂性。

于 2016-04-12T16:19:11.647 回答