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

neural_networks_prediction_topology.h
1 /* file: neural_networks_prediction_topology.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 #ifndef __NEURAL_NETWORKS_PREDICTION_TOPOLOGY_H__
17 #define __NEURAL_NETWORKS_PREDICTION_TOPOLOGY_H__
18 
19 #include "algorithms/neural_networks/layers/layer_forward_descriptor.h"
20 #include "algorithms/neural_networks/neural_networks_training_topology.h"
21 
22 namespace daal
23 {
24 namespace algorithms
25 {
26 namespace neural_networks
27 {
28 namespace prediction
29 {
30 namespace interface1
31 {
32 
42 class Topology: public Base
43 {
44 protected:
45  typedef services::Collection<layers::forward::LayerDescriptor> Descriptors;
46 
47 public:
49  Topology() {}
50 
55  Topology(const training::Topology &t) : _config(t.size())
56  {
57  for(size_t i = 0; i < _config.size(); ++i)
58  {
59  const layers::LayerDescriptor& desc = t[i];
60  layers::forward::LayerIfacePtr predictionLayer = desc.layer()->forwardLayer->getLayerForPrediction();
61  _config[i] = layers::forward::LayerDescriptor(i, predictionLayer, desc.nextLayers());
62  predictionLayer->getLayerParameter()->predictionStage = true;
63  }
64  }
65 
70  Topology(const Topology &t) : _config(t.size())
71  {
72  for(size_t i = 0; i < t.size(); i++)
73  {
74  _config[i] = layers::forward::LayerDescriptor(i, t[i].layer(), t[i].nextLayers());
75  }
76  }
77 
82  size_t size() const { return _config.size(); }
83 
89  size_t push_back(const layers::forward::LayerIfacePtr &layer)
90  {
91  size_t id = _config.size();
92  _config.push_back(layers::forward::LayerDescriptor(id, layer));
93  return id;
94  }
95 
101  size_t add(const layers::forward::LayerIfacePtr &layer)
102  {
103  return push_back(layer);
104  }
105 
112  size_t add(const Topology &topologyBlock, size_t &startIndex)
113  {
114  size_t size = _config.size();
115  startIndex = size;
116 
117  size_t id = 0;
118  for(size_t i = 0; i < topologyBlock.size(); i++)
119  {
120  id = push_back(topologyBlock[i].layer());
121  const layers::NextLayers& nextLayers = topologyBlock[i].nextLayers();
122  for(size_t j = 0; j < nextLayers.size(); j++)
123  {
124  addNext(i + size, nextLayers[j] + size);
125  }
126  }
127  return id;
128  }
129 
135  services::Status clear()
136  {
137  _config.clear();
138  return services::Status();
139  }
140 
146  layers::forward::LayerDescriptor& operator [] (size_t index) { return _config[index]; }
147 
153  const layers::forward::LayerDescriptor& operator [] (size_t index) const { return _config[index]; }
154 
160  layers::forward::LayerDescriptor& get(size_t index) { return _config[index]; }
161 
167  const layers::forward::LayerDescriptor& get(size_t index) const { return _config[index]; }
168 
169 
178  services::Status addNext(size_t index, size_t next)
179  {
180  _config[index].addNext(next);
181  return services::Status();
182  }
183 
184 protected:
185  Descriptors _config;
186 };
187 
188 typedef services::SharedPtr<Topology> TopologyPtr;
190 }
191 
192 using interface1::Topology;
193 using interface1::TopologyPtr;
194 }
195 }
196 }
197 }
198 
199 #endif
daal::algorithms::neural_networks::prediction::interface1::Topology::Topology
Topology(const training::Topology &t)
Definition: neural_networks_prediction_topology.h:55
daal
Definition: algorithm_base_common.h:31
daal::algorithms::neural_networks::prediction::interface1::Topology
Class defining a neural network topology - a set of layers and connection between them - on the predi...
Definition: neural_networks_prediction_topology.h:42
daal::algorithms::neural_networks::prediction::interface1::Topology::clear
services::Status clear()
Definition: neural_networks_prediction_topology.h:135
daal::algorithms::neural_networks::prediction::interface1::Topology::size
size_t size() const
Definition: neural_networks_prediction_topology.h:82
daal::algorithms::neural_networks::prediction::interface1::Topology::Topology
Topology(const Topology &t)
Definition: neural_networks_prediction_topology.h:70
daal::algorithms::neural_networks::prediction::interface1::Topology::push_back
size_t push_back(const layers::forward::LayerIfacePtr &layer)
Definition: neural_networks_prediction_topology.h:89
daal::algorithms::neural_networks::prediction::interface1::Topology::operator[]
layers::forward::LayerDescriptor & operator[](size_t index)
Definition: neural_networks_prediction_topology.h:146
daal::algorithms::neural_networks::prediction::interface1::Topology::Topology
Topology()
Definition: neural_networks_prediction_topology.h:49
daal::algorithms::neural_networks::prediction::interface1::Topology::addNext
services::Status addNext(size_t index, size_t next)
Definition: neural_networks_prediction_topology.h:178
daal::algorithms::classifier::prediction::prediction
Definition: classifier_predict_types.h:76
daal::algorithms::neural_networks::prediction::interface1::Topology::add
size_t add(const Topology &topologyBlock, size_t &startIndex)
Definition: neural_networks_prediction_topology.h:112
daal::algorithms::neural_networks::prediction::interface1::Topology::add
size_t add(const layers::forward::LayerIfacePtr &layer)
Definition: neural_networks_prediction_topology.h:101
daal::Base
Base class for Intel(R) Data Analytics Acceleration Library objects
Definition: base.h:39

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