Abstract Class

Backbones

class mindnlp.abc.BaseModel(auto_prefix=True, flags=None)[source]

Basic class for models

class mindnlp.abc.Seq2seqModel(encoder, decoder)[source]

Basic class for seq2seq models

Parameters
class mindnlp.abc.Seq2vecModel(encoder, head, dropout: Optional[float] = None)[source]

Basic class for seq2vec models

Parameters
  • encoder (EncoderBase) – The encoder.

  • head (nn.Cell) – The module to process encoder output.

  • dropout (float) – The drop out rate, greater than 0 and less equal than 1. If None, not dropping out input units. Drfault: None.

class mindnlp.abc.PretrainedModel(config)[source]

Abstract class for Pretrained models

class mindnlp.abc.PretrainedConfig(**kwargs)[source]

Abstract class for Pretrained models config.

Callback

class mindnlp.abc.Callback[source]

Abstract base class used to build a callback class. Callbacks are context managers which will be entered and exited when passing into the Model. You can use this mechanism to do some custom operations.

Callback function can perform some operations before and after step or epoch. To create a custom callback, subclass Callback and override the method associated with the stage of interest.

Metric

class mindnlp.abc.Metric[source]

Base class of all metrics. Never use this class directly, but instantiate one of its subclasses instead.

Functions update will accumulate intermediate results in the evaluation process, eval will evaluate the final result, and clear will reinitialize the intermediate results. Function get_metric_name will provide class name.

Modules

class mindnlp.abc.EncoderBase(embedding)[source]

Basic class for encoders

Parameters

embedding (Cell) – The embedding layer.

class mindnlp.abc.DecoderBase(embedding)[source]

Basic class for dedcoders

Parameters

embedding (Cell) – The embedding layer.

class mindnlp.abc.TokenEmbedding(vocab: Vocab, init_embed, requires_grad: bool = True, dropout=0.0)[source]

Create vocab and Embedding from a given pre-trained vector file.

Parameters
  • vocab (Vocab) – Passins into Vocab for initialization.

  • init_embed (Tensor) – Passing into Vocab and Tensor,use these values to initialize Embedding directly.

  • requires_grad (bool) – Whether this parameter needs to be gradient to update.

  • dropout (float) – Dropout of the output of Embedding.