def join_embeddings(src_we, target_we):
"""joins and filters words not in common and produces two tensors"""
src_w = set(src_we.keys())
target_w = set(target_we.keys())
common_w = src_w & target_w
src_tensor = []
target_tensor = []
for w in common_w:
src_tensor.append(src_we[w])
target_tensor.append(target_we[w])
src_tensor = torch.Tensor(np.stack(src_tensor))
target_tensor = torch.Tensor(np.stack(target_tensor))
return src_tensor, target_tensor
评论列表
文章目录