【发布时间】:2020-03-28 01:19:15
【问题描述】:
我正在使用 bert-for-tf2 库来解决多类分类问题。我创建了模型,但训练引发以下错误:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-25-d9f382cba5d4> in <module>()
----> 1 model.fit([INPUT_IDS,INPUT_MASKS,INPUT_SEGS], list(train.SECTION))
5 frames
/tensorflow-2.0.0/python3.6/tensorflow_core/python/keras/engine/data_adapter.py in
__init__(self, x, y, sample_weights, batch_size, epochs, steps, shuffle, **kwargs)
243 label, ", ".join([str(i.shape[0]) for i in nest.flatten(data)]))
244 msg += "Please provide data which shares the same first dimension."
--> 245 raise ValueError(msg)
246 num_samples = num_samples.pop()
247
ValueError: Data cardinality is ambiguous:
x sizes: 3
y sizes: 6102
Please provide data which shares the same first dimension.
我指的是名为Simple BERT using TensorFlow 2.0的媒体文章 可以在 here 找到库 bert-for-tf2 的 git repo。
请找到完整代码here。
Here 是我的 colab 笔记本的链接
非常感谢您的帮助!
【问题讨论】:
标签: machine-learning nlp text-classification tensorflow2.0 tf.keras