Skip to content

Commit

Permalink
Integrate gaizna/exportdbn into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Project Philly committed Feb 17, 2016
2 parents caccaf3 + e3dbc9c commit a34922b
Show file tree
Hide file tree
Showing 5 changed files with 355 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Source/ActionsLib/Actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void DoCrossValidate(const ConfigParameters& config);
template <typename ElemType>
void DoWriteOutput(const ConfigParameters& config);

// misc (OtherActions.cp)
// misc (OtherActions.cpp)
template <typename ElemType>
void DoCreateLabelMap(const ConfigParameters& config);
template <typename ElemType>
Expand All @@ -43,6 +43,8 @@ void DoWriteWordAndClassInfo(const ConfigParameters& config);
template <typename ElemType>
void DoTopologyPlot(const ConfigParameters& config);

// special purpose (EsotericActions.cp)
// special purpose (SpecialPurposeActions.cpp)
template <typename ElemType>
void DoConvertFromDbn(const ConfigParameters& config);
template<typename ElemType>
void DoExportToDbn(const ConfigParameters& config);
21 changes: 21 additions & 0 deletions Source/ActionsLib/SpecialPurposeActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,26 @@ void DoConvertFromDbn(const ConfigParameters& config)
net->Save(modelPath);
}

// ===========================================================================
// DoExportToDbn() - implements CNTK "exportdbn" command
// ===========================================================================

template <typename ElemType>
void DoExportToDbn(const ConfigParameters& config)
{
DEVICEID_TYPE deviceID = DeviceFromConfig(config);

const wstring modelPath = config("modelPath");
wstring dbnModelPath = config("dbnModelPath");

ComputationNetworkPtr net = make_shared<ComputationNetwork>(deviceID);
net->Load<ElemType>(modelPath);

// write dbn file
net->SaveToDbnFile<ElemType>(net, dbnModelPath);
}

template void DoConvertFromDbn<float>(const ConfigParameters& config);
template void DoConvertFromDbn<double>(const ConfigParameters& config);
template void DoExportToDbn<float>(const ConfigParameters& config);
template void DoExportToDbn<double>(const ConfigParameters& config);
4 changes: 4 additions & 0 deletions Source/CNTK/CNTK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ void DoCommands(const ConfigParameters& config)
{
DoConvertFromDbn<ElemType>(commandParams);
}
else if (action[j] == "exportdbn")
{
DoExportToDbn<ElemType>(commandParams);
}
else if (action[j] == "createLabelMap")
{
DoCreateLabelMap<ElemType>(commandParams);
Expand Down
Loading

0 comments on commit a34922b

Please sign in to comment.