0

我使用 Deep Pavlov 框架与 Bert 分类器一起工作,只是因为我需要预测人员的语言是俄语。基本上,我正在尝试解决多类分类问题。根据 Deep Pavlov,我们可以轻松地更改配置文件上的一些配置。我拿了这个配置文件https://github.com/deepmipt/DeepPavlov/blob/master/deeppavlov/configs/classifiers/ruse​​ntiment_convers_bert.json并训练了它,我花了大约 13 个小时才完成,结果是这样我的模型过拟合。

我做了一些改变,尤其是这些:

"weight_decay_rate": 0.001,
"learning_rate_drop_patience": 1,
"learning_rate_drop_div": 2.0,
"load_before_drop": True, 
"min_learning_rate": 1e-03,
"attention_probs_keep_prob": 0.5,
"hidden_keep_prob": 0.5,

另外,我增加了批量大小,之前是 16:

"batch_size": 32

并添加了一些指标:

"log_loss",
"matthews_correlation",

还将validation_patience更改为1并添加了tensorboard func

"validation_patience": 1,
"tensorboard_log_dir": "logs/",

就是这样。这些是我对模型所做的所有更改,当我尝试训练我的模型时,它给了我以下错误:

UFuncTypeError                            Traceback (most recent call last)
        /usr/local/lib/python3.7/dist-packages/numpy/core/fromnumeric.py in _wrapfunc(obj, method, *args, **kwds)
             60     try:
        ---> 61         return bound(*args, **kwds)
             62     except TypeError:

15 frames
UFuncTypeError: ufunc 'clip' did not contain a loop with signature matching types (dtype('<U32'), dtype('<U32'), dtype('<U32')) -> dtype('<U32')

During handling of the above exception, another exception occurred:

UFuncTypeError                            Traceback (most recent call last)
<__array_function__ internals> in clip(*args, **kwargs)

/usr/local/lib/python3.7/dist-packages/numpy/core/_methods.py in _clip_dep_invoke_with_casting(ufunc, out, casting, *args, **kwargs)
     83     # try to deal with broken casting rules
     84     try:
---> 85         return ufunc(*args, out=out, **kwargs)
     86     except _exceptions._UFuncOutputCastingError as e:
     87         # Numpy 1.17.0, 2019-02-24

UFuncTypeError: ufunc 'clip' did not contain a loop with signature matching types (dtype('<U32'), dtype('<U32'), dtype('<U32')) -> dtype('<U32')

起初,我认为它与数据集有关,但是,我没有更改我的数据集,并且在我第一次训练这个模型时它已经运行了。

4

1 回答 1

0

log_loss在 DeepPavlov 中只是 sklearn.metrics.log_loss 的包装器: https ://github.com/deepmipt/DeepPavlov/blob/master/deeppavlov/metrics/log_loss.py#L37

默认情况下,DeepPavlov在度量计算中使用 chainer's outas和 chainer's as 。y_predin_yy_true

要使用日志丢失,您可以指定y_trueyy_ids。并指定y_predy_pred_probas对数损失计算。此更改将为您的案例计算日志损失:

{
  "name": "log_loss",
  "inputs": [
    "y",
    "y_pred_probas"
  ]
}
于 2021-05-12T16:21:54.050 回答