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
57 explicit rnn_descr_t(size_t dim)
58 : m_dim(dim) { }
59};
60
62{
63 size_t m_arc_dim;
64 // size_t m_input_rnn_layer; // 0 - embd, 1 - 1st RNN layer, ...
65
66 explicit deep_biaffine_attention_descr_t(size_t arc_dim)
67 : m_arc_dim(arc_dim) { }
68};
69
70} // nets
71} // deeplima
72
73#endif // DEEPLIMA_LIBS_NN_COMMON_LAYER_DESCR_H
74
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