Minor fixes
This commit is contained in:
parent
4d55499548
commit
2b7188b1b8
2 changed files with 3 additions and 4 deletions
|
|
@ -182,9 +182,8 @@
|
||||||
" positive_likelihood = torch.nn.Softmax(dim=1)(result.logits)[0][1]\n",
|
" positive_likelihood = torch.nn.Softmax(dim=1)(result.logits)[0][1]\n",
|
||||||
" tokens = tensors[\"input_ids\"][0]\n",
|
" tokens = tensors[\"input_ids\"][0]\n",
|
||||||
"\n",
|
"\n",
|
||||||
" attentions = np.sum(result.attentions[-1].numpy()[0], axis=0)[0][\n",
|
" attentions = np.sum(result.attentions[-1].numpy()[0], axis=0)[0][1:-1]\n",
|
||||||
" 1:-1\n",
|
" # Tuple of `torch.FloatTensor` (one for each layer) of shape\n",
|
||||||
" ] # Tuple of `torch.FloatTensor` (one for each layer) of shape\n",
|
|
||||||
" # `(batch_size, num_heads, sequence_length, sequence_length)`.\n",
|
" # `(batch_size, num_heads, sequence_length, sequence_length)`.\n",
|
||||||
"\n",
|
"\n",
|
||||||
" explanation = []\n",
|
" explanation = []\n",
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,7 @@
|
||||||
" Dataset.from_dict({\"text\": X, \"label\": y})\n",
|
" Dataset.from_dict({\"text\": X, \"label\": y})\n",
|
||||||
" .map(lambda v: tokenizer(v[\"text\"], truncation=True), batched=True)\n",
|
" .map(lambda v: tokenizer(v[\"text\"], truncation=True), batched=True)\n",
|
||||||
" .remove_columns(\"text\")\n",
|
" .remove_columns(\"text\")\n",
|
||||||
" .train_test_split(test_size=0.2, shuffle=True)\n",
|
" .train_test_split(test_size=0.2, shuffle=True) # test is actually validation\n",
|
||||||
")\n",
|
")\n",
|
||||||
"\n",
|
"\n",
|
||||||
"f1_score = load_metric(\"f1\")\n",
|
"f1_score = load_metric(\"f1\")\n",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue