medcat.components.addons.meta_cat.models
Classes:
Attributes:
-
logger–
BertForMetaAnnotation
BertForMetaAnnotation(config: ConfigMetaCAT, save_dir_path: Optional[str] = None)
Bases: Module
Methods:
-
forward–Args:
Attributes:
Source code in medcat-v2/medcat/components/addons/meta_cat/models.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
bert
instance-attribute
bert = bert
bert_config
instance-attribute
bert_config = _bertconfig
config
instance-attribute
config = _bertconfig
dropout
instance-attribute
dropout = Dropout(dropout)
fc1
instance-attribute
fc1 = Linear(hidden_size * 2, hidden_size)
fc2
instance-attribute
fc2 = Linear(hidden_size, hidden_size_2)
fc3
instance-attribute
fc3 = Linear(hidden_size_2, hidden_size_2)
fc4
instance-attribute
fc4 = Linear(hidden_size_2, num_labels)
num_labels
instance-attribute
num_labels = nclasses
relu
instance-attribute
relu = ReLU()
softmax
instance-attribute
softmax = LogSoftmax(dim=1)
forward
forward(input_ids: Optional[LongTensor] = None, attention_mask: Optional[FloatTensor] = None, token_type_ids: Optional[LongTensor] = None, position_ids: Optional[LongTensor] = None, head_mask: Optional[FloatTensor] = None, inputs_embeds: Optional[FloatTensor] = None, labels: Optional[LongTensor] = None, center_positions: Iterable[Any] = [], ignore_cpos: Optional[bool] = None, output_attentions: Optional[bool] = None, output_hidden_states: Optional[bool] = None, return_dict: Optional[bool] = None)
Parameters:
-
(input_idsOptional[LongTensor], default:None) –The input IDs. Defaults to None.
-
(attention_maskOptional[FloatTensor], default:None) –The attention mask. Defaults to None.
-
(token_type_idsOptional[LongTensor], default:None) –Type IDs of the tokens. Defaults to None.
-
(position_idsOptional[LongTensor], default:None) –Position IDs. Defaults to None.
-
(head_maskOptional[FloatTensor], default:None) –Head mask. Defaults to None.
-
(inputs_embedsOptional[FloatTensor], default:None) –Input embeddings. Defaults to None.
-
(labelsOptional[LongTensor], default:None) –Labels for computing the token classification loss. Indices should be in
[0, ..., config.num_labels - 1]. Defaults to None. -
(center_positionsOptional[Any], default:[]) –Cennter positions. Defaults to None.
-
(output_attentionsOptional[bool], default:None) –Output attentions. Defaults to None.
-
(ignore_cposOptional[bool], default:None) –If center positions are to be ignored.
-
(output_hidden_statesOptional[bool], default:None) –Output hidden states. Defaults to None.
-
(return_dictOptional[bool], default:None) –Whether to return a dict. Defaults to None.
Returns:
-
TokenClassifierOutput–The token classifier output.
Source code in medcat-v2/medcat/components/addons/meta_cat/models.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | |
LSTM
LSTM(embeddings: Optional[Tensor], config: ConfigMetaCAT)
Bases: Module
Methods:
-
forward–
Attributes:
-
config– -
d1– -
embeddings– -
fc1– -
rnn–
Source code in medcat-v2/medcat/components/addons/meta_cat/models.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
config
instance-attribute
config = config
d1
instance-attribute
d1 = Dropout(dropout)
embeddings
instance-attribute
embeddings = Embedding(vocab_size, embedding_size, padding_idx=padding_idx)
fc1
instance-attribute
fc1 = Linear(hidden_size, nclasses)
rnn
instance-attribute
rnn = LSTM(input_size=input_size, hidden_size=hidden_size // num_directions, num_layers=num_layers, dropout=dropout, bidirectional=num_directions == 2)
forward
forward(input_ids: LongTensor, center_positions: Tensor, attention_mask: Optional[FloatTensor] = None, ignore_cpos: bool = False) -> Tensor
Source code in medcat-v2/medcat/components/addons/meta_cat/models.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |