LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
layer_descr.h
Go to the documentation of this file.
1// Copyright 2002-2021 CEA LIST
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
6#ifndef DEEPLIMA_LIBS_NN_COMMON_LAYER_DESCR_H
7#define DEEPLIMA_LIBS_NN_COMMON_LAYER_DESCR_H
8
9#include <sstream>
10
11namespace deeplima
12{
13namespace nets
14{
15
17{
18 std::string m_name;
19 size_t m_dim;
20 unsigned char m_type; // 0 - raw, 1 - embd
21
22 embd_descr_t(const std::string& name, size_t dim, unsigned char type=1)
23 : m_name(name), m_dim(dim), m_type(type) { }
24
25 explicit embd_descr_t(const std::string& str)
26 {
27 from_string(str);
28 }
29
30 std::string to_string() const
31 {
32 std::ostringstream s;
33 s << m_name << " " << (int)m_dim << " " << (int)m_type;
34 return s.str();
35 }
36
37 void from_string(const std::string& str)
38 {
39 std::istringstream s(str);
40 s >> m_name;
41 s >> m_dim;
42 int t = 0;
43 s >> t;
44 m_type = t;
45 }
46
47 bool operator==(const embd_descr_t& other)
48 {
49 return (other.m_name == m_name) && (other.m_dim == m_dim) && (other.m_type == m_type);
50 }
51};
52
54{
55 size_t m_dim;
56 float m_dropout; // on the output of the layer, before the next one (not after the last)
57
58 explicit rnn_descr_t(size_t dim, float dropout = 0)
59 : m_dim(dim), m_dropout(dropout) { }
60};
61
63{
64 size_t m_arc_dim;
65 size_t m_rel_dim; // hidden dim of the label decoder
66 float m_dropout; // on the encoder output, before both decoders
67 // size_t m_input_rnn_layer; // 0 - embd, 1 - 1st RNN layer, ...
68
69 explicit deep_biaffine_attention_descr_t(size_t arc_dim, size_t rel_dim = 0, float dropout = 0)
70 : m_arc_dim(arc_dim), m_rel_dim(rel_dim > 0 ? rel_dim : arc_dim), m_dropout(dropout) { }
71};
72
73} // nets
74} // deeplima
75
76#endif // DEEPLIMA_LIBS_NN_COMMON_LAYER_DESCR_H
77
Edit rules for lemmatizing words absent from the lemma dictionary.
deep_biaffine_attention_descr_t(size_t arc_dim, size_t rel_dim=0, float dropout=0)
Definition layer_descr.h:69
embd_descr_t(const std::string &name, size_t dim, unsigned char type=1)
Definition layer_descr.h:22
embd_descr_t(const std::string &str)
Definition layer_descr.h:25
bool operator==(const embd_descr_t &other)
Definition layer_descr.h:47
void from_string(const std::string &str)
Definition layer_descr.h:37
std::string to_string() const
Definition layer_descr.h:30
rnn_descr_t(size_t dim, float dropout=0)
Definition layer_descr.h:58