From 9ae6cd2cffc2f9ad3d51f8584d6325ffd6dffbdd Mon Sep 17 00:00:00 2001 From: spacewaterbear <38250076+spacewaterbear@users.noreply.github.com> Date: Sat, 3 Apr 2021 18:39:30 +0200 Subject: [PATCH] fix "bert_model" outputs (last_hidden_state, pooled_output) othervise last_hidden_state.shape return an AttributeError: 'str' object has no attribute 'shape' --- 08.sentiment-analysis-with-bert.ipynb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/08.sentiment-analysis-with-bert.ipynb b/08.sentiment-analysis-with-bert.ipynb index d249946..12cab17 100644 --- a/08.sentiment-analysis-with-bert.ipynb +++ b/08.sentiment-analysis-with-bert.ipynb @@ -1563,10 +1563,11 @@ "colab": {} }, "source": [ - "last_hidden_state, pooled_output = bert_model(\n", + "last_hidden_state_pooled_output = bert_model(\n", " input_ids=encoding['input_ids'], \n", " attention_mask=encoding['attention_mask']\n", - ")" + ")", + "last_hidden_state, pooled_output = last_hidden_state_pooled_output[0], last_hidden_state_pooled_output[1]" ], "execution_count": 0, "outputs": [] @@ -2717,4 +2718,4 @@ ] } ] -} \ No newline at end of file +}