[英]UFuncTypeError: ufunc ‘clip’ did not contain a loop with signature matching types (dtype(‘<U32’), dtype(‘<U32’), dtype(‘<U32’)) -> dtype(‘<U32’)
I am using the Deep Pavlov framework to work with Bert Classifier simply because the language I need to predict staff is Russian.我使用 Deep Pavlov 框架与 Bert 分类器一起工作,只是因为我需要预测人员的语言是俄语。 Basically, I am trying to solve a multi-class classification problem.
基本上,我正在尝试解决多类分类问题。 According to the Deep Pavlov, we can easily change some configs on config file.
根据 Deep Pavlov,我们可以轻松地更改配置文件上的一些配置。 I took this config file https://github.com/deepmipt/DeepPavlov/blob/master/deeppavlov/configs/classifiers/rusentiment_convers_bert.json and trained it, and it took me around 13 hours to finish and it turned out to be that my model is overfitting.
我拿了这个配置文件https://github.com/deepmipt/DeepPavlov/blob/master/deeppavlov/configs/classifiers/rusentiment_convers_bert.json并训练它,结果我花了大约 13 个小时才完成它我的 model 过拟合。
I made some changes, particularly these:我做了一些改变,尤其是这些:
"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,
also, I increased the batch size, it was 16 before now:另外,我增加了批量大小,之前是 16:
"batch_size": 32
and added some metrics:并添加了一些指标:
"log_loss",
"matthews_correlation",
Also changed validation_patience to 1 and added tensorboard func还将validation_patience更改为1并添加了tensorboard func
"validation_patience": 1,
"tensorboard_log_dir": "logs/",
and that is it.就是这样。 these are all the changes I made to my model, and when i tried to train my model, it is giving me following error:
这些是我对 model 所做的所有更改,当我尝试训练我的 model 时,它给了我以下错误:
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')
At first, I thought it has something to do with a dataset, however, I did not change my dataset and it has run the first time I trained this model.起初,我认为它与数据集有关,但是,我没有更改我的数据集,并且在我第一次训练这个 model 时它已经运行。
log_loss
in DeepPavlov is just a wrapper over sklearn.metrics.log_loss: https://github.com/deepmipt/DeepPavlov/blob/master/deeppavlov/metrics/log_loss.py#L37 log_loss
中的 log_loss 只是 sklearn.metrics.log_loss 的包装: https://github.com/deepmipt/DeepPavlov/blob/master/deeppavlov/metrics/log_loss.py#L37
By default DeepPavlov uses chainer's out
as y_pred
in metrics computation and chainer's in_y
as y_true
.默认情况下,DeepPavlov 在度量计算中使用 chainer's
out
作为y_pred
和 chainer's in_y
作为y_true
。
To use log loss you can specify y_true
as y
or y_ids
.要使用日志丢失,您可以将
y_true
指定为y
或y_ids
。 And specify y_pred
as y_pred_probas
in log loss computation.并在对数损失计算
y_pred
指定为y_pred_probas
。 This change will compute log loss for your case:此更改将为您的案例计算日志损失:
{
"name": "log_loss",
"inputs": [
"y",
"y_pred_probas"
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.