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

truncated_gaussian_initializer.h
1 /* file: truncated_gaussian_initializer.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 truncated gaussian initializer in the batch processing mode
21 //--
22 */
23 
24 #ifndef __TRUNCATED_GAUSSIAN_INITIALIZER_H__
25 #define __TRUNCATED_GAUSSIAN_INITIALIZER_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "data_management/data/tensor.h"
29 #include "services/daal_defines.h"
30 #include "algorithms/neural_networks/initializers/initializer.h"
31 #include "algorithms/neural_networks/initializers/initializer_types.h"
32 #include "algorithms/neural_networks/initializers/truncated_gaussian/truncated_gaussian_initializer_types.h"
33 
34 namespace daal
35 {
36 namespace algorithms
37 {
38 namespace neural_networks
39 {
40 namespace initializers
41 {
42 namespace truncated_gaussian
43 {
49 namespace interface1
50 {
61 template<typename algorithmFPType, Method method, CpuType cpu>
62 class BatchContainer : public initializers::InitializerContainerIface
63 {
64 public:
70  BatchContainer(daal::services::Environment::env *daalEnv);
72  ~BatchContainer();
78  services::Status compute() DAAL_C11_OVERRIDE;
79 };
80 
95 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
96 class DAAL_EXPORT Batch : public initializers::InitializerIface
97 {
98 public:
99  typedef initializers::InitializerIface super;
100 
101  typedef typename super::InputType InputType;
102  typedef algorithms::neural_networks::initializers::truncated_gaussian::Parameter<algorithmFPType> ParameterType;
103  typedef typename super::ResultType ResultType;
104 
105  Parameter<algorithmFPType> parameter;
112  Batch(double mean = 0, double sigma = 1.00) : parameter(mean, sigma)
113  {
114  initialize();
115  }
116 
122  Batch(const Batch<algorithmFPType, method> &other) : super(other), parameter(other.parameter)
123  {
124  initialize();
125  }
126 
131  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
132 
137  virtual ParameterType * getParameter() DAAL_C11_OVERRIDE { return &parameter; }
138 
143  ResultPtr getResult()
144  {
145  return _result;
146  }
147 
154  services::Status setResult(const ResultPtr &result)
155  {
156  DAAL_CHECK(result, services::ErrorNullResult)
157  _result = result;
158  _res = _result.get();
159  return services::Status();
160  }
161 
167  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
168  {
169  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
170  }
171 
177  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
178  {
179  _par = &parameter;
180  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), &parameter, (int) method);
181  this->_res = this->_result.get();
182  return s;
183  }
184 
185 protected:
186  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
187  {
188  return new Batch<algorithmFPType, method>(*this);
189  }
190 
191  void initialize()
192  {
193  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
194  _in = &input;
195  _par = &parameter;
196  _result.reset(new ResultType());
197  }
198 
199 private:
200  ResultPtr _result;
201 };
202 
203 } // namespace interface1
204 using interface1::BatchContainer;
205 using interface1::Batch;
207 } // namespace truncated_gaussian
208 } // namespace initializers
209 } // namespace neural_networks
210 } // namespace algorithms
211 } // namespace daal
212 #endif
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: truncated_gaussian_initializer.h:122
daal::batch
Definition: daal_defines.h:112
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: truncated_gaussian_initializer.h:167
daal::algorithms::covariance::mean
Definition: covariance_types.h:92
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::Batch::getParameter
virtual ParameterType * getParameter() DAAL_C11_OVERRIDE
Definition: truncated_gaussian_initializer.h:137
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::Batch::Batch
Batch(double mean=0, double sigma=1.00)
Definition: truncated_gaussian_initializer.h:112
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: truncated_gaussian_initializer.h:131
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:62
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: truncated_gaussian_initializer.h:154
daal_defines.h
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::Parameter
truncated gaussian initializer parameters
Definition: truncated_gaussian_initializer_types.h:72
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::Batch::parameter
Parameter< algorithmFPType > parameter
Definition: truncated_gaussian_initializer.h:105
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::Batch::getResult
ResultPtr getResult()
Definition: truncated_gaussian_initializer.h:143
daal::algorithms::neural_networks::initializers::truncated_gaussian::interface1::Batch::allocateResult
virtual services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: truncated_gaussian_initializer.h:177
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:70
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:96

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