forked from microsoft/CNTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CNTKEval.h
61 lines (50 loc) · 2.08 KB
/
CNTKEval.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
//
// CNTKEval.h - Include file for the CNTK Evaluation DLL
//
#pragma once
#include <string>
#include <map>
#include <vector>
#include "Eval.h"
#include "EvalReader.h"
#include "EvalWriter.h"
#include "ComputationNetwork.h"
namespace Microsoft { namespace MSR { namespace CNTK {
template <class ElemType>
class CNTKEval : public IEvaluateModel<ElemType>
{
typedef shared_ptr<ComputationNode<ElemType>> ComputationNodePtr;
EvalReader<ElemType>* m_reader;
EvalWriter<ElemType>* m_writer;
ConfigParameters m_config;
ComputationNetworkPtr m_net;
std::map<std::wstring, size_t> m_dimensions;
size_t m_start;
public:
// constructor
CNTKEval()
: m_reader(nullptr), m_net(nullptr)
{
}
// LoadModel - load a model from the specified path
// modelFileName - file holding the model to load
virtual void LoadModel(const std::wstring& modelFileName);
// GetNodeDimensions - Get the node dimensions of the specified nodes
// dimensions - map from name of node to dimension of the node
// nodeGroup - type of node we are requesting (input/output/specified)
virtual void GetNodeDimensions(std::map<std::wstring, size_t>& dimensions, NodeGroup nodeGroup);
// StartEvaluateMinibatchLoop - Prepare network for Evaluate() calls.
// ouputNodeName - name of node that will be evaluated
virtual void StartEvaluateMinibatchLoop(const std::wstring& outputNodeName);
// Evaluate - Evalute using the model with the given inputs and outputs
// inputs - map from node name to input vector
// outputs - map from node name to output vector, outputs vectors need to be preallocated by caller, sizing will happen during evaluation
virtual void Evaluate(std::map<std::wstring, std::vector<ElemType>*>& inputs, std::map<std::wstring, std::vector<ElemType>*>& outputs);
virtual void Init(const std::string& config);
virtual void Destroy();
virtual void ResetState();
};
} } }