mirror of
https://github.com/20kaushik02/CSE515_MWDB_Project.git
synced 2025-12-06 09:04:06 +00:00
correction in task 11 latent space sim matrix
This commit is contained in:
parent
6a1c11a9fa
commit
04987d5aa8
@ -39,26 +39,24 @@
|
|||||||
" def create_similarity_graph(\n",
|
" def create_similarity_graph(\n",
|
||||||
" self, n, feature_model, semantic_data=None, dim_reduction_method=None\n",
|
" self, n, feature_model, semantic_data=None, dim_reduction_method=None\n",
|
||||||
" ):\n",
|
" ):\n",
|
||||||
|
" import glob\n",
|
||||||
|
"\n",
|
||||||
" if semantic_data is None:\n",
|
" if semantic_data is None:\n",
|
||||||
|
" file_prefix = f\"image_sim-{feature_model}-*.json\"\n",
|
||||||
|
" if len(glob.glob(file_prefix)) > 0:\n",
|
||||||
|
" matrix_data = json.load(open(glob.glob(file_prefix)[0]))\n",
|
||||||
|
" image_sim_matrix = matrix_data[\"sim-matrix\"]\n",
|
||||||
|
" if self.verbose:\n",
|
||||||
|
" print(\"Using image-image similarity matrix from semantic data\")\n",
|
||||||
|
" else:\n",
|
||||||
" # Similarity graph from feature models\n",
|
" # Similarity graph from feature models\n",
|
||||||
" image_sim_matrix = find_image_image_similarity(fd_collection, feature_model)\n",
|
" image_sim_matrix = find_image_image_similarity(\n",
|
||||||
|
" fd_collection, feature_model\n",
|
||||||
|
" )\n",
|
||||||
" if self.verbose:\n",
|
" if self.verbose:\n",
|
||||||
" print(\"Image-image similarity matrix constructed from\", feature_model)\n",
|
" print(\"Image-image similarity matrix constructed from\", feature_model)\n",
|
||||||
" else:\n",
|
" else:\n",
|
||||||
" # Similarity graph from image-semantic latent space\n",
|
" # Similarity graph from image-semantic latent space\n",
|
||||||
" # LS3, LS4\n",
|
|
||||||
" if \"sim-matrix\" in semantic_data:\n",
|
|
||||||
" # for now, don't work with LS3\n",
|
|
||||||
" # TODO: do similar to task 7 and 10\n",
|
|
||||||
" image_sim_matrix = np.array(semantic_data[\"sim-matrix\"])\n",
|
|
||||||
" if image_sim_matrix.shape[0] != NUM_IMAGES:\n",
|
|
||||||
" raise TypeError(\n",
|
|
||||||
" \"Functionality to construct similarity graph from LS3 not yet done\"\n",
|
|
||||||
" )\n",
|
|
||||||
" if self.verbose:\n",
|
|
||||||
" print(\"Using image-image similarity matrix from semantic data\")\n",
|
|
||||||
" # LS1, LS2\n",
|
|
||||||
" else:\n",
|
|
||||||
" image_semantic = semantic_data[\"image-semantic\"]\n",
|
" image_semantic = semantic_data[\"image-semantic\"]\n",
|
||||||
" # SVD, CP\n",
|
" # SVD, CP\n",
|
||||||
" if \"semantics-core\" in semantic_data:\n",
|
" if \"semantics-core\" in semantic_data:\n",
|
||||||
@ -103,8 +101,6 @@
|
|||||||
" def personalized_pagerank(\n",
|
" def personalized_pagerank(\n",
|
||||||
" self, label, m, damping_factor=0.85, max_iter=1000, tol=1e-6\n",
|
" self, label, m, damping_factor=0.85, max_iter=1000, tol=1e-6\n",
|
||||||
" ):\n",
|
" ):\n",
|
||||||
" import time\n",
|
|
||||||
"\n",
|
|
||||||
" if self.similarity_graph is None:\n",
|
" if self.similarity_graph is None:\n",
|
||||||
" raise ValueError(\n",
|
" raise ValueError(\n",
|
||||||
" \"Similarity graph not created. Call create_similarity_graph() first.\"\n",
|
" \"Similarity graph not created. Call create_similarity_graph() first.\"\n",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user