私は CNTK を調べていて、基本を理解していることを確認するために xor 関数のモデルを作成することにしました。以下のファイルを作成しましたが、モデルの動作が非常に悪いため、根本的な何かが欠けていると思います。
command = Train:Output:DumpNodeInfo
modelPath = "Models\xor.dnn"
deviceId = -1
makeMode = false
featureDimension = 2
labelDimension = 1
Train = [
action = "train"
BrainScriptNetworkBuilder = {
FDim = $featureDimension$
LDim = $labelDimension$
features = Input {FDim}
labels = Input {LDim}
W0 = ParameterTensor {(FDim:FDim)} ; b0 = ParameterTensor {FDim}
W1 = ParameterTensor {(LDim:FDim)} ; b1 = ParameterTensor {LDim}
o1 = W0*features + b0
z = Sigmoid (W1*o1 + b1)
ce = SquareError (labels, z)
errs = ClassificationError (labels, z)
# root nodes
featureNodes = (features)
labelNodes = (labels)
criterionNodes = (ce)
evaluationNodes = (errs)
outputNodes = (z)
}
SGD = [
epochSize = 0
minibatchSize = 1
learningRatesPerSample = 0.4
maxEpochs = 50
]
reader=[
readerType="CNTKTextFormatReader"
file="Train_xor.txt"
input = [
features = [
dim = $featureDimension$
alias = X
format = "dense"
]
labels = [
dim = $labelDimension$
alias = y
format = "dense"
]
]
]
]
Output = [
action="write"
reader=[
readerType="CNTKTextFormatReader"
file="Train_xor.txt"
input = [
features = [
dim = $featureDimension$
alias = X
format = "dense"
]
labels = [
dim = $labelDimension$
alias = y
format = "dense"
]
]
]
outputNodeNames = z
outputPath = "Output\xor.txt"
]
DumpNodeInfo = [
action = "dumpNode"
printValues = true
]
入力ファイルは次のようになります
|y 0 |X 0 0
|y 1 |X 1 0
|y 1 |X 0 1
|y 0 |X 1 1
そして、私はこの出力を取得します
0.490156
0.490092
0.489984
0.489920
それが役立つ場合、ノード ダンプは次のようになります。
b0=LearnableParameter [2,1] learningRateMultiplier=1.000000 NeedsGradient=true
-0.00745151564
0.0358283482
####################################################################
b1=LearnableParameter [1,1] learningRateMultiplier=1.000000 NeedsGradient=true
-0.0403601788
####################################################################
ce=SquareError ( labels , z )
errs=ClassificationError ( labels , z )
features=InputValue [ 2 ]
labels=InputValue [ 1 ]
o1=Plus ( o1.PlusArgs[0] , b0 )
o1.PlusArgs[0]=Times ( W0 , features )
W0=LearnableParameter [2,2] learningRateMultiplier=1.000000 NeedsGradient=true
-0.0214280766 0.0442263819
-0.0401388146 0.0261882655
####################################################################
W1=LearnableParameter [1,2] learningRateMultiplier=1.000000 NeedsGradient=true
-0.0281925034 0.0214234442
####################################################################
z=Sigmoid ( z._ )
z._=Plus ( z._.PlusArgs[0] , b1 )
z._.PlusArgs[0]=Times ( W1 , o1 )