modeling

Modeling classes for LayoutLMv2 model.

class LayoutLMv2Model(with_pool='tanh', **kwargs)[源代码]

基类:paddlenlp.transformers.layoutlmv2.modeling.LayoutLMv2PretrainedModel

The bare LayoutLMv2 Model outputting raw hidden-states.

This model inherits from PretrainedModel. Refer to the superclass documentation for the generic methods.

This model is also a Paddle paddle.nn.Layer subclass. Use it as a regular Paddle Layer and refer to the Paddle documentation for all matter related to general usage and behavior.

参数
  • vocab_size (int) -- Vocabulary size of the XLNet model. Defines the number of different tokens that can be represented by the inputs_ids passed when calling XLNetModel.

  • hidden_size (int, optional) -- Dimensionality of the encoder layers and the pooler layer. Defaults to 768.

  • num_hidden_layers (int, optional) -- Number of hidden layers in the Transformer encoder. Defaults to 12.

  • num_attention_heads (int, optional) -- Number of attention heads for each attention layer in the Transformer encoder. Defaults to 12.

  • intermediate_size (int, optional) -- Dimensionality of the "intermediate" (often named feed-forward) layer in the Transformer encoder. Defaults to 3072.

  • hidden_act (str, optional) -- The non-linear activation function in the feed-forward layer. "gelu", "relu" and any other paddle supported activation functions are supported. Defaults to "gelu".

  • hidden_dropout_prob (float, optional) -- The dropout probability for all fully connected layers in the embeddings and encoder. Defaults to 0.1.

  • attention_probs_dropout_prob (float, optional) -- The dropout probability for all fully connected layers in the pooler. Defaults to 0.1.

  • initializer_range (float, optional) -- The standard deviation of the truncated_normal_initializer for initializing all weight matrices. Defaults to 0.02.

forward(input_ids=None, bbox=None, image=None, token_type_ids=None, position_ids=None, attention_mask=None, head_mask=None, output_hidden_states=None, output_attentions=None)[源代码]

Defines the computation performed at every call. Should be overridden by all subclasses.

参数
  • *inputs (tuple) -- unpacked tuple arguments

  • **kwargs (dict) -- unpacked dict arguments

class LayoutLMv2PretrainedModel(name_scope=None, dtype='float32')[源代码]

基类:paddlenlp.transformers.model_utils.PretrainedModel

init_weights(layer)[源代码]

Initialization hook

base_model_class

alias of paddlenlp.transformers.layoutlmv2.modeling.LayoutLMv2Model

class LayoutLMv2ForTokenClassification(layoutlmv2, num_classes=2, dropout=None)[源代码]

基类:paddlenlp.transformers.layoutlmv2.modeling.LayoutLMv2PretrainedModel

forward(input_ids=None, bbox=None, image=None, attention_mask=None, token_type_ids=None, position_ids=None, head_mask=None, labels=None)[源代码]

Defines the computation performed at every call. Should be overridden by all subclasses.

参数
  • *inputs (tuple) -- unpacked tuple arguments

  • **kwargs (dict) -- unpacked dict arguments

class LayoutLMv2ForPretraining(layoutlmv2)[源代码]

基类:paddlenlp.transformers.layoutlmv2.modeling.LayoutLMv2PretrainedModel

forward(input_ids=None, bbox=None, image=None, attention_mask=None, token_type_ids=None, position_ids=None, head_mask=None, masked_positions=None)[源代码]

Defines the computation performed at every call. Should be overridden by all subclasses.

参数
  • *inputs (tuple) -- unpacked tuple arguments

  • **kwargs (dict) -- unpacked dict arguments

class LayoutLMv2ForRelationExtraction(layoutlmv2, hidden_size=768, hidden_dropout_prob=0.1, dropout=None)[源代码]

基类:paddlenlp.transformers.layoutlmv2.modeling.LayoutLMv2PretrainedModel

init_weights(layer)[源代码]

Initialize the weights

forward(input_ids, bbox, labels=None, image=None, attention_mask=None, token_type_ids=None, position_ids=None, head_mask=None, entities=None, relations=None)[源代码]

Defines the computation performed at every call. Should be overridden by all subclasses.

参数
  • *inputs (tuple) -- unpacked tuple arguments

  • **kwargs (dict) -- unpacked dict arguments