:py:mod:`medcat.utils.meta_cat.models` ====================================== .. py:module:: medcat.utils.meta_cat.models Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: medcat.utils.meta_cat.models.LSTM medcat.utils.meta_cat.models.BertForMetaAnnotation Attributes ~~~~~~~~~~ .. autoapisummary:: medcat.utils.meta_cat.models.logger .. py:data:: logger .. py:class:: LSTM(embeddings, config) Bases: :py:obj:`torch.nn.Module` Base class for all neural network modules. Your models should also subclass this class. Modules can also contain other Modules, allowing to nest them in a tree structure. You can assign the submodules as regular attributes:: import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self): super().__init__() self.conv1 = nn.Conv2d(1, 20, 5) self.conv2 = nn.Conv2d(20, 20, 5) def forward(self, x): x = F.relu(self.conv1(x)) return F.relu(self.conv2(x)) Submodules assigned in this way will be registered, and will have their parameters converted too when you call :meth:`to`, etc. .. note:: As per the example above, an ``__init__()`` call to the parent class must be made before assignment on the child. :ivar training: Boolean represents whether this module is in training or evaluation mode. :vartype training: bool .. py:method:: __init__(embeddings, config) Initialize internal Module state, shared by both nn.Module and ScriptModule. .. py:method:: forward(input_ids, center_positions, attention_mask = None, ignore_cpos = False) .. py:class:: BertForMetaAnnotation(config) Bases: :py:obj:`torch.nn.Module` Base class for all neural network modules. Your models should also subclass this class. Modules can also contain other Modules, allowing to nest them in a tree structure. You can assign the submodules as regular attributes:: import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self): super().__init__() self.conv1 = nn.Conv2d(1, 20, 5) self.conv2 = nn.Conv2d(20, 20, 5) def forward(self, x): x = F.relu(self.conv1(x)) return F.relu(self.conv2(x)) Submodules assigned in this way will be registered, and will have their parameters converted too when you call :meth:`to`, etc. .. note:: As per the example above, an ``__init__()`` call to the parent class must be made before assignment on the child. :ivar training: Boolean represents whether this module is in training or evaluation mode. :vartype training: bool .. py:attribute:: _keys_to_ignore_on_load_unexpected :type: List[str] :value: ['pooler'] .. py:method:: __init__(config) Initialize internal Module state, shared by both nn.Module and ScriptModule. .. py:method:: forward(input_ids = None, attention_mask = None, token_type_ids = None, position_ids = None, head_mask = None, inputs_embeds = None, labels = None, center_positions = [], ignore_cpos = None, output_attentions = None, output_hidden_states = None, return_dict = None) labels (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`, `optional`): Labels for computing the token classification loss. Indices should be in ``[0, ..., config.num_labels - 1]``. :param input_ids: The input IDs. Defaults to None. :type input_ids: Optional[torch.LongTensor] :param attention_mask: The attention mask. Defaults to None. :type attention_mask: Optional[torch.FloatTensor] :param token_type_ids: Type IDs of the tokens. Defaults to None. :type token_type_ids: Optional[torch.LongTensor] :param position_ids: Position IDs. Defaults to None. :type position_ids: Optional[torch.LongTensor] :param head_mask: Head mask. Defaults to None. :type head_mask: Optional[torch.FloatTensor] :param inputs_embeds: Input embeddings. Defaults to None. :type inputs_embeds: Optional[torch.FloatTensor] :param labels: Labels. Defaults to None. :type labels: Optional[torch.LongTensor] :param center_positions: Cennter positions. Defaults to None. :type center_positions: Optional[Any] :param output_attentions: Output attentions. Defaults to None. :type output_attentions: Optional[bool] :param ignore_cpos: If center positions are to be ignored. :param output_hidden_states: Output hidden states. Defaults to None. :type output_hidden_states: Optional[bool] :param return_dict: Whether to return a dict. Defaults to None. :type return_dict: Optional[bool] :Returns: **TokenClassifierOutput** -- The token classifier output.