Minor fixes

This commit is contained in:
Andras Schmelczer 2022-07-29 11:05:37 +02:00
parent 4d55499548
commit 2b7188b1b8
No known key found for this signature in database
GPG key ID: 0EA1BC97D0AB076E
2 changed files with 3 additions and 4 deletions

View file

@ -182,9 +182,8 @@
" positive_likelihood = torch.nn.Softmax(dim=1)(result.logits)[0][1]\n",
" tokens = tensors[\"input_ids\"][0]\n",
"\n",
" attentions = np.sum(result.attentions[-1].numpy()[0], axis=0)[0][\n",
" 1:-1\n",
" ] # Tuple of `torch.FloatTensor` (one for each layer) of shape\n",
" attentions = np.sum(result.attentions[-1].numpy()[0], axis=0)[0][1:-1]\n",
" # Tuple of `torch.FloatTensor` (one for each layer) of shape\n",
" # `(batch_size, num_heads, sequence_length, sequence_length)`.\n",
"\n",
" explanation = []\n",

View file

@ -246,7 +246,7 @@
" Dataset.from_dict({\"text\": X, \"label\": y})\n",
" .map(lambda v: tokenizer(v[\"text\"], truncation=True), batched=True)\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",
"f1_score = load_metric(\"f1\")\n",