change several assertions to exception throw to guard it from incorrect behavior under the release build.

change gradient check error information display from stdout to stderr.
This commit is contained in:
Dong Yu 2014-10-16 16:37:37 -07:00
Родитель a6d0f8176d
Коммит c56a245433
5 изменённых файлов: 8 добавлений и 10 удалений

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

@ -1425,12 +1425,10 @@ namespace Microsoft { namespace MSR { namespace CNTK {
switch (endDataType)
{
case endDataNull:
assert(false);
break;
case endDataEpoch:
case endDataSet:
assert(false); // not support
break;
throw std::logic_error("DataEnd: does not support endDataTypes: endDataNull, endDataEpoch and endDataSet");
break;
case endDataSentence:
if (m_truncated)
ret = m_sentenceEnd[0];

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

@ -78,6 +78,7 @@ public:
virtual void GetSections(std::map<std::wstring, SectionType, nocase_compare>& /*sections*/)
{
assert(false);
NOT_IMPLEMENTED;
}
virtual bool SaveData(size_t /*recordStart*/, const std::map<std::wstring, void*, nocase_compare>& matrices, size_t numRecords, size_t /*datasetSize*/, size_t /*byteVariableSized*/)
{

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

@ -828,11 +828,11 @@ namespace Microsoft { namespace MSR { namespace CNTK {
}
virtual ComputationNodePtr Duplicate(const std::wstring& newName, const CopyNodeFlags flags) const = 0;
virtual TaskDescriptor<ElemType>* GetPTaskDescriptor(TaskType /*taskType*/, size_t inputIndex=0) const
virtual TaskDescriptor<ElemType>* GetPTaskDescriptor(TaskType /*taskType*/, size_t /*inputIndex=0*/) const
{
inputIndex;
assert(false);
return NULL;
NOT_IMPLEMENTED;
//return NULL;
}
protected:

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

@ -1347,7 +1347,7 @@ protected:
bool wrong = (_isnan(diff) || diff > threshold);
if (wrong)
{
fprintf (stdout, "\nd%ws Numeric gradient = %e, Error BP gradient = %e\n", node->NodeName().c_str(), eGradNum, eGradErr);
fprintf (stderr, "\nd%ws Numeric gradient = %e, Error BP gradient = %e\n", node->NodeName().c_str(), eGradNum, eGradErr);
return false;
}
}

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

@ -764,8 +764,7 @@ protected:
// Copy constructor, should never be called.
SynchronousExecutionEngine(const SynchronousExecutionEngine<ElemType>& /*deepCopyFrom*/)
{
assert(false);
//throw std::logic_error("'SynchronousExecutionEngine(const SynchronousExecutionEngine<ElemType>& deepCopyFrom)' should never be called.");
throw std::logic_error("'SynchronousExecutionEngine(const SynchronousExecutionEngine<ElemType>& deepCopyFrom)' should never be called.");
}
// Assignment operator, should never be called.