|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 1, |
| 6 | + "metadata": {}, |
| 7 | + "outputs": [ |
| 8 | + { |
| 9 | + "name": "stdout", |
| 10 | + "output_type": "stream", |
| 11 | + "text": [ |
| 12 | + "\u001b[1;31merror\u001b[0m: \u001b[1mexternally-managed-environment\u001b[0m\n", |
| 13 | + "\n", |
| 14 | + "\u001b[31m×\u001b[0m This environment is externally managed\n", |
| 15 | + "\u001b[31m╰─>\u001b[0m To install Python packages system-wide, try apt install\n", |
| 16 | + "\u001b[31m \u001b[0m python3-xyz, where xyz is the package you are trying to\n", |
| 17 | + "\u001b[31m \u001b[0m install.\n", |
| 18 | + "\u001b[31m \u001b[0m \n", |
| 19 | + "\u001b[31m \u001b[0m If you wish to install a non-Debian-packaged Python package,\n", |
| 20 | + "\u001b[31m \u001b[0m create a virtual environment using python3 -m venv path/to/venv.\n", |
| 21 | + "\u001b[31m \u001b[0m Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make\n", |
| 22 | + "\u001b[31m \u001b[0m sure you have python3-full installed.\n", |
| 23 | + "\u001b[31m \u001b[0m \n", |
| 24 | + "\u001b[31m \u001b[0m If you wish to install a non-Debian packaged Python application,\n", |
| 25 | + "\u001b[31m \u001b[0m it may be easiest to use pipx install xyz, which will manage a\n", |
| 26 | + "\u001b[31m \u001b[0m virtual environment for you. Make sure you have pipx installed.\n", |
| 27 | + "\u001b[31m \u001b[0m \n", |
| 28 | + "\u001b[31m \u001b[0m See /usr/share/doc/python3.12/README.venv for more information.\n", |
| 29 | + "\n", |
| 30 | + "\u001b[1;35mnote\u001b[0m: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.\n", |
| 31 | + "\u001b[1;36mhint\u001b[0m: See PEP 668 for the detailed specification.\n" |
| 32 | + ] |
| 33 | + } |
| 34 | + ], |
| 35 | + "source": [ |
| 36 | + "!pip install torch_geometric --quiet" |
| 37 | + ] |
| 38 | + }, |
| 39 | + { |
| 40 | + "cell_type": "code", |
| 41 | + "execution_count": 2, |
| 42 | + "metadata": {}, |
| 43 | + "outputs": [], |
| 44 | + "source": [ |
| 45 | + "import numpy as np\n", |
| 46 | + "import torch\n", |
| 47 | + "import torch.nn.functional as F\n", |
| 48 | + "import os\n", |
| 49 | + "import json\n", |
| 50 | + "from torch_geometric.utils import dense_to_sparse\n", |
| 51 | + "import matplotlib.pyplot as plt\n", |
| 52 | + "from sklearn.decomposition import PCA\n", |
| 53 | + "from sklearn.cluster import OPTICS, DBSCAN\n", |
| 54 | + "from tqdm.notebook import tqdm\n", |
| 55 | + "from torch.utils.data import Dataset\n", |
| 56 | + "\n", |
| 57 | + "# Custom imports\n", |
| 58 | + "import sys\n", |
| 59 | + "sys.path.insert(1, \"/kaggle/input/second-dataset/dependecies\")\n", |
| 60 | + "\n", |
| 61 | + "import GCN\n", |
| 62 | + "from Graph import Graph\n", |
| 63 | + "\n", |
| 64 | + "device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n", |
| 65 | + "TEST = False" |
| 66 | + ] |
| 67 | + }, |
| 68 | + { |
| 69 | + "cell_type": "code", |
| 70 | + "execution_count": 3, |
| 71 | + "metadata": {}, |
| 72 | + "outputs": [], |
| 73 | + "source": [ |
| 74 | + "model_diversity_path = \"weights/model_diversity_weights.pth\"\n", |
| 75 | + "model_accuracy_path = \"weights/model_accuracy_weights.pth\"" |
| 76 | + ] |
| 77 | + }, |
| 78 | + { |
| 79 | + "cell_type": "code", |
| 80 | + "execution_count": 4, |
| 81 | + "metadata": {}, |
| 82 | + "outputs": [ |
| 83 | + { |
| 84 | + "data": { |
| 85 | + "text/plain": [ |
| 86 | + "GCN(\n", |
| 87 | + " (gc1): GCNConv(8, 64)\n", |
| 88 | + " (gc2): GCNConv(64, 256)\n", |
| 89 | + " (gc3): GCNConv(256, 512)\n", |
| 90 | + " (gc4): GCNConv(512, 64)\n", |
| 91 | + " (residual_proj): Linear(in_features=8, out_features=64, bias=True)\n", |
| 92 | + " (layer_norm): LayerNorm((64,), eps=1e-05, elementwise_affine=True)\n", |
| 93 | + " (dropout): Dropout(p=0, inplace=False)\n", |
| 94 | + " (fc1): Linear(in_features=64, out_features=64, bias=True)\n", |
| 95 | + " (fc_norm): LayerNorm((64,), eps=1e-05, elementwise_affine=True)\n", |
| 96 | + " (fc2): Linear(in_features=64, out_features=16, bias=True)\n", |
| 97 | + ")" |
| 98 | + ] |
| 99 | + }, |
| 100 | + "execution_count": 4, |
| 101 | + "metadata": {}, |
| 102 | + "output_type": "execute_result" |
| 103 | + } |
| 104 | + ], |
| 105 | + "source": [ |
| 106 | + "input_dim = 8\n", |
| 107 | + "output_dim = 16\n", |
| 108 | + "dropout=0\n", |
| 109 | + "\n", |
| 110 | + "model_diverisity = GCN.GCN(input_dim, output_dim, dropout).to(device)\n", |
| 111 | + "state_dict = torch.load(model_diversity_path, map_location=device, weights_only=True)\n", |
| 112 | + "model_diverisity.load_state_dict(state_dict)\n", |
| 113 | + "model_diverisity.eval()" |
| 114 | + ] |
| 115 | + }, |
| 116 | + { |
| 117 | + "cell_type": "code", |
| 118 | + "execution_count": 5, |
| 119 | + "metadata": {}, |
| 120 | + "outputs": [ |
| 121 | + { |
| 122 | + "data": { |
| 123 | + "text/plain": [ |
| 124 | + "GCN(\n", |
| 125 | + " (gc1): GCNConv(8, 64)\n", |
| 126 | + " (gc2): GCNConv(64, 256)\n", |
| 127 | + " (gc3): GCNConv(256, 512)\n", |
| 128 | + " (gc4): GCNConv(512, 64)\n", |
| 129 | + " (residual_proj): Linear(in_features=8, out_features=64, bias=True)\n", |
| 130 | + " (layer_norm): LayerNorm((64,), eps=1e-05, elementwise_affine=True)\n", |
| 131 | + " (dropout): Dropout(p=0, inplace=False)\n", |
| 132 | + " (fc1): Linear(in_features=64, out_features=64, bias=True)\n", |
| 133 | + " (fc_norm): LayerNorm((64,), eps=1e-05, elementwise_affine=True)\n", |
| 134 | + " (fc2): Linear(in_features=64, out_features=1, bias=True)\n", |
| 135 | + ")" |
| 136 | + ] |
| 137 | + }, |
| 138 | + "execution_count": 5, |
| 139 | + "metadata": {}, |
| 140 | + "output_type": "execute_result" |
| 141 | + } |
| 142 | + ], |
| 143 | + "source": [ |
| 144 | + "input_dim = 8\n", |
| 145 | + "output_dim = 1\n", |
| 146 | + "dropout = 0\n", |
| 147 | + "\n", |
| 148 | + "model_accuracy = GCN.GCN(input_dim, output_dim, dropout).to(device)\n", |
| 149 | + "state_dict = torch.load(model_accuracy_path, map_location=device, weights_only=True)\n", |
| 150 | + "model_accuracy.load_state_dict(state_dict)\n", |
| 151 | + "model_accuracy.eval()" |
| 152 | + ] |
| 153 | + }, |
| 154 | + { |
| 155 | + "cell_type": "code", |
| 156 | + "execution_count": null, |
| 157 | + "metadata": {}, |
| 158 | + "outputs": [], |
| 159 | + "source": [] |
| 160 | + } |
| 161 | + ], |
| 162 | + "metadata": { |
| 163 | + "kernelspec": { |
| 164 | + "display_name": "Python 3", |
| 165 | + "language": "python", |
| 166 | + "name": "python3" |
| 167 | + }, |
| 168 | + "language_info": { |
| 169 | + "codemirror_mode": { |
| 170 | + "name": "ipython", |
| 171 | + "version": 3 |
| 172 | + }, |
| 173 | + "file_extension": ".py", |
| 174 | + "mimetype": "text/x-python", |
| 175 | + "name": "python", |
| 176 | + "nbconvert_exporter": "python", |
| 177 | + "pygments_lexer": "ipython3", |
| 178 | + "version": "3.12.3" |
| 179 | + } |
| 180 | + }, |
| 181 | + "nbformat": 4, |
| 182 | + "nbformat_minor": 2 |
| 183 | +} |
0 commit comments