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

neural_networks_training_topology.h
1 /* file: neural_networks_training_topology.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 #ifndef __NEURAL_NETWORKS_TRAINING_TOPOLOGY_H__
43 #define __NEURAL_NETWORKS_TRAINING_TOPOLOGY_H__
44 
45 #include "algorithms/neural_networks/layers/layer_descriptor.h"
46 
47 namespace daal
48 {
49 namespace algorithms
50 {
51 namespace neural_networks
52 {
53 namespace training
54 {
55 namespace interface1
56 {
66 class Topology: public Base
67 {
68 public:
70  Topology() {}
71 
76  Topology(const Topology &t) : _config(t.size())
77  {
78  for(size_t i = 0; i < t.size(); i++)
79  {
80  _config[i] = layers::LayerDescriptor(i, t[i].layer(), t[i].nextLayers());
81  }
82  }
83 
88  size_t size() const { return _config.size(); }
89 
95  size_t push_back(const layers::LayerIfacePtr &layer)
96  {
97  size_t id = _config.size();
98  _config.push_back(layers::LayerDescriptor(id, layer));
99  return id;
100  }
101 
107  size_t add(const layers::LayerIfacePtr &layer)
108  {
109  return push_back(layer);
110  }
111 
118  size_t add(const Topology &topologyBlock, size_t &startIndex)
119  {
120  size_t size = _config.size();
121  startIndex = size;
122 
123  size_t id = 0;
124  for(size_t i = 0; i < topologyBlock.size(); i++)
125  {
126  id = push_back(topologyBlock[i].layer());
127 
128  const layers::NextLayers& nextLayers = topologyBlock[i].nextLayers();
129  for(size_t j = 0; j < nextLayers.size(); j++)
130  {
131  get(i + size).addNext(nextLayers[j] + size);
132  }
133  }
134  return id;
135  }
136 
142  services::Status clear()
143  {
144  _config.clear();
145  return services::Status();
146  }
147 
153  layers::LayerDescriptor& operator [] (size_t index) { return _config[index]; }
154 
160  const layers::LayerDescriptor& operator [] (size_t index) const { return _config[index]; }
161 
167  layers::LayerDescriptor& get(size_t index) { return _config[index]; }
168 
174  const layers::LayerDescriptor& get(size_t index) const { return _config[index]; }
175 
184  DAAL_DEPRECATED services::Status addNext(size_t index, size_t next)
185  {
186  _config[index].addNext(next);
187  return services::Status();
188  }
189 
190 protected:
191  services::Collection<layers::LayerDescriptor> _config;
192 };
193 
194 typedef services::SharedPtr<Topology> TopologyPtr;
196 }
197 using interface1::Topology;
198 using interface1::TopologyPtr;
199 }
200 }
201 }
202 }
203 
204 #endif
daal::algorithms::neural_networks::layers::interface1::LayerDescriptor
Class defining descriptor for layer on both forward and backward stages and its parameters.
Definition: layer_descriptor.h:71
daal::algorithms::neural_networks::training::interface1::Topology
Class defining a neural network topology - a set of layers and connection between them - on the train...
Definition: neural_networks_training_topology.h:66
daal::algorithms::neural_networks::training::interface1::Topology::push_back
size_t push_back(const layers::LayerIfacePtr &layer)
Definition: neural_networks_training_topology.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::training::interface1::Topology::add
size_t add(const Topology &topologyBlock, size_t &startIndex)
Definition: neural_networks_training_topology.h:118
daal::algorithms::neural_networks::layers::interface1::NextLayers
Contains list of layer indices of layers following the current layer.
Definition: layer_types.h:140
daal::algorithms::neural_networks::training::interface1::Topology::Topology
Topology()
Definition: neural_networks_training_topology.h:70
daal::algorithms::neural_networks::training::interface1::Topology::size
size_t size() const
Definition: neural_networks_training_topology.h:88
daal::algorithms::neural_networks::training::interface1::Topology::clear
services::Status clear()
Definition: neural_networks_training_topology.h:142
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::training::interface1::Topology::Topology
Topology(const Topology &t)
Definition: neural_networks_training_topology.h:76
daal::algorithms::neural_networks::training::interface1::Topology::operator[]
layers::LayerDescriptor & operator[](size_t index)
Definition: neural_networks_training_topology.h:153
daal::Base
Base class for Intel(R) Data Analytics Acceleration Library objects
Definition: base.h:65
daal::algorithms::neural_networks::layers::interface1::NextLayers::size
size_t size() const
Definition: layer_types.h:250
daal::algorithms::neural_networks::training::interface1::Topology::add
size_t add(const layers::LayerIfacePtr &layer)
Definition: neural_networks_training_topology.h:107
daal::algorithms::neural_networks::training::interface1::Topology::addNext
DAAL_DEPRECATED services::Status addNext(size_t index, size_t next)
Definition: neural_networks_training_topology.h:184
daal::services::interface1::Collection
Class that implements functionality of the Collection container.
Definition: collection.h:69

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