marked CRFNode as #ifdef COMING_SOON
This commit is contained in:
Родитель
198d64dd64
Коммит
b0bbc0c949
|
@ -155,7 +155,9 @@ bool CheckFunction(std::string& p_nodeType, bool* allowUndeterminedVariable)
|
|||
bool ret = false;
|
||||
if (EqualInsensitive(nodeType, OperationNameOf(AveragePoolingNode))) ret = true;
|
||||
else if (EqualInsensitive(nodeType, OperationNameOf(BatchNormalizationNode))) ret = true;
|
||||
#ifdef COMING_SOON
|
||||
else if (EqualInsensitive(nodeType, OperationNameOf(CRFNode), L"CRF")) ret = true;
|
||||
#endif
|
||||
else if (EqualInsensitive(nodeType, OperationNameOf(ClassBasedCrossEntropyWithSoftmaxNode), L"CBCEWithSM")) ret = true;
|
||||
else if (EqualInsensitive(nodeType, OperationNameOf(ConvolutionNode), L"Convolve")) ret = true;
|
||||
else if (EqualInsensitive(nodeType, OperationNameOf(CosDistanceNode), L"CosDist")) ret = true;
|
||||
|
|
|
@ -1688,10 +1688,12 @@ shared_ptr<ComputationNode<ElemType>> SimpleNetworkBuilder<ElemType>::AddTrainAn
|
|||
tinput = builder.Times(matrix, input);
|
||||
output = builder.Logistic(label, tinput, (trainNodeName == L"") ? L"Logistic" : trainNodeName);
|
||||
break;
|
||||
#ifdef COMING_SOON
|
||||
case TrainingCriterion::CRF:
|
||||
assert(trans != nullptr);
|
||||
output = builder.CRF(label, input, trans, (trainNodeName == L"") ? L"CRF" : trainNodeName);
|
||||
break;
|
||||
#endif
|
||||
case TrainingCriterion::ClassCrossEntropyWithSoftmax:
|
||||
output = builder.ClassCrossEntropyWithSoftmax(label, input, matrix, clspostprob, (trainNodeName == L"") ? L"ClassCrossEntropyWithSoftmax" : trainNodeName);
|
||||
break;
|
||||
|
@ -1743,12 +1745,14 @@ shared_ptr<ComputationNode<ElemType>> SimpleNetworkBuilder<ElemType>::AddTrainAn
|
|||
tinput = builder.Times(matrix, input);
|
||||
output = builder.ErrorPrediction(label, tinput, (evalNodeName == L"") ? L"EvalErrorPrediction" : evalNodeName);
|
||||
break;
|
||||
#ifdef COMING_SOON
|
||||
case EvalCriterion::CRF:
|
||||
assert(trans != nullptr);
|
||||
if (matrix != nullptr && tinput == input)
|
||||
tinput = builder.Times(matrix, input);
|
||||
output = builder.CRF(label, tinput, trans, (evalNodeName == L"") ? L"EvalCRF" : evalNodeName);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
LogicError("Unsupported training criterion.");
|
||||
}
|
||||
|
@ -1769,14 +1773,10 @@ template class SimpleNetworkBuilder<double>;
|
|||
|
||||
TrainingCriterion ParseTrainingCriterionString(wstring s)
|
||||
{
|
||||
if (!_wcsicmp(s.c_str(), L"crossEntropyWithSoftmax"))
|
||||
return TrainingCriterion::CrossEntropyWithSoftmax;
|
||||
if (!_wcsicmp(s.c_str(), L"sequenceWithSoftmax"))
|
||||
return TrainingCriterion::SequenceWithSoftmax;
|
||||
else if (!_wcsicmp(s.c_str(), L"squareError"))
|
||||
return TrainingCriterion::SquareError;
|
||||
else if (!_wcsicmp(s.c_str(), L"logistic"))
|
||||
return TrainingCriterion::Logistic;
|
||||
if (!_wcsicmp(s.c_str(), L"crossEntropyWithSoftmax")) return TrainingCriterion::CrossEntropyWithSoftmax;
|
||||
else if (!_wcsicmp(s.c_str(), L"sequenceWithSoftmax")) return TrainingCriterion::SequenceWithSoftmax;
|
||||
else if (!_wcsicmp(s.c_str(), L"squareError")) return TrainingCriterion::SquareError;
|
||||
else if (!_wcsicmp(s.c_str(), L"logistic")) return TrainingCriterion::Logistic;
|
||||
else if (!_wcsicmp(s.c_str(), L"noiseContrastiveEstimation") || !_wcsicmp(s.c_str(), L"noiseContrastiveEstimationNode" /*spelling error, deprecated*/))
|
||||
return TrainingCriterion::NCECrossEntropyWithSoftmax;
|
||||
else if (!!_wcsicmp(s.c_str(), L"classCrossEntropyWithSoftmax")) // (twisted logic to keep compiler happy w.r.t. not returning from LogicError)
|
||||
|
@ -1786,20 +1786,16 @@ TrainingCriterion ParseTrainingCriterionString(wstring s)
|
|||
|
||||
EvalCriterion ParseEvalCriterionString(wstring s)
|
||||
{
|
||||
if (!_wcsicmp(s.c_str(), L"errorPrediction"))
|
||||
return EvalCriterion::ErrorPrediction;
|
||||
else if (!_wcsicmp(s.c_str(), L"crossEntropyWithSoftmax"))
|
||||
return EvalCriterion::CrossEntropyWithSoftmax;
|
||||
else if (!_wcsicmp(s.c_str(), L"sequenceWithSoftmax"))
|
||||
return EvalCriterion::SequenceWithSoftmax;
|
||||
else if (!_wcsicmp(s.c_str(), L"classCrossEntropyWithSoftmax"))
|
||||
return EvalCriterion::ClassCrossEntropyWithSoftmax;
|
||||
if (!_wcsicmp(s.c_str(), L"errorPrediction")) return EvalCriterion::ErrorPrediction;
|
||||
else if (!_wcsicmp(s.c_str(), L"crossEntropyWithSoftmax")) return EvalCriterion::CrossEntropyWithSoftmax;
|
||||
else if (!_wcsicmp(s.c_str(), L"sequenceWithSoftmax")) return EvalCriterion::SequenceWithSoftmax;
|
||||
else if (!_wcsicmp(s.c_str(), L"classCrossEntropyWithSoftmax")) return EvalCriterion::ClassCrossEntropyWithSoftmax;
|
||||
else if (!_wcsicmp(s.c_str(), L"logistic")) return EvalCriterion::Logistic;
|
||||
else if (!_wcsicmp(s.c_str(), L"noiseContrastiveEstimation") || !_wcsicmp(s.c_str(), L"noiseContrastiveEstimationNode" /*spelling error, deprecated*/))
|
||||
return EvalCriterion::NCECrossEntropyWithSoftmax;
|
||||
else if (!_wcsicmp(s.c_str(), L"logistic"))
|
||||
return EvalCriterion::Logistic;
|
||||
else if (!!_wcsicmp(s.c_str(), L"squareError"))
|
||||
LogicError("evalCriterion: Invalid trainingCriterion value. Valid values are (errorPrediction | crossEntropyWithSoftmax | squareError | logistic | sequenceWithSoftmax)");
|
||||
return EvalCriterion::SquareError;
|
||||
}
|
||||
|
||||
} } }
|
||||
|
|
|
@ -464,10 +464,6 @@ typedef MBLayout::MBLayoutPtr MBLayoutPtr;
|
|||
// TODO: This will in the future be able to hold sub-ranges for nested loops as well.
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// TODO: We should also have a FrameRange that selects all frames of a single sequence. Currently now possible since that would require Matrix::RowSlice()
|
||||
// - likewise, LSTMNode does its own iteration, hence needs access to GetNumParallelSequences() or NumCols() in the whole-batch iterator
|
||||
// BUGBUG: These nodes are currently broken and will need to be fixed:
|
||||
// - CRFNode does not support > 1 parallel sequence
|
||||
class FrameRange
|
||||
{
|
||||
public: // TODO: make private (currently used from masking and DataFor) ; TODO: rename all members with m_ prefix
|
||||
|
|
|
@ -418,7 +418,9 @@ bool ComputationNetwork::IsTypicalCriterionNode(ComputationNodeBasePtr nodePtr)
|
|||
nodePtr->OperationName() == OperationNameOf(CrossEntropyNode) ||
|
||||
nodePtr->OperationName() == OperationNameOf(ClassBasedCrossEntropyWithSoftmaxNode) ||
|
||||
nodePtr->OperationName() == OperationNameOf(ErrorPredictionNode) ||
|
||||
#ifdef COMING_SOON
|
||||
nodePtr->OperationName() == OperationNameOf(CRFNode) ||
|
||||
#endif
|
||||
nodePtr->OperationName() == OperationNameOf(DummyCriterionNode))
|
||||
return true;
|
||||
|
||||
|
|
|
@ -981,10 +981,5 @@ typedef ComputationNetwork::ComputationNetworkPtr ComputationNetworkPtr;
|
|||
// - code prettification:
|
||||
// - sort all node implementations' methods into the same order; esp, ForwardProp() comes before partial
|
||||
// - sort important nodes first; move unused/experimental nodes into source files named accordingly
|
||||
// - finish the job:
|
||||
// - everywhere complete folding ForwardPropS() into ForwardProp(FrameRange()), same for partial
|
||||
// - revise node constructors, merge by means of default parameters
|
||||
// - known issues that need actual test cases to be fixed:
|
||||
// - CRFNode::BackpropTo() fails for >1 parallel sequence due to DataFor() not being able to return whole sequences
|
||||
// - implement reading of MB Layout in Binary, DSSM, and LivbSVM readers --is DSSM already done?
|
||||
|
||||
} } }
|
||||
|
|
|
@ -33,8 +33,11 @@ template <class ElemType, class... _Types>
|
|||
static shared_ptr<ComputationNode<ElemType>> CreateStandardNode(const std::wstring& nodeType, _Types&&... _Args)
|
||||
{
|
||||
// please keep this table sorted
|
||||
if (nodeType == OperationNameOf(CRFNode)) return New<CRFNode<ElemType>>(forward<_Types>(_Args)...);
|
||||
else if (nodeType == OperationNameOf(ClassBasedCrossEntropyWithSoftmaxNode))return New<ClassBasedCrossEntropyWithSoftmaxNode<ElemType>>(forward<_Types>(_Args)...);
|
||||
#ifdef COMING_SOON
|
||||
if (nodeType == OperationNameOf(CRFNode)) return New<CRFNode<ElemType>>(forward<_Types>(_Args)...);
|
||||
else
|
||||
#endif
|
||||
if (nodeType == OperationNameOf(ClassBasedCrossEntropyWithSoftmaxNode))return New<ClassBasedCrossEntropyWithSoftmaxNode<ElemType>>(forward<_Types>(_Args)...);
|
||||
else if (nodeType == OperationNameOf(CosDistanceNode)) return New<CosDistanceNode<ElemType>>(forward<_Types>(_Args)...);
|
||||
else if (nodeType == OperationNameOf(CosDistanceWithNegativeSamplesNode)) return New<CosDistanceWithNegativeSamplesNode<ElemType>>(forward<_Types>(_Args)...);
|
||||
else if (nodeType == OperationNameOf(CosineNode)) return New<CosineNode<ElemType>>(forward<_Types>(_Args)...);
|
||||
|
@ -346,6 +349,7 @@ shared_ptr<ComputationNode<ElemType>> ComputationNetworkBuilder<ElemType>::Class
|
|||
return net.AddNodeToNetAndAttachInputs(New<ClassBasedCrossEntropyWithSoftmaxNode<ElemType>>(net.GetDeviceId(), nodeName), label, prediction, input_weight, cls_log_post_prob);
|
||||
}
|
||||
|
||||
#ifdef COMING_SOON
|
||||
template <class ElemType>
|
||||
shared_ptr<ComputationNode<ElemType>> ComputationNetworkBuilder<ElemType>::CRF(const ComputationNodePtr label,
|
||||
const ComputationNodePtr postDepScore,
|
||||
|
@ -354,6 +358,7 @@ shared_ptr<ComputationNode<ElemType>> ComputationNetworkBuilder<ElemType>::CRF(c
|
|||
{
|
||||
return net.AddNodeToNetAndAttachInputs(New<CRFNode<ElemType>>(net.GetDeviceId(), nodeName), label, postDepScore, transition_score);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class ElemType>
|
||||
shared_ptr<ComputationNode<ElemType>> ComputationNetworkBuilder<ElemType>::DummyCriterion(const ComputationNodePtr objectives, const ComputationNodePtr derivatives, const ComputationNodePtr prediction, const std::wstring nodeName)
|
||||
|
@ -605,4 +610,5 @@ shared_ptr<ComputationNode<ElemType>> ComputationNetworkBuilder<ElemType>::Batch
|
|||
|
||||
template class ComputationNetworkBuilder<float>;
|
||||
template class ComputationNetworkBuilder<double>;
|
||||
|
||||
} } }
|
||||
|
|
|
@ -73,7 +73,9 @@ public:
|
|||
ComputationNodePtr AveragePooling(const ComputationNodePtr inputValues,
|
||||
const size_t windowWidth, const size_t windowHeight, const size_t horizontalSubsample, const size_t verticalSubsample, ImageLayoutKind imageLayoutKind,
|
||||
const std::wstring nodeName = L"");
|
||||
#ifdef COMING_SOON
|
||||
ComputationNodePtr CRF(const ComputationNodePtr label, const ComputationNodePtr postDepScore, const ComputationNodePtr transition_score, const std::wstring nodeName = L"");
|
||||
#endif
|
||||
ComputationNodePtr ClassCrossEntropyWithSoftmax(const ComputationNodePtr label, const ComputationNodePtr prediction, const ComputationNodePtr input_weight, const ComputationNodePtr cls_log_post_prob, const std::wstring nodeName = L"");
|
||||
ComputationNodePtr Cos(const ComputationNodePtr a, const std::wstring nodeName = L"");
|
||||
ComputationNodePtr CosDistance(const ComputationNodePtr a, const ComputationNodePtr b, const std::wstring nodeName = L"");
|
||||
|
|
|
@ -1599,7 +1599,7 @@ inline shared_ptr<C> New(_Types&&... _Args)
|
|||
|
||||
// =======================================================================
|
||||
// ComputationNodeNonLooping -- abstract base class for computation nodes that do not implement eval/partial for individual frames
|
||||
// Such as CRFNode, LSTMNode, ParallelNode, SequenceDecoderNode, TimeReverseNode (BatchModeNode), and TransposeNode.
|
||||
// Such as CRFNode, SequenceDecoderNode, and training criteria.
|
||||
// =======================================================================
|
||||
|
||||
// This will provide default implementations for those two functions that will fail at runtime with a meaningful error.
|
||||
|
|
|
@ -1016,6 +1016,8 @@ protected:
|
|||
template class ClassBasedCrossEntropyWithSoftmaxNode<float>;
|
||||
template class ClassBasedCrossEntropyWithSoftmaxNode<double>;
|
||||
|
||||
#ifdef COMING_SOON
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// CRFNode (labels, position_dependent_scores, transition_scores)
|
||||
// - labels: output label vector of [0:T-1]
|
||||
|
@ -1315,6 +1317,8 @@ private:
|
|||
int mEndLbl;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// LogisticNode (labels, prediction, weight)
|
||||
// calculates: -sum(left * log(right) + (1-left)*log(1-right)) (optionally * weight)
|
||||
|
|
Загрузка…
Ссылка в новой задаче