C++ API Reference for Intel® Data Analytics Acceleration Library 2019 Update 4

adagrad_batch.h
1 /* file: adagrad_batch.h */
2 /*******************************************************************************
3 * Copyright 2014-2019 Intel Corporation.
4 *
5 * This software and the related documents are Intel copyrighted materials, and
6 * your use of them is governed by the express license under which they were
7 * provided to you (License). Unless the License provides otherwise, you may not
8 * use, modify, copy, publish, distribute, disclose or transmit this software or
9 * the related documents without Intel's prior written permission.
10 *
11 * This software and the related documents are provided as is, with no express
12 * or implied warranties, other than those that are expressly stated in the
13 * License.
14 *******************************************************************************/
15 
16 /*
17 //++
18 // Implementation of the interface for the adaptive gradient descent (Adagrad) algorithm
19 // in the batch processing mode
20 //--
21 */
22 
23 #ifndef __ADAGRAD_BATCH_H__
24 #define __ADAGRAD_BATCH_H__
25 
26 #include "algorithms/algorithm.h"
27 #include "data_management/data/numeric_table.h"
28 #include "services/daal_defines.h"
29 #include "algorithms/optimization_solver/iterative_solver/iterative_solver_batch.h"
30 #include "adagrad_types.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace optimization_solver
37 {
38 namespace adagrad
39 {
40 namespace interface1
41 {
55 template<typename algorithmFPType, Method method, CpuType cpu>
56 class DAAL_EXPORT BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
57 {
58 public:
64  BatchContainer(daal::services::Environment::env *daalEnv);
66  ~BatchContainer();
72  virtual services::Status compute() DAAL_C11_OVERRIDE;
73 };
74 
89 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
90 class DAAL_EXPORT Batch : public iterative_solver::Batch
91 {
92 public:
93  typedef algorithms::optimization_solver::adagrad::Input InputType;
94  typedef algorithms::optimization_solver::adagrad::Parameter ParameterType;
95  typedef algorithms::optimization_solver::adagrad::Result ResultType;
96 
97  InputType input;
98  ParameterType parameter;
101  Batch(sum_of_functions::BatchPtr objectiveFunction = sum_of_functions::BatchPtr()) :
102  parameter(objectiveFunction)
103  {
104  initialize();
105  }
106 
113  Batch(const Batch<algorithmFPType, method> &other) :
114  iterative_solver::Batch(other),
115  input(other.input),
116  parameter(other.parameter)
117  {
118  initialize();
119  }
120 
125  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
126 
131  virtual iterative_solver::Input * getInput() DAAL_C11_OVERRIDE { return &input; }
132 
137  virtual iterative_solver::Parameter * getParameter() DAAL_C11_OVERRIDE { return &parameter; }
138 
144  virtual services::Status createResult() DAAL_C11_OVERRIDE
145  {
146  _result = iterative_solver::ResultPtr(new ResultType());
147  _res = NULL;
148  return services::Status();
149  }
150 
156  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
157  {
158  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
159  }
160 
165  static services::SharedPtr<Batch<algorithmFPType, method> > create();
166 
167 protected:
168  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
169  {
170  return new Batch<algorithmFPType, method>(*this);
171  }
172 
173  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
174  {
175  services::Status s = static_cast<ResultType*>(_result.get())->allocate<algorithmFPType>(&input, &parameter, (int)method);
176  _res = _result.get();
177  return s;
178  }
179 
180  void initialize()
181  {
182  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
183  _par = &parameter;
184  _in = &input;
185  _result.reset(new ResultType());
186  }
187 };
189 } // namespace interface1
190 using interface1::BatchContainer;
191 using interface1::Batch;
192 
193 } // namespace adagrad
194 } // namespace optimization_solver
195 } // namespace algorithm
196 } // namespace daal
197 #endif
daal::algorithms::optimization_solver::adagrad::interface1::Batch::getInput
virtual iterative_solver::Input * getInput() DAAL_C11_OVERRIDE
Definition: adagrad_batch.h:131
daal
Definition: algorithm_base_common.h:31
daal::algorithms::optimization_solver::adagrad::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: adagrad_batch.h:125
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:53
daal::algorithms::optimization_solver::adagrad::interface1::Batch::Batch
Batch(sum_of_functions::BatchPtr objectiveFunction=sum_of_functions::BatchPtr())
Definition: adagrad_batch.h:101
daal::algorithms::optimization_solver::adagrad::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: adagrad_batch.h:113
daal::algorithms::optimization_solver::adagrad::interface1::Batch
Computes Adaptive gradient descent in the batch processing mode.
Definition: adagrad_batch.h:90
daal::algorithms::optimization_solver::adagrad::interface1::Batch::getParameter
virtual iterative_solver::Parameter * getParameter() DAAL_C11_OVERRIDE
Definition: adagrad_batch.h:137
daal::algorithms::optimization_solver::adagrad::interface1::Batch::parameter
ParameterType parameter
Definition: adagrad_batch.h:98
daal::algorithms::optimization_solver::adagrad::interface1::Batch::input
InputType input
Definition: adagrad_batch.h:97
daal_defines.h
daal::batch
Definition: daal_defines.h:110
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:68
daal::algorithms::optimization_solver::adagrad::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: adagrad_batch.h:156
daal::algorithms::optimization_solver::iterative_solver::interface1::Batch
Interface for computing the iterative solver in the batch processing mode.
Definition: iterative_solver_batch.h:52
daal::algorithms::optimization_solver::adagrad::interface1::Batch::createResult
virtual services::Status createResult() DAAL_C11_OVERRIDE
Definition: adagrad_batch.h:144
daal::algorithms::optimization_solver::adagrad::interface1::BatchContainer
Provides methods to run implementations of the adaptive gradient descent algorithm. This class is associated with daal::algorithms::optimization_solver::adagrad::BatchContainer class.
Definition: adagrad_batch.h:56
daal::algorithms::kmeans::objectiveFunction
Definition: kmeans_types.h:109

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