" closest_cluster_no = int(cluster_no) # Convert cluster_no to an integer\n",
" print(min_distance, closest_cluster_no)\n",
" return closest_cluster_no\n"
]
},
{
...
...
@@ -120,7 +157,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 11,
"id": "cf2e79ca-461b-4368-98cc-26d9e55488fd",
"metadata": {},
"outputs": [
...
...
@@ -128,7 +165,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"Some weights of the model checkpoint at bert-base-uncased were not used when initializing BertModel: ['cls.predictions.bias', 'cls.predictions.decoder.weight', 'cls.seq_relationship.weight', 'cls.seq_relationship.bias', 'cls.predictions.transform.LayerNorm.weight', 'cls.predictions.transform.dense.bias', 'cls.predictions.transform.LayerNorm.bias', 'cls.predictions.transform.dense.weight']\n",
"Some weights of the model checkpoint at bert-base-uncased were not used when initializing BertModel: ['cls.predictions.transform.dense.weight', 'cls.seq_relationship.weight', 'cls.predictions.transform.dense.bias', 'cls.predictions.transform.LayerNorm.weight', 'cls.predictions.transform.LayerNorm.bias', 'cls.predictions.decoder.weight', 'cls.predictions.bias', 'cls.seq_relationship.bias']\n",
"- This IS expected if you are initializing BertModel from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).\n",
"- This IS NOT expected if you are initializing BertModel from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).\n"
]
...
...
@@ -137,11 +174,14 @@
"name": "stdout",
"output_type": "stream",
"text": [
"13.285225168586905\n",
"11.51259043024684\n",
"8.962974422826848\n",
"12.52214870605026\n",
"10.757946725715826\n",
"1\n",
"13.285225168586905 1\n",
"4\n",
"11.51259043024684 4\n",
"0\n",
"8.962974422826848 0\n",
"2\n",
"3\n",
"The closest cluster for the word 'ocean' is cluster 0\n"