Skip to content

Commit

Permalink
deleted 5 unused methods
Browse files Browse the repository at this point in the history
  • Loading branch information
frankseide committed Jan 23, 2016
1 parent d48ec6f commit 6dff1a8
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 234 deletions.
83 changes: 15 additions & 68 deletions Source/ComputationNetworkLib/ComputationNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,12 @@ class ComputationNetwork : public ScriptableObjects::Object, public ScriptableOb
m_deviceId = EnforceOneGPUOnly(m_deviceId); // see EnforceOneGPUOnly() for comment on what this is
}

DEVICEID_TYPE GetDeviceId() const
{
return m_deviceId;
}
DEVICEID_TYPE GetDeviceId() const { return m_deviceId; }

// -----------------------------------------------------------------------
// serialization
// (de-)serialization
// -----------------------------------------------------------------------

void Save(const std::wstring& fileName, const FileOptions fileFormat = FileOptions::fileOptionsBinary) const;
void SaveEdited(const std::wstring& fileName, const FileOptions fileFormat = FileOptions::fileOptionsBinary);

private:
void SaveToFileImpl(const std::wstring& fileName, const FileOptions fileFormat) const;

public:
template <class ElemType>
void ReadPersistableParameters(File& fstream, bool create);
// reload node content only, e.g. used by SGD::Train() when going back to an older model that had better training objective
Expand Down Expand Up @@ -121,6 +111,15 @@ class ComputationNetwork : public ScriptableObjects::Object, public ScriptableOb
return net;
}

void Save(const std::wstring& fileName, const FileOptions fileFormat = FileOptions::fileOptionsBinary) const;
void SaveEdited(const std::wstring& fileName, const FileOptions fileFormat = FileOptions::fileOptionsBinary);

private:

void SaveToFileImpl(const std::wstring& fileName, const FileOptions fileFormat) const;

public:

// -----------------------------------------------------------------------
// evaluation
// -----------------------------------------------------------------------
Expand Down Expand Up @@ -261,28 +260,8 @@ class ComputationNetwork : public ScriptableObjects::Object, public ScriptableOb
// -----------------------------------------------------------------------

// Note: this is also used to copy MBLayouts into our existing MBLayout instance, which is a somewhat questionable design.
const MBLayoutPtr& GetMBLayoutPtr()
{
return m_pMBLayout;
}

size_t GetNumParallelSequences() const
{
return m_pMBLayout->GetNumParallelSequences();
}

// temporary function: Call this after CopyMBLayoutTo(evalnet->GetMBLayoutPtr()) to ensure everything is consistent as expected
// It is actually called after every CopyMBLayoutTo() in the entire system (except for multi-reader CopyMBLayoutTo() itself).
// Remove this function after a few weeks of not firing.
void VerifyActualNumParallelSequences(const size_t expectedNumSeq)
{
size_t actualNumSeq = GetNumParallelSequences();
if (actualNumSeq != expectedNumSeq)
{
LogicError("VerifyActualNumParallelSequences: Number of parallel sequences in MBLayout (%d) not matching expected value (%d).",
(int) actualNumSeq, (int) expectedNumSeq);
}
}
const MBLayoutPtr& GetMBLayoutPtr() { return m_pMBLayout; }
size_t GetNumParallelSequences() const { return m_pMBLayout->GetNumParallelSequences(); }

// determine the actual MB size from the feature nodes
// This returns max number of columns over the feature nodes.
Expand Down Expand Up @@ -580,45 +559,13 @@ class ComputationNetwork : public ScriptableObjects::Object, public ScriptableOb
template <class ElemType>
void PerformSVDecomposition(const map<wstring, float>& SVDConfig, size_t AlignedSize);

public:
// -----------------------------------------------------------------------
// evaluation: legacy
// construction
// -----------------------------------------------------------------------

// the following two are only called from FindBestPath() and FindbestPathWithVariableLength()
// This code is currently not in use.
// TODO: make these templated on <ElemType> locally
template <class ElemType>
void GetHistory(map<wstring, Matrix<ElemType>>& history, bool bLastTime = false)
{
// put all node info first
Matrix<ElemType> hist;
for (auto nodeIter = m_nameToNodeMap.begin(); nodeIter != m_nameToNodeMap.end(); nodeIter++)
{
shared_ptr<ComputationNode<ElemType>> nodePtr = dynamic_pointer_cast<ComputationNode<ElemType>>(nodeIter->second);
if (nodePtr && nodePtr->GetHistory(hist, bLastTime))
history[nodeIter->first] = hist;
}
};

template <class ElemType>
void SetHistory(map<wstring, Matrix<ElemType>>& history)
{
// put all node info first
for (auto nodeIter = m_nameToNodeMap.begin(); nodeIter != m_nameToNodeMap.end(); nodeIter++)
{
shared_ptr<ComputationNode<ElemType>> nodePtr = dynamic_pointer_cast<ComputationNode<ElemType>>(nodeIter->second);
if (nodePtr && history.find(nodeIter->first) != history.end())
nodePtr->SetHistory(history[nodeIter->first]);
}
};

protected:
// -----------------------------------------------------------------------
// construction
// -----------------------------------------------------------------------

// Copy constructor, should never be called.
// Copy constructor, should never be called.
#pragma warning(push)
#pragma warning(disable : 4702) // this function is flagged but unclear why
ComputationNetwork(const ComputationNetwork& /*deepCopyFrom*/)
Expand Down
17 changes: 0 additions & 17 deletions Source/ComputationNetworkLib/ComputationNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -1439,23 +1439,6 @@ class ComputationNode : public ComputationNodeBase // abstract class that cannot

public:

// these are used to export hidden state activations
virtual bool GetHistory(Matrix<ElemType>&, bool)
{
return false;
}
virtual void SetHistory(const Matrix<ElemType>&)
{
}

// these two are used to pass gradients from future minibatch
virtual void GetErrorsToPreviousMinibatch(Matrix<ElemType>&)
{
}
virtual void SetErrorsFromFutureMinibatch(Matrix<ElemType>&)
{
}

// -----------------------------------------------------------------------
// miscellaneous
// -----------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion Source/SGDLib/DataReaderHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ namespace Microsoft { namespace MSR { namespace CNTK {
// - GetMinibatch() --fills the inputMatrices
// - SetActualMiniBatchSizeFromFeatures() --tells Network to resize the nodes' buffers
// - CopyMBLayoutTo() --copies the MBLayout from Reader to Network
// - VerifyActualNumParallelSequences() --(refactoring left-over) verify that MBLayout is consistent with #parallel sequences
// with the special twist that in presence of parallelization, there is some decimation involved.

bool wasDataRead = trainSetDataReader.GetMinibatch(inputMatrices); // fill in the minibatch data into the Input nodes' buffers directly
Expand Down
Loading

0 comments on commit 6dff1a8

Please sign in to comment.