fixed 02_Convolutional as well for new tensor TimesNode
This commit is contained in:
Родитель
10c4b7d3de
Коммит
81884e31db
|
@ -51,8 +51,8 @@ DNN=[
|
||||||
pool2 = MaxPooling(conv2_act, pool2W, pool2H, pool2hStride, pool2vStride, imageLayout=$imageLayout$)
|
pool2 = MaxPooling(conv2_act, pool2W, pool2H, pool2hStride, pool2vStride, imageLayout=$imageLayout$)
|
||||||
|
|
||||||
h1Dim = 128
|
h1Dim = 128
|
||||||
# DNNSigmoidLayer and DNNLayer are defined in Macros.ndl
|
# DNNImageSigmoidLayer and DNNLayer are defined in Macros.ndl
|
||||||
h1 = DNNSigmoidLayer(512, h1Dim, pool2, 1)
|
h1 = DNNImageSigmoidLayer(4, 4, cMap2, h1Dim, pool2, 1)
|
||||||
ol = DNNLayer(h1Dim, labelDim, h1, 1)
|
ol = DNNLayer(h1Dim, labelDim, h1, 1)
|
||||||
|
|
||||||
ce = CrossEntropyWithSoftmax(labels, ol)
|
ce = CrossEntropyWithSoftmax(labels, ol)
|
||||||
|
|
|
@ -6,6 +6,14 @@ DNNSigmoidLayer(inDim, outDim, x, parmScale) = [
|
||||||
y = Sigmoid(z)
|
y = Sigmoid(z)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
DNNImageSigmoidLayer(inW, inH, inC, outDim, x, parmScale) = [
|
||||||
|
W = ImageParameter(outDim, inW, inH, inC, init="uniform", initValueScale=parmScale, imageLayout=$imageLayout$)
|
||||||
|
b = LearnableParameter(outDim, 1, init="uniform", initValueScale=parmScale)
|
||||||
|
t = Times(W, x)
|
||||||
|
z = Plus(t, b)
|
||||||
|
y = Sigmoid(z)
|
||||||
|
]
|
||||||
|
|
||||||
DNNLayer(inDim, outDim, x, parmScale) = [
|
DNNLayer(inDim, outDim, x, parmScale) = [
|
||||||
W = LearnableParameter(outDim, inDim, init="uniform", initValueScale=parmScale)
|
W = LearnableParameter(outDim, inDim, init="uniform", initValueScale=parmScale)
|
||||||
b = LearnableParameter(outDim, 1, init="uniform", initValueScale=parmScale)
|
b = LearnableParameter(outDim, 1, init="uniform", initValueScale=parmScale)
|
||||||
|
|
|
@ -114,7 +114,7 @@ void SynchronousNodeEvaluator<ElemType>::Evaluate(NDLNode<ElemType>* node, const
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (parameter.size() < 3)
|
if (parameter.size() < 3)
|
||||||
RuntimeError("%ls should have 3 parameters [imageWidth, imageHeight, imageChannels] plus other optional parameters (learningRateMultiplier=[1|0|float], init=[uniform|gaussian|fixedvalue], initValueScale=[1|float], value=[0|float]).", cnNodeType.c_str());
|
RuntimeError("%ls should have 3 or more parameters [imageWidth, imageHeight, imageChannels] plus other optional parameters (learningRateMultiplier=[1|0|float], init=[uniform|gaussian|fixedvalue], initValueScale=[1|float], value=[0|float]).", cnNodeType.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pass == ndlPassInitial)
|
if (pass == ndlPassInitial)
|
||||||
|
|
|
@ -298,6 +298,8 @@ public:
|
||||||
InvalidArgument("%ls %ls operation: Right [%s] operand must have zero dimensions.", NodeName().c_str(), OperationName().c_str(), dimsBstring.c_str());
|
InvalidArgument("%ls %ls operation: Right [%s] operand must have zero dimensions.", NodeName().c_str(), OperationName().c_str(), dimsBstring.c_str());
|
||||||
else if (dimA == 0)
|
else if (dimA == 0)
|
||||||
dimA = dimB; // infer dimension
|
dimA = dimB; // infer dimension
|
||||||
|
else if (dimA != dimB)
|
||||||
|
InvalidArgument("%ls %ls operation: Left [%s] and right [%s] operands' shapes are not compatible.", NodeName().c_str(), OperationName().c_str(), dimsAstring.c_str(), dimsBstring.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// swap back in case of TransposeTimes
|
// swap back in case of TransposeTimes
|
||||||
|
@ -305,7 +307,6 @@ public:
|
||||||
std::swap(dimsA[0], dimsA[1]);
|
std::swap(dimsA[0], dimsA[1]);
|
||||||
|
|
||||||
// update if LearnableParameter
|
// update if LearnableParameter
|
||||||
|
|
||||||
Input(0)->ValidateInferInputDimsFrom(TensorShape(dimsA));
|
Input(0)->ValidateInferInputDimsFrom(TensorShape(dimsA));
|
||||||
|
|
||||||
// and verify once again
|
// and verify once again
|
||||||
|
|
|
@ -98,7 +98,8 @@ train = [
|
||||||
|
|
||||||
h1Dim = 128
|
h1Dim = 128
|
||||||
# DNNSigmoidLayer and DNNLayer are defined in Macros.ndl
|
# DNNSigmoidLayer and DNNLayer are defined in Macros.ndl
|
||||||
h1 = DNNSigmoidLayer((cMap2 : 4 : 4), h1Dim, pool2, 1).out
|
h1 = DNNSigmoidLayer(if useCuDnn then (4 : 4 : cMap2/*cudnn: CHW*/) else (cMap2 : 4 : 4/*legacy: HWC*/), h1Dim, pool2, 1).out
|
||||||
|
# Note: 'CHW' and 'HWC' refer to row-major representations, while CNTK uses column-major, so must specify the values in reverse order
|
||||||
ol = DNNLayer(h1Dim, labelDim, h1, 1).out
|
ol = DNNLayer(h1Dim, labelDim, h1, 1).out
|
||||||
|
|
||||||
ce = CrossEntropyWithSoftmax(labels, ol, tag="criterion")
|
ce = CrossEntropyWithSoftmax(labels, ol, tag="criterion")
|
||||||
|
|
Загрузка…
Ссылка в новой задаче