C++ API Reference for Intel® Data Analytics Acceleration Library 2018 Update 2

gaussian_initializer.h
1 /* file: gaussian_initializer.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 Intel Corporation
4 * All Rights Reserved.
5 *
6 * If this software was obtained under the Intel Simplified Software License,
7 * the following terms apply:
8 *
9 * The source code, information and material ("Material") contained herein is
10 * owned by Intel Corporation or its suppliers or licensors, and title to such
11 * Material remains with Intel Corporation or its suppliers or licensors. The
12 * Material contains proprietary information of Intel or its suppliers and
13 * licensors. The Material is protected by worldwide copyright laws and treaty
14 * provisions. No part of the Material may be used, copied, reproduced,
15 * modified, published, uploaded, posted, transmitted, distributed or disclosed
16 * in any way without Intel's prior express written permission. No license under
17 * any patent, copyright or other intellectual property rights in the Material
18 * is granted to or conferred upon you, either expressly, by implication,
19 * inducement, estoppel or otherwise. Any license under such intellectual
20 * property rights must be express and approved by Intel in writing.
21 *
22 * Unless otherwise agreed by Intel in writing, you may not remove or alter this
23 * notice or any other notice embedded in Materials by Intel or Intel's
24 * suppliers or licensors in any way.
25 *
26 *
27 * If this software was obtained under the Apache License, Version 2.0 (the
28 * "License"), the following terms apply:
29 *
30 * You may not use this file except in compliance with the License. You may
31 * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
32 *
33 *
34 * Unless required by applicable law or agreed to in writing, software
35 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
36 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37 *
38 * See the License for the specific language governing permissions and
39 * limitations under the License.
40 *******************************************************************************/
41 
42 /*
43 //++
44 // Implementation of the gaussian initializer in the batch processing mode
45 //--
46 */
47 
48 #ifndef __GAUSSIAN_INITIALIZER_H__
49 #define __GAUSSIAN_INITIALIZER_H__
50 
51 #include "algorithms/algorithm.h"
52 #include "data_management/data/tensor.h"
53 #include "services/daal_defines.h"
54 #include "algorithms/neural_networks/initializers/initializer.h"
55 #include "algorithms/neural_networks/initializers/initializer_types.h"
56 #include "algorithms/neural_networks/initializers/gaussian/gaussian_initializer_types.h"
57 
58 namespace daal
59 {
60 namespace algorithms
61 {
62 namespace neural_networks
63 {
64 namespace initializers
65 {
66 namespace gaussian
67 {
73 namespace interface1
74 {
85 template<typename algorithmFPType, Method method, CpuType cpu>
86 class DAAL_EXPORT BatchContainer : public initializers::InitializerContainerIface
87 {
88 public:
94  BatchContainer(daal::services::Environment::env *daalEnv);
96  ~BatchContainer();
102  services::Status compute() DAAL_C11_OVERRIDE;
103 };
104 
119 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
120 class DAAL_EXPORT Batch : public initializers::InitializerIface
121 {
122 public:
123  typedef initializers::InitializerIface super;
124 
125  typedef typename super::InputType InputType;
126  typedef algorithms::neural_networks::initializers::gaussian::Parameter ParameterType;
127  typedef typename super::ResultType ResultType;
128 
129  ParameterType parameter;
136  Batch(double a = 0, double sigma = 0.01) : parameter(a, sigma)
137  {
138  initialize();
139  }
140 
146  Batch(const Batch<algorithmFPType, method> &other) : super(other), parameter(other.parameter)
147  {
148  initialize();
149  }
150 
155  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
156 
161  virtual ParameterType * getParameter() DAAL_C11_OVERRIDE { return &parameter; }
162 
167  ResultPtr getResult()
168  {
169  return _result;
170  }
171 
178  services::Status setResult(const ResultPtr &result)
179  {
180  DAAL_CHECK(result, services::ErrorNullResult)
181  _result = result;
182  _res = _result.get();
183  return services::Status();
184  }
185 
191  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
192  {
193  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
194  }
195 
201  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
202  {
203  _par = &parameter;
204  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), &parameter, (int) method);
205  this->_res = this->_result.get();
206  return s;
207  }
208 
209 protected:
210  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
211  {
212  return new Batch<algorithmFPType, method>(*this);
213  }
214 
215  void initialize()
216  {
217  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
218  _in = &input;
219  _par = &parameter;
220  _result.reset(new ResultType());
221  }
222 
223 private:
224  ResultPtr _result;
225 };
226 
227 } // namespace interface1
228 using interface1::BatchContainer;
229 using interface1::Batch;
231 } // namespace gaussian
232 } // namespace initializers
233 } // namespace neural_networks
234 } // namespace algorithms
235 } // namespace daal
236 #endif
daal::services::interface1::Environment::_envStruct
The environment structure.
Definition: env_detect.h:95
daal::services::interface1::Status
Class that holds the results of API calls. In case of API routine failure it contains the list of err...
Definition: error_handling.h:491
daal
Definition: algorithm_base_common.h:57
daal::algorithms::neural_networks::initializers::interface1::InitializerContainerIface
Class that specifies interfaces of implementations of the neural network weights and biases initializ...
Definition: initializer.h:74
daal::algorithms::neural_networks::initializers::gaussian::interface1::Batch::parameter
ParameterType parameter
Definition: gaussian_initializer.h:129
daal::algorithms::neural_networks::initializers::interface1::Input
Input objects for initializer algorithm
Definition: initializer_types.h:121
daal::algorithms::neural_networks::initializers::gaussian::interface1::BatchContainer
Provides methods to run implementations of the gaussian initializer. This class is associated with th...
Definition: gaussian_initializer.h:86
daal::algorithms::neural_networks::initializers::gaussian::interface1::Batch::Batch
Batch(double a=0, double sigma=0.01)
Definition: gaussian_initializer.h:136
daal_defines.h
daal::batch
Definition: daal_defines.h:132
daal::algorithms::neural_networks::initializers::gaussian::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: gaussian_initializer.h:191
daal::services::interface1::SharedPtr
Shared pointer that retains shared ownership of an object through a pointer. Several SharedPtr object...
Definition: daal_shared_ptr.h:187
daal::algorithms::neural_networks::initializers::gaussian::interface1::Batch::getParameter
virtual ParameterType * getParameter() DAAL_C11_OVERRIDE
Definition: gaussian_initializer.h:161
daal::algorithms::neural_networks::initializers::gaussian::interface1::Batch
Provides methods for gaussian initializer computations in the batch processing mode.
Definition: gaussian_initializer.h:120
daal::algorithms::neural_networks::initializers::gaussian::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: gaussian_initializer.h:146
daal::algorithms::neural_networks::initializers::interface1::Result
Provides methods to access the result obtained with the compute() method of the neural network weight...
Definition: initializer_types.h:167
daal::algorithms::neural_networks::initializers::gaussian::interface1::Parameter
gaussian initializer parameters
Definition: gaussian_initializer_types.h:95
daal::algorithms::neural_networks::initializers::interface1::InitializerIface
Class representing a neural network weights and biases initializer.
Definition: initializer.h:85
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:94
daal::algorithms::neural_networks::initializers::gaussian::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: gaussian_initializer.h:178
daal::services::ErrorNullResult
Definition: error_indexes.h:122
daal::algorithms::neural_networks::initializers::gaussian::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: gaussian_initializer.h:155
daal::algorithms::neural_networks::initializers::gaussian::interface1::Batch::allocateResult
virtual services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: gaussian_initializer.h:201

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