Skip to content

Commit

Permalink
Fix CntkEval.dll Related Issues
Browse files Browse the repository at this point in the history
Consumers of the CntkEval interface can pass in feature values
without label values. Most of the code was okay with this, but
the SimpleOutputWriter insisted on initializing both features
and labels. This caused GetMinibatchIntoNetwork function in
DataReaderHelpers.h to fail, when the layout of the label node
was incorrect.

I've changed the SimpleOutputWriter to only use input nodes
that are ancestors of the desired output nodes. This fixes the
issue for CntkEval usage.
  • Loading branch information
Jasha Droppo committed Jan 29, 2016
1 parent b8badf6 commit 91cf01e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Source/SGDLib/SimpleOutputWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,11 @@ class SimpleOutputWriter
m_net->AllocateAllMatrices({}, outputNodes, nullptr);

// specify feature value nodes
std::vector<ComputationNodeBasePtr>& featureNodes = m_net->FeatureNodes();
std::vector<ComputationNodeBasePtr>& labelNodes = m_net->LabelNodes();
std::map<std::wstring, Matrix<ElemType>*> inputMatrices;
for (size_t i = 0; i < featureNodes.size(); i++)
inputMatrices[featureNodes[i]->NodeName()] = &dynamic_pointer_cast<ComputationNode<ElemType>>(featureNodes[i])->Value();
for (size_t i = 0; i < labelNodes.size(); i++)
inputMatrices[labelNodes[i]->NodeName()] = &dynamic_pointer_cast<ComputationNode<ElemType>>(labelNodes[i])->Value();
for (auto& onode : outputNodes)
for (auto& inode : m_net->InputNodes(onode))
inputMatrices[inode->NodeName()] = &dynamic_pointer_cast<ComputationNode<ElemType>>(inode)->Value();

// Matrix<ElemType> endOfFile = Matrix<ElemType>((size_t)1,(size_t)1);
// endOfFile(0,0)=0;

Expand All @@ -76,8 +74,10 @@ class SimpleOutputWriter
size_t actualMBSize;
while (DataReaderHelpers::GetMinibatchIntoNetwork(dataReader, m_net, nullptr, false, false, inputMatrices, actualMBSize))
{
ComputationNetwork::BumpEvalTimeStamp(featureNodes);
ComputationNetwork::BumpEvalTimeStamp(labelNodes);
// Update timestamp for all input nodes ancestors of the output nodes
for (auto& onode : outputNodes)
for (auto& inode : m_net->InputNodes(onode))
inode->BumpEvalTimeStamp();

for (int i = 0; i < outputNodes.size(); i++)
{
Expand Down

0 comments on commit 91cf01e

Please sign in to comment.