From 2b7188b1b8be214ad40468989c263a263d6fa5a8 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Fri, 29 Jul 2022 11:05:37 +0200 Subject: [PATCH] Minor fixes --- docs/examples/scibert/deploy.ipynb | 5 ++--- docs/examples/scibert/train.ipynb | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/examples/scibert/deploy.ipynb b/docs/examples/scibert/deploy.ipynb index 905f369..b35e6b2 100644 --- a/docs/examples/scibert/deploy.ipynb +++ b/docs/examples/scibert/deploy.ipynb @@ -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", diff --git a/docs/examples/scibert/train.ipynb b/docs/examples/scibert/train.ipynb index ef3a462..6e96889 100644 --- a/docs/examples/scibert/train.ipynb +++ b/docs/examples/scibert/train.ipynb @@ -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",