我有一份共同作者名单:
ten_author_pairs = [('creutzig', 'gao'),
('creutzig', 'linshaw'),
('gao', 'linshaw'),
('jing', 'zhang'),
('jing', 'liu'),
('zhang', 'liu'),
('jing', 'xu'),
('briant', 'einav'),
('chen', 'gao'),
('chen', 'jing')]
Run Code Online (Sandbox Code Playgroud)
从这里我可以生成一个反例列表 - 即使用以下代码未连接的作者对:
#generating negative examples -
from itertools import combinations
elements = list(set([e for l in ten_author_pairs for e in l])) # find all unique elements
complete_list = list(combinations(elements, 2)) # generate all possible combinations
#convert to sets to negate the order
set1 = [set(l) for l in ten_author_pairs]
complete_set = [set(l) for l in complete_list] …Run Code Online (Sandbox Code Playgroud) 我正在尝试学习 BERT 进行文本分类。我在准备使用 BERT 的数据时发现一些问题。
从我的数据集中,我将情绪和评论分为:
X = df['sentiments']
y = df['reviews'] #it contains four different class of reviews
Run Code Online (Sandbox Code Playgroud)
下一个,
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)
train_encodings = tokenizer(X_train, truncation=True, padding=True, max_length=512)
Run Code Online (Sandbox Code Playgroud)
这是我收到错误的地方:
X = df['sentiments']
y = df['reviews'] #it contains four different class of reviews
Run Code Online (Sandbox Code Playgroud)
当我尝试将 X 转换为列表并使用它时,出现另一个错误:
TypeError: TextEncodeInput must be Union[TextInputSequence, Tuple[InputSequence, InputSequence]]
Run Code Online (Sandbox Code Playgroud)
有人可以解释一下问题出在哪里吗?之前我遵循了 20 个新闻数据集的教程,结果很有效。但现在当我在另一个项目中使用它时,它不起作用,我感到很难过。
谢谢。