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

truncated_gaussian_initializer.h
1 /* file: truncated_gaussian_initializer.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 truncated gaussian initializer in the batch processing mode
19 //--
20 */
21 
22 #ifndef __TRUNCATED_GAUSSIAN_INITIALIZER_H__
23 #define __TRUNCATED_GAUSSIAN_INITIALIZER_H__
24 
25 #include "algorithms/algorithm.h"
26 #include "data_management/data/tensor.h"
27 #include "services/daal_defines.h"
28 #include "algorithms/neural_networks/initializers/initializer.h"
29 #include "algorithms/neural_networks/initializers/initializer_types.h"
30 #include "algorithms/neural_networks/initializers/truncated_gaussian/truncated_gaussian_initializer_types.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace neural_networks
37 {
38 namespace initializers
39 {
40 namespace truncated_gaussian
41 {
47 namespace interface1
48 {
59 template<typename algorithmFPType, Method method, CpuType cpu>
60 class DAAL_EXPORT BatchContainer : public initializers::InitializerContainerIface
61 {
62 public:
68  BatchContainer(daal::services::Environment::env *daalEnv);
70  ~BatchContainer();
76  services::Status compute() DAAL_C11_OVERRIDE;
77 };
78 
93 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
94 class DAAL_EXPORT Batch : public initializers::InitializerIface
95 {
96 public:
97  typedef initializers::InitializerIface super;
98 
99  typedef typename super::InputType InputType;
100  typedef algorithms::neural_networks::initializers::truncated_gaussian::Parameter<algorithmFPType> ParameterType;
101  typedef typename super::ResultType ResultType;
102 
103  Parameter<algorithmFPType> parameter;
110  Batch(double mean = 0, double sigma = 1.00) : parameter(mean, sigma)
111  {
112  initialize();
113  }
114 
120  Batch(const Batch<algorithmFPType, method> &other) : super(other), parameter(other.parameter)
121  {
122  initialize();
123  }
124 
129  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
130 
135  virtual ParameterType * getParameter() DAAL_C11_OVERRIDE { return &parameter; }
136 
141  ResultPtr getResult()
142  {
143  return _result;
144  }
145 
152  services::Status setResult(const ResultPtr &result)
153  {
154  DAAL_CHECK(result, services::ErrorNullResult)
155  _result = result;
156  _res = _result.get();
157  return services::Status();
158  }
159 
165  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
166  {
167  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
168  }
169 
175  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
176  {
177  _par = &parameter;
178  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), &parameter, (int) method);
179  this->_res = this->_result.get();
180  return s;
181  }
182 
183 protected:
184  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
185  {
186  return new Batch<algorithmFPType, method>(*this);
187  }
188 
189  void initialize()
190  {
191  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
192  _in = &input;
193  _par = &parameter;
194  _result.reset(new ResultType());
195  }
196 
197 private:
198  ResultPtr _result;
199 };
200 
201 } // namespace interface1
202 using interface1::BatchContainer;
203 using interface1::Batch;
205 } // namespace truncated_gaussian
206 } // namespace initializers
207 } // namespace neural_networks
208 } // namespace algorithms
209 } // namespace daal
210 #endif
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::BatchContainer
Provides methods to run implementations of the truncated gaussian initializer. This class is associat...
Definition: truncated_gaussian_initializer.h:60
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: truncated_gaussian_initializer.h:152
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::Batch::parameter
Parameter< algorithmFPType > parameter
Definition: truncated_gaussian_initializer.h:103
daal
Definition: algorithm_base_common.h:31
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::Batch::getResult
ResultPtr getResult()
Definition: truncated_gaussian_initializer.h:141
daal_defines.h
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::Batch::Batch
Batch(double mean=0, double sigma=1.00)
Definition: truncated_gaussian_initializer.h:110
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: truncated_gaussian_initializer.h:120
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: truncated_gaussian_initializer.h:129
daal::batch
Definition: daal_defines.h:110
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::Batch
Provides methods for truncated gaussian initializer computations in the batch processing mode...
Definition: truncated_gaussian_initializer.h:94
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::Batch::getParameter
virtual ParameterType * getParameter() DAAL_C11_OVERRIDE
Definition: truncated_gaussian_initializer.h:135
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::Parameter
truncated gaussian initializer parameters
Definition: truncated_gaussian_initializer_types.h:70
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::Batch::allocateResult
virtual services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: truncated_gaussian_initializer.h:175
daal::algorithms::covariance::mean
Definition: covariance_types.h:90
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:68
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: truncated_gaussian_initializer.h:165

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