Tools¶
deepke.attribution_extraction.standard.tools.dataset module¶
deepke.attribution_extraction.standard.tools.metrics module¶
- class deepke.attribution_extraction.standard.tools.metrics.Metric[source]¶
Bases:
object
- abstract reset()[source]¶
Resets the metric to to it’s initial state. This is called at the start of each epoch.
deepke.attribution_extraction.standard.tools.preprocess module¶
deepke.attribution_extraction.standard.tools.serializer module¶
- class deepke.attribution_extraction.standard.tools.serializer.Serializer(never_split: Optional[List] = None, do_lower_case=True, do_chinese_split=False)[source]¶
Bases:
object
deepke.attribution_extraction.standard.tools.trainer module¶
- deepke.attribution_extraction.standard.tools.trainer.train(epoch, model, dataloader, optimizer, criterion, device, writer, cfg)[source]¶
- training the model.
- Args:
epoch (int): number of training steps. model (class): model of training. dataloader (dict): dict of dataset iterator. Keys are tasknames, values are corresponding dataloaders. optimizer (Callable): optimizer of training. criterion (Callable): loss criterion of training. device (torch.device): device of training. writer (class): output to tensorboard. cfg: configutation of training.
- Return:
losses[-1] : the loss of training
- deepke.attribution_extraction.standard.tools.trainer.validate(epoch, model, dataloader, criterion, device, cfg)[source]¶
- validating the model.
- Args:
epoch (int): number of validating steps. model (class): model of validating. dataloader (dict): dict of dataset iterator. Keys are tasknames, values are corresponding dataloaders. criterion (Callable): loss criterion of validating. device (torch.device): device of validating. cfg: configutation of validating.
- Return:
f1 : f1 score loss : the loss of validating
deepke.attribution_extraction.standard.tools.vocab module¶
- class deepke.attribution_extraction.standard.tools.vocab.Vocab(name: str = 'basic', init_tokens: Sequence = {'bos_token': '[BOS]', 'cls_token': '[CLS]', 'eos_token': '[EOS]', 'head_token': 'HEAD', 'mask_token': '[MASK]', 'pad_token': '[PAD]', 'sep_token': '[SEP]', 'tail_token': 'TAIL', 'unk_token': '[UNK]'})[source]¶
Bases:
object
构建词汇表,增加词汇,删除低频词汇