Skip to content

Instantly share code, notes, and snippets.

@henry16lin
Created February 15, 2020 14:53
Show Gist options
  • Save henry16lin/dce942fdd41df3a633b97c7cdc3368b3 to your computer and use it in GitHub Desktop.
Save henry16lin/dce942fdd41df3a633b97c7cdc3368b3 to your computer and use it in GitHub Desktop.
prepare_result
# 隨便選一個樣本
sample_idx = 10
# 利用剛剛建立的 Dataset 取出轉換後的 id tensors
tokens_tensor, segments_tensor, label_tensor,origin_text = trainset[sample_idx]
# 將 tokens_tensor 還原成文本
tokens = tokenizer.convert_ids_to_tokens(tokens_tensor.tolist())
print('token:\n',tokens,'\n')
print('origin_text:\n',origin_text,'\n')
print('label:',label_map[int(label_tensor.numpy())],'\n')
print('tokens_tensor:\n',tokens_tensor,'\n')
print('segment tensor:\n',segments_tensor)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment