fixed 02_Convolutional as well for new tensor TimesNode

This commit is contained in:
Frank Seide 2016-02-26 14:14:43 -08:00
Родитель 10c4b7d3de
Коммит 81884e31db
5 изменённых файлов: 16 добавлений и 6 удалений

Просмотреть файл

@ -51,8 +51,8 @@ DNN=[
pool2 = MaxPooling(conv2_act, pool2W, pool2H, pool2hStride, pool2vStride, imageLayout=$imageLayout$)
h1Dim = 128
# DNNSigmoidLayer and DNNLayer are defined in Macros.ndl
h1 = DNNSigmoidLayer(512, h1Dim, pool2, 1)
# DNNImageSigmoidLayer and DNNLayer are defined in Macros.ndl
h1 = DNNImageSigmoidLayer(4, 4, cMap2, h1Dim, pool2, 1)
ol = DNNLayer(h1Dim, labelDim, h1, 1)
ce = CrossEntropyWithSoftmax(labels, ol)

Просмотреть файл

@ -6,6 +6,14 @@ DNNSigmoidLayer(inDim, outDim, x, parmScale) = [
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) = [
W = LearnableParameter(outDim, inDim, init="uniform", initValueScale=parmScale)
b = LearnableParameter(outDim, 1, init="uniform", initValueScale=parmScale)
@ -26,7 +34,7 @@ DnnBNReLULayer(inDim, outDim, x, wScale, bValue, scValue, expAvg) = [
ConvReLULayer(inp, outMap, inWCount, kW, kH, hStride, vStride, wScale, bValue) = [
convW = LearnableParameter(outMap, inWCount, init="uniform", initValueScale=wScale)
convB = ImageParameter(1, 1, outMap, init="fixedValue", value=bValue, imageLayout=$imageLayout$)
convB = ImageParameter(1, 1, outMap, init="fixedValue", value=bValue, imageLayout=$imageLayout$)
conv = Convolution(convW, inp, kW, kH, outMap, hStride, vStride, zeroPadding=false, imageLayout=$imageLayout$)
convPlusB = Plus(conv, convB);
act = RectifiedLinear(convPlusB);

Просмотреть файл

@ -114,7 +114,7 @@ void SynchronousNodeEvaluator<ElemType>::Evaluate(NDLNode<ElemType>* node, const
else
{
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)

Просмотреть файл

@ -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());
else if (dimA == 0)
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
@ -305,7 +307,6 @@ public:
std::swap(dimsA[0], dimsA[1]);
// update if LearnableParameter
Input(0)->ValidateInferInputDimsFrom(TensorShape(dimsA));
// and verify once again

Просмотреть файл

@ -98,7 +98,8 @@ train = [
h1Dim = 128
# 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
ce = CrossEntropyWithSoftmax(labels, ol, tag="criterion")