From a538f070db1cfb8bee6772eff64cf8b1e6d661b8 Mon Sep 17 00:00:00 2001 From: Frank Seide Date: Tue, 24 Nov 2015 20:13:46 -0800 Subject: [PATCH] SimpleNetworkBuilder and NDLBuilder no longer derive from IComputationNetBuilder; steps towards making gcc happy (still stuck with a link error) --- Common/DataWriter.cpp | 3 --- .../LUSequenceReader/LUSequenceReader.cpp | 20 +++++++++++-------- DataReader/UCIFastReader/UCIFastReader.cpp | 13 ++++++------ MachineLearning/CNTK/NDLNetworkBuilder.h | 5 ++--- MachineLearning/CNTK/SimpleNetworkBuilder.h | 5 ++--- .../CNTKSGDLib/IComputationNetBuilder.h | 2 ++ 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Common/DataWriter.cpp b/Common/DataWriter.cpp index 22a26432e..8e8ee035e 100644 --- a/Common/DataWriter.cpp +++ b/Common/DataWriter.cpp @@ -27,7 +27,6 @@ void DataWriter::InitFromConfig(const ConfigRecordType & /*config*/) // not implemented, calls the underlying class instead } - // Destroy - cleanup and remove this class // NOTE: this destroys the object, and it can't be used past this point template @@ -83,8 +82,6 @@ template DataWriter::DataWriter(const ConfigParameters &); template DataWriter::DataWriter(const ScriptableObjects::IConfigRecord &); template DataWriter::DataWriter(const ScriptableObjects::IConfigRecord &); - - // destructor - cleanup temp files, etc. template DataWriter::~DataWriter() diff --git a/DataReader/LUSequenceReader/LUSequenceReader.cpp b/DataReader/LUSequenceReader/LUSequenceReader.cpp index 09101f22d..d71657c63 100644 --- a/DataReader/LUSequenceReader/LUSequenceReader.cpp +++ b/DataReader/LUSequenceReader/LUSequenceReader.cpp @@ -8,6 +8,8 @@ #include "stdafx.h" +#include "Basics.h" +#include "basetypes.h" #define DATAREADER_EXPORTS // creating the exports here #include "DataReader.h" #include "LUSequenceReader.h" @@ -369,8 +371,8 @@ void BatchLUSequenceReader::InitFromConfig(const ConfigRecordType & re const ConfigRecordType & labelConfig = readerConfig(m_labelsName[index].c_str(), ConfigRecordType::Record()); m_labelInfo[index].idMax = 0; - m_labelInfo[index].beginSequence = labelConfig(L"beginSequence", L""); - m_labelInfo[index].endSequence = labelConfig(L"endSequence", L""); + m_labelInfo[index].beginSequence = (wstring)labelConfig(L"beginSequence", L""); + m_labelInfo[index].endSequence = (wstring)labelConfig(L"endSequence", L""); m_labelInfo[index].busewordmap = labelConfig(L"useWordMap", false); m_labelInfo[index].isproposal = labelConfig(L"isProposal", false); @@ -423,9 +425,7 @@ void BatchLUSequenceReader::InitFromConfig(const ConfigRecordType & re m_readNextSampleLine = 0; m_readNextSample = 0; - ConfigArray wContext = readerConfig(L"wordContext", "0"); - intargvector wordContext = wContext; - m_wordContext = wordContext; + m_wordContext = readerConfig(L"wordContext", ConfigRecordType::Array(intargvector(vector{ 0 }))); // The input data is a combination of the label Data and extra feature dims together // m_featureCount = m_featureDim + m_labelInfo[labelInfoIn].dim; @@ -1145,14 +1145,18 @@ template template void BatchLUSequenceReader::LoadWordMapping(const ConfigRecordType& readerConfig) { - mWordMappingFn = readerConfig(L"wordmap", L""); + mWordMappingFn = (wstring)readerConfig(L"wordmap", L""); wstring si, so; wstring ss; vector vs; if (mWordMappingFn != L"") { wifstream fp; +#ifdef _WIN32 fp.open(mWordMappingFn.c_str(), wifstream::in); +#else + fp.open(charpath(mWordMappingFn), wifstream::in); +#endif while (fp.good()) { @@ -1230,13 +1234,13 @@ template template void MultiIOBatchLUSequenceReader::InitFromConfig(const ConfigRecordType & readerConfig) { - ConfigArray ioNames = readerConfig(L"ioNodeNames", ""); + vector ioNames = readerConfig(L"ioNodeNames", ConfigRecordType::Array(stringargvector())); if (ioNames.size() > 0) { /// newer code that explicitly place multiple streams for inputs foreach_index(i, ioNames) // inputNames should map to node names { - ConfigParameters thisIO = readerConfig(ioNames[i]); + const ConfigRecordType & thisIO = readerConfig(ioNames[i]); BatchLUSequenceReader *thisReader = new BatchLUSequenceReader(); thisReader->Init(thisIO); diff --git a/DataReader/UCIFastReader/UCIFastReader.cpp b/DataReader/UCIFastReader/UCIFastReader.cpp index ddb6bbf36..d314a44a2 100644 --- a/DataReader/UCIFastReader/UCIFastReader.cpp +++ b/DataReader/UCIFastReader/UCIFastReader.cpp @@ -360,21 +360,20 @@ void UCIFastReader::InitFromConfig(const ConfigRecordType & readerConf // determine label type desired std::wstring labelType; if (!hasLabels) - labelType = L"None"; + labelType = L"none"; else - labelType = configLabels(L"labelType", L"Category"); + labelType = (wstring)configLabels(L"labelType", L"category"); //convert to lower case for case insensitive comparison - msra::strfun::tolower_ascii(labelType); - if (labelType == L"category") + if (!_wcsicmp(labelType.c_str(), L"category")) { m_labelType = labelCategory; } - else if (labelType == L"regression") + else if (!_wcsicmp(labelType.c_str(), L"regression")) { m_labelType = labelRegression; } - else if (labelType == L"none") + else if (!_wcsicmp(labelType.c_str(), L"none")) { m_labelType = labelNone; dimLabels = 0; // override for no labels @@ -382,7 +381,7 @@ void UCIFastReader::InitFromConfig(const ConfigRecordType & readerConf std::wstring file = configFeatures(L"file"); if (m_traceLevel > 0) - fprintf(stderr, "reading uci file %ls\n", file.c_str()); + fprintf(stderr, "Reading UCI file %ls\n", file.c_str()); m_parser.ParseInit(file.c_str(), startFeatures, dimFeatures, startLabels, dimLabels); diff --git a/MachineLearning/CNTK/NDLNetworkBuilder.h b/MachineLearning/CNTK/NDLNetworkBuilder.h index 5c46142a6..2ccc9eca9 100644 --- a/MachineLearning/CNTK/NDLNetworkBuilder.h +++ b/MachineLearning/CNTK/NDLNetworkBuilder.h @@ -6,7 +6,6 @@ #pragma once #include "NetworkDescriptionLanguage.h" #include "ComputationNetwork.h" -#include "IComputationNetBuilder.h" #include "IExecutionEngine.h" #include "Basics.h" #include @@ -24,7 +23,7 @@ namespace Microsoft { namespace MSR { namespace CNTK { using namespace Microsoft::MSR; template - class NDLBuilder : public IComputationNetBuilder + class NDLBuilder { typedef shared_ptr> ComputationNodePtr; @@ -204,7 +203,7 @@ namespace Microsoft { namespace MSR { namespace CNTK { ndlUtil.ProcessNDLConfig(config, true); } - virtual ComputationNetworkPtr BuildNetworkFromDescription(ComputationNetwork* = nullptr) override + virtual ComputationNetworkPtr BuildNetworkFromDescription(ComputationNetwork* = nullptr) { if (m_net->GetTotalNumberOfNodes() < 1) //not built yet { diff --git a/MachineLearning/CNTK/SimpleNetworkBuilder.h b/MachineLearning/CNTK/SimpleNetworkBuilder.h index 440bbeb8f..937a81300 100644 --- a/MachineLearning/CNTK/SimpleNetworkBuilder.h +++ b/MachineLearning/CNTK/SimpleNetworkBuilder.h @@ -14,7 +14,6 @@ #include "BestGpu.h" #include "ComputationNetwork.h" -#include "IComputationNetBuilder.h" #include "commandArgUtil.h" // TODO: giving up moving stuff for now, running out of time. The following #includes should not be necessary once the hard-working code in here gets moved to .cpp @@ -74,7 +73,7 @@ namespace Microsoft { namespace MSR { namespace CNTK { extern EvalCriterion ParseEvalCriterionString(wstring s); template - class SimpleNetworkBuilder : public IComputationNetBuilder + class SimpleNetworkBuilder { protected: typedef shared_ptr> ComputationNodePtr; @@ -248,7 +247,7 @@ namespace Microsoft { namespace MSR { namespace CNTK { } - ComputationNetworkPtr BuildNetworkFromDescription(ComputationNetwork* encoderNet = nullptr) override; + ComputationNetworkPtr BuildNetworkFromDescription(ComputationNetwork* encoderNet = nullptr); ComputationNetworkPtr BuildNetworkFromDbnFile(const std::wstring& dbnModelFileName); // support for fseide's Microsoft-internal legacy tool "DBN.exe" diff --git a/MachineLearning/CNTKSGDLib/IComputationNetBuilder.h b/MachineLearning/CNTKSGDLib/IComputationNetBuilder.h index 4451dea7e..716b2c7b6 100644 --- a/MachineLearning/CNTKSGDLib/IComputationNetBuilder.h +++ b/MachineLearning/CNTKSGDLib/IComputationNetBuilder.h @@ -1,3 +1,4 @@ +#if 1 // only needed for some unused code in MultiNetworksSGD.h // // // Copyright (c) Microsoft Corporation. All rights reserved. @@ -25,3 +26,4 @@ namespace Microsoft { namespace MSR { namespace CNTK { }; }}} +#endif