OpenNN
Open-source neural networks library
Loading...
Searching...
No Matches
standard_networks.h
Go to the documentation of this file.
1// OpenNN: Open Neural Networks Library
2// www.opennn.net
3//
4// S T A N D A R D N E T W O R K S C L A S S H E A D E R
5//
6// Artificial Intelligence Techniques SL
7// artelnics@artelnics.com
8
22
23#pragma once
24
25#include "neural_network.h"
26
27namespace opennn
28{
29
38{
39
40public:
41
48 ApproximationNetwork(const Shape& input_shape,
49 const Shape& complexity_dimensions,
50 const Shape& output_shape);
51};
52
62{
63
64public:
65
72 ClassificationNetwork(const Shape& input_shape,
73 const Shape& complexity_dimensions,
74 const Shape& output_shape);
75};
76
85{
86
87public:
88
95 ForecastingNetwork(const Shape& input_shape,
96 const Shape& complexity_dimensions,
97 const Shape& output_shape);
98};
99
109{
110
111public:
112
119 AutoAssociationNetwork(const Shape& input_shape,
120 const Shape& complexity_dimensions,
121 const Shape& output_shape);
122};
123
132{
133
134public:
135
143 const Shape& complexity_dimensions,
144 const Shape& output_shape);
145};
146
156{
157
158public:
159
167 SimpleResNet(const Shape& input_shape,
168 const vector<Index>& blocks_per_stage,
169 const Shape& initial_filters,
170 const Shape& output_shape);
171};
172
177class VGG16 final : public NeuralNetwork
178{
179public:
180
186 VGG16(const Shape& input_shape, const Shape& target_shape);
187
192 VGG16(const filesystem::path& path);
193
199 void set(const Shape& input_shape, const Shape& target_shape);
200
201};
202
212{
213
214public:
215
223 const Shape& complexity_dimensions,
224 const Shape& output_shape);
225
226private:
227
229 vector<string> input_vocabulary;
231 vector<string> output_vocabulary;
232};
233
239class Transformer final : public NeuralNetwork
240{
241public:
242
254 Transformer(const Index input_sequence_length = 0,
255 Index decoder_sequence_length = 0,
256 Index input_vocabulary_size = 0,
257 Index output_vocabulary_size = 0,
258 Index embedding_dimension = 0,
259 Index heads_number = 0,
260 Index feedforward_dimension = 0,
261 Index layers_number = 0);
262
268 void set(const Index input_sequence_length = 0,
269 Index decoder_sequence_length = 0,
270 Index input_vocabulary_size = 0,
271 Index output_vocabulary_size = 0,
272 Index embedding_dimension = 0,
273 Index heads_number = 0,
274 Index feedforward_dimension = 0,
275 Index layers_number = 0);
276
284 Index get_heads_number() const;
285
291 void set_dropout_rate(const float);
297 void set_input_vocabulary(const vector<string>&);
303 void set_output_vocabulary(const vector<string>&);
304
310 string calculate_outputs(const string& input);
311
312private:
313
315 vector<string> input_vocabulary;
317 vector<string> output_vocabulary;
318
320 unordered_map<string, Index> input_vocabulary_map;
322 unordered_map<Index, string> output_inverse_vocabulary_map;
323};
324
325}
326
327// OpenNN: Open Neural Networks Library.
328// Copyright(C) 2005-2026 Artificial Intelligence Techniques, SL.
329// Licensed under the GNU Lesser General Public License v2.1 or later.
ApproximationNetwork(const Shape &input_shape, const Shape &complexity_dimensions, const Shape &output_shape)
Constructs the network.
AutoAssociationNetwork(const Shape &input_shape, const Shape &complexity_dimensions, const Shape &output_shape)
Constructs the network.
ClassificationNetwork(const Shape &input_shape, const Shape &complexity_dimensions, const Shape &output_shape)
Constructs the network.
ForecastingNetwork(const Shape &input_shape, const Shape &complexity_dimensions, const Shape &output_shape)
Constructs the network.
ImageClassificationNetwork(const Shape &input_shape, const Shape &complexity_dimensions, const Shape &output_shape)
Constructs the network.
NeuralNetwork()
Default-constructs an empty network.
SimpleResNet(const Shape &input_shape, const vector< Index > &blocks_per_stage, const Shape &initial_filters, const Shape &output_shape)
Constructs the network.
TextClassificationNetwork(const Shape &input_shape, const Shape &complexity_dimensions, const Shape &output_shape)
Constructs the network.
string calculate_outputs(const string &input)
Greedy decoding given a raw input string.
Transformer(const Index input_sequence_length=0, Index decoder_sequence_length=0, Index input_vocabulary_size=0, Index output_vocabulary_size=0, Index embedding_dimension=0, Index heads_number=0, Index feedforward_dimension=0, Index layers_number=0)
Constructs an untrained Transformer.
void set(const Index input_sequence_length=0, Index decoder_sequence_length=0, Index input_vocabulary_size=0, Index output_vocabulary_size=0, Index embedding_dimension=0, Index heads_number=0, Index feedforward_dimension=0, Index layers_number=0)
Re-initializes the Transformer with new dimensions.
Index get_heads_number() const
Number of attention heads per layer.
Index get_decoder_sequence_length() const
Length of the decoder input sequence.
void set_output_vocabulary(const vector< string > &)
Replaces the output-side vocabulary.
void set_dropout_rate(const float)
Sets the dropout rate applied to the residual streams.
void set_input_vocabulary(const vector< string > &)
Replaces the input-side vocabulary.
Index get_embedding_dimension() const
Embedding (model) dimension.
Index get_input_sequence_length() const
Length of the encoder input sequence.
VGG16(const Shape &input_shape, const Shape &target_shape)
Constructs an untrained VGG-16.
void set(const Shape &input_shape, const Shape &target_shape)
Re-initializes the network with new shapes.
VGG16(const filesystem::path &path)
Constructs a VGG-16 with parameters loaded from a saved model.
Definition adaptive_moment_estimation.h:19
Declares the NeuralNetwork class.
Definition tensor_utilities.h:46