我使用 Keras 功能 API 构建了一个多输入模型。这个想法是对文本及其元数据进行分类。该模型适用于 NumPy 格式输入,但适用于 tf.data.Dataset 则失败。
UnimplementedError: Cast string to int32 is not supported
[[node functional_5/Cast (defined at <ipython-input-3-8e2b230c1da3>:17) ]] [Op:__inference_train_function_24120]
Function call stack:
train_function
Run Code Online (Sandbox Code Playgroud)
我不确定如何解释它,因为两个输入应该是相等的。预先感谢您的任何指导。我在下面附上了我的项目的虚拟等效项。
模型:
import tensorflow as tf
import tensorflow.keras as keras
from tensorflow.keras import Input, Model, layers
from transformers import DistilBertTokenizer, TFDistilBertModel
MAX_LEN = 20
STRING_CATEGORICAL_COLUMNS = [
"Organization",
"Sector",
"Content_type",
"Geography",
"Themes",
]
VOCAB = {
"Organization": ["BNS", "FED", "ECB"],
"Sector": ["BANK", "ASS", "MARKET"],
"Content_type": ["LAW", "NOTES", "PAPER"],
"Geography": ["UK", "FR", "DE", …Run Code Online (Sandbox Code Playgroud)