C++ API Reference for Intel® Data Analytics Acceleration Library 2020 Update 1

neural_networks_prediction.h
1 /* file: neural_networks_prediction.h */
2 /*******************************************************************************
3 * Copyright 2014-2020 Intel Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *******************************************************************************/
17 
18 /*
19 //++
20 // Implementation of the interface for neural network model-based prediction
21 // in the batch processing mode
22 //--
23 */
24 
25 #ifndef __NEURAL_NETWORKS_PREDICTION_H__
26 #define __NEURAL_NETWORKS_PREDICTION_H__
27 
28 #include "algorithms/algorithm.h"
29 
30 #include "services/daal_defines.h"
31 #include "algorithms/neural_networks/neural_networks_types.h"
32 #include "algorithms/neural_networks/neural_networks_prediction_types.h"
33 #include "algorithms/neural_networks/neural_networks_prediction_model.h"
34 #include "algorithms/neural_networks/layers/layer.h"
35 
36 namespace daal
37 {
38 namespace algorithms
39 {
43 namespace neural_networks
44 {
45 namespace prediction
46 {
47 namespace interface1
48 {
59 template<typename algorithmFPType, Method method, CpuType cpu>
60 class BatchContainer : public PredictionContainerIface
61 {
62 public:
69  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv);
70  /*
71  * Default destructor
72  * \DAAL_DEPRECATED
73  */
74  DAAL_DEPRECATED ~BatchContainer();
79  DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE;
83  DAAL_DEPRECATED services::Status setupCompute() DAAL_C11_OVERRIDE;
87  DAAL_DEPRECATED services::Status resetCompute() DAAL_C11_OVERRIDE;
88 };
89 
107 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
108 class Batch : public daal::algorithms::Prediction
109 {
110 public:
111  typedef algorithms::neural_networks::prediction::Input InputType;
112  typedef algorithms::neural_networks::prediction::Parameter ParameterType;
113  typedef algorithms::neural_networks::prediction::Result ResultType;
114 
115  /*
116  * Default constructor
117  * \DAAL_DEPRECATED
118  */
119  DAAL_DEPRECATED Batch()
120  {
121  initialize();
122  };
123 
130  Batch(const Batch<algorithmFPType, method> &other) : parameter(other.parameter), input(other.input)
131  {
132  initialize();
133  }
134 
135  /*
136  * \DAAL_DEPRECATED
137  */
138  virtual ~Batch() {}
139 
145  DAAL_DEPRECATED ResultPtr getResult()
146  {
147  return _result;
148  }
149 
157  DAAL_DEPRECATED services::Status setResult(const ResultPtr& res)
158  {
159  DAAL_CHECK(res, services::ErrorNullResult)
160  _result = res;
161  _res = _result.get();
162  return services::Status();
163  }
164 
171  DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, method> > clone() const
172  {
173  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
174  }
175 
181  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
182 
183  InputType input;
184  ParameterType parameter;
186 protected:
187  /*
188  * \DAAL_DEPRECATED
189  */
190  void initialize()
191  {
192  Prediction::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
193  _in = &input;
194  _par = &parameter;
195  _result.reset(new ResultType());
196  }
197 
198  /*
199  * \DAAL_DEPRECATED
200  */
201  DAAL_DEPRECATED_VIRTUAL virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
202  {
203  return new Batch<algorithmFPType, method>(*this);
204  }
205 
206  /*
207  * \DAAL_DEPRECATED
208  */
209  DAAL_DEPRECATED_VIRTUAL virtual services::Status allocateResult() DAAL_C11_OVERRIDE
210  {
211  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int) method);
212  _res = _result.get();
213  return s;
214  }
215 
216 private:
217  ResultPtr _result;
218 };
219 
221 } // namespace interface1
222 using interface1::Batch;
223 using interface1::BatchContainer;
224 
225 } // namespace prediction
226 } // namespace neural_networks
227 } // namespace algorithms
228 } // namespace daal
229 #endif
daal::algorithms::neural_networks::prediction::interface1::Batch::input
InputType input
Definition: neural_networks_prediction.h:183
daal::batch
Definition: daal_defines.h:112
daal::algorithms::neural_networks::prediction::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: neural_networks_prediction.h:130
daal::algorithms::neural_networks::prediction::interface1::BatchContainer::compute
DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::neural_networks::prediction::prediction
Definition: neural_networks_prediction_result.h:55
daal::algorithms::neural_networks::prediction::interface1::Batch::getResult
DAAL_DEPRECATED ResultPtr getResult()
Definition: neural_networks_prediction.h:145
daal::algorithms::neural_networks::prediction::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::neural_networks::prediction::interface1::BatchContainer::setupCompute
DAAL_DEPRECATED services::Status setupCompute() DAAL_C11_OVERRIDE
daal::algorithms::neural_networks::prediction::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: neural_networks_prediction.h:181
daal::algorithms::neural_networks::prediction::interface1::Batch
Provides methods for neural network model-based prediction in the batch processing mode...
Definition: neural_networks_prediction.h:108
daal_defines.h
daal::algorithms::neural_networks::prediction::interface1::Batch::setResult
DAAL_DEPRECATED services::Status setResult(const ResultPtr &res)
Definition: neural_networks_prediction.h:157
daal::algorithms::PredictionContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the algor...
Definition: prediction.h:42
daal::algorithms::neural_networks::prediction::interface1::BatchContainer
Class containing methods to train neural network model using algorithmFPType precision arithmetic...
Definition: neural_networks_prediction.h:60
daal::algorithms::neural_networks::prediction::interface1::Batch::parameter
ParameterType parameter
Definition: neural_networks_prediction.h:184
daal::algorithms::neural_networks::prediction::interface1::BatchContainer::resetCompute
DAAL_DEPRECATED services::Status resetCompute() DAAL_C11_OVERRIDE
daal::algorithms::neural_networks::prediction::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: neural_networks_prediction.h:171
daal::algorithms::Prediction
Provides prediction methods depending on the model such as linear_regression::Model. The methods of the class support different computation modes: batch, distributed, and online(see ComputeMode). Classes that implement specific algorithms of the model based data prediction are derived classes of the Prediction class. The class additionally provides virtual methods for validation of input and output parameters of the algorithms.
Definition: prediction.h:52

For more complete information about compiler optimizations, see our Optimization Notice.