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

neural_networks_training_topology.h
1 /* file: neural_networks_training_topology.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 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_TRAINING_TOPOLOGY_H__
17 #define __NEURAL_NETWORKS_TRAINING_TOPOLOGY_H__
18 
19 #include "algorithms/neural_networks/layers/layer_descriptor.h"
20 
21 namespace daal
22 {
23 namespace algorithms
24 {
25 namespace neural_networks
26 {
27 namespace training
28 {
29 namespace interface1
30 {
40 class Topology: public Base
41 {
42 public:
44  Topology() {}
45 
50  Topology(const Topology &t) : _config(t.size())
51  {
52  for(size_t i = 0; i < t.size(); i++)
53  {
54  _config[i] = layers::LayerDescriptor(i, t[i].layer(), t[i].nextLayers());
55  }
56  }
57 
62  size_t size() const { return _config.size(); }
63 
69  size_t push_back(const layers::LayerIfacePtr &layer)
70  {
71  size_t id = _config.size();
72  _config.push_back(layers::LayerDescriptor(id, layer));
73  return id;
74  }
75 
81  size_t add(const layers::LayerIfacePtr &layer)
82  {
83  return push_back(layer);
84  }
85 
92  size_t add(const Topology &topologyBlock, size_t &startIndex)
93  {
94  size_t size = _config.size();
95  startIndex = size;
96 
97  size_t id = 0;
98  for(size_t i = 0; i < topologyBlock.size(); i++)
99  {
100  id = push_back(topologyBlock[i].layer());
101 
102  const layers::NextLayers& nextLayers = topologyBlock[i].nextLayers();
103  for(size_t j = 0; j < nextLayers.size(); j++)
104  {
105  get(i + size).addNext(nextLayers[j] + size);
106  }
107  }
108  return id;
109  }
110 
116  services::Status clear()
117  {
118  _config.clear();
119  return services::Status();
120  }
121 
127  layers::LayerDescriptor& operator [] (size_t index) { return _config[index]; }
128 
134  const layers::LayerDescriptor& operator [] (size_t index) const { return _config[index]; }
135 
141  layers::LayerDescriptor& get(size_t index) { return _config[index]; }
142 
148  const layers::LayerDescriptor& get(size_t index) const { return _config[index]; }
149 
158  DAAL_DEPRECATED services::Status addNext(size_t index, size_t next)
159  {
160  _config[index].addNext(next);
161  return services::Status();
162  }
163 
164 protected:
165  services::Collection<layers::LayerDescriptor> _config;
166 };
167 
168 typedef services::SharedPtr<Topology> TopologyPtr;
170 }
171 using interface1::Topology;
172 using interface1::TopologyPtr;
173 }
174 }
175 }
176 }
177 
178 #endif
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:40
daal::algorithms::neural_networks::training::interface1::Topology::push_back
size_t push_back(const layers::LayerIfacePtr &layer)
Definition: neural_networks_training_topology.h:69
daal
Definition: algorithm_base_common.h:31
daal::algorithms::neural_networks::training::interface1::Topology::add
size_t add(const Topology &topologyBlock, size_t &startIndex)
Definition: neural_networks_training_topology.h:92
daal::algorithms::neural_networks::training::interface1::Topology::Topology
Topology()
Definition: neural_networks_training_topology.h:44
daal::algorithms::neural_networks::training::interface1::Topology::clear
services::Status clear()
Definition: neural_networks_training_topology.h:116
daal::algorithms::neural_networks::training::interface1::Topology::Topology
Topology(const Topology &t)
Definition: neural_networks_training_topology.h:50
daal::algorithms::neural_networks::training::interface1::Topology::operator[]
layers::LayerDescriptor & operator[](size_t index)
Definition: neural_networks_training_topology.h:127
daal::Base
Base class for Intel(R) Data Analytics Acceleration Library objects
Definition: base.h:39
daal::algorithms::neural_networks::training::interface1::Topology::size
size_t size() const
Definition: neural_networks_training_topology.h:62
daal::algorithms::neural_networks::training::interface1::Topology::add
size_t add(const layers::LayerIfacePtr &layer)
Definition: neural_networks_training_topology.h:81
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:158

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