HUANGYIFEI commited on
Commit
af557de
·
verified ·
1 Parent(s): d142b96

Delete .ipynb_checkpoints

Browse files
.ipynb_checkpoints/DataInspect-checkpoint.ipynb DELETED
@@ -1,396 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "metadata": {
5
- "ExecuteTime": {
6
- "end_time": "2024-12-12T16:11:02.453452Z",
7
- "start_time": "2024-12-12T16:10:59.783010Z"
8
- }
9
- },
10
- "cell_type": "code",
11
- "source": [
12
- "import os\n",
13
- "import time\n",
14
- "from rdkit import Chem\n",
15
- "from rdkit import RDLogger;\n",
16
- "from torch.utils.data import Dataset\n",
17
- "import torch.nn.functional as F\n",
18
- "RDLogger.DisableLog('rdApp.*')\n",
19
- "import torch\n",
20
- "import torch.nn as nn\n",
21
- "import torch.optim as optim\n",
22
- "import pickle\n",
23
- "import numpy as np\n",
24
- "import matplotlib.pyplot as plt\n",
25
- "import math\n",
26
- "import dgl\n",
27
- "import networkx as nx"
28
- ],
29
- "id": "1517383df6eb646",
30
- "outputs": [],
31
- "execution_count": 1
32
- },
33
- {
34
- "metadata": {
35
- "ExecuteTime": {
36
- "end_time": "2024-12-12T16:11:02.468893Z",
37
- "start_time": "2024-12-12T16:11:02.454576Z"
38
- }
39
- },
40
- "cell_type": "code",
41
- "source": [
42
- "atom_number_index_dict ={\n",
43
- " 1:0,\n",
44
- " 6:1,\n",
45
- " 7:2,\n",
46
- " 8:3,\n",
47
- " 9:4\n",
48
- "}\n",
49
- "atom_index_number_dict ={\n",
50
- " 0:1,\n",
51
- " 1:6,\n",
52
- " 2:7,\n",
53
- " 3:8,\n",
54
- " 4:9\n",
55
- "}\n",
56
- "def atom_number2index(atom_number):\n",
57
- " return atom_number_index_dict[atom_number]\n",
58
- "def atom_index2number(atom_index):\n",
59
- " return atom_index_number_dict[atom_index]"
60
- ],
61
- "id": "697783252f244e50",
62
- "outputs": [],
63
- "execution_count": 2
64
- },
65
- {
66
- "metadata": {
67
- "ExecuteTime": {
68
- "end_time": "2024-12-12T16:11:03.301916Z",
69
- "start_time": "2024-12-12T16:11:03.243204Z"
70
- }
71
- },
72
- "cell_type": "code",
73
- "source": [
74
- "from dgl.data import QM9Dataset\n",
75
- "from torch.utils.data import SubsetRandomSampler\n",
76
- "from dgl.dataloading import GraphDataLoader\n",
77
- "\n",
78
- "dataset = QM9Dataset(label_keys=['mu', 'gap'], cutoff=5.0)\n",
79
- "dataset_length = len(dataset)\n",
80
- "train_idx = torch.arange(dataset_length)\n",
81
- "train_sampler = SubsetRandomSampler(train_idx)\n",
82
- "def collate_fn(batch):\n",
83
- " graphs, labels = map(list, zip(*batch))\n",
84
- " for g in graphs:\n",
85
- " # g.ndata[\"R\"]->the coordinates of each atom[num_nodes,3], g.ndata[\"Z\"]->the atomic number(H:1,C:6) [num_nodes]\n",
86
- " g.ndata[\"Z_index\"] = torch.tensor([atom_number2index(z.item()) for z in g.ndata[\"Z\"]])\n",
87
- " batched_graph = dgl.batch(graphs)\n",
88
- " return batched_graph, torch.stack(labels)\n",
89
- "myGLoader = GraphDataLoader(dataset,collate_fn=collate_fn,batch_size=5, pin_memory=True)"
90
- ],
91
- "id": "7074f5a11a15ebc6",
92
- "outputs": [],
93
- "execution_count": 3
94
- },
95
- {
96
- "metadata": {
97
- "ExecuteTime": {
98
- "end_time": "2024-12-12T15:59:44.314049Z",
99
- "start_time": "2024-12-12T15:59:44.299072Z"
100
- }
101
- },
102
- "cell_type": "code",
103
- "source": [
104
- "# atom_numbers = []\n",
105
- "# for g,_ in dataset:\n",
106
- "# for atom_z in g.ndata[\"Z\"]:\n",
107
- "# if atom_z not in atom_numbers:\n",
108
- "# atom_numbers.append(atom_z)\n",
109
- "# print(atom_numbers)"
110
- ],
111
- "id": "5758841a1f281514",
112
- "outputs": [],
113
- "execution_count": 12
114
- },
115
- {
116
- "metadata": {
117
- "ExecuteTime": {
118
- "end_time": "2024-12-12T16:14:46.301537Z",
119
- "start_time": "2024-12-12T16:11:12.606641Z"
120
- }
121
- },
122
- "cell_type": "code",
123
- "source": [
124
- "device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
125
- "for batch in myGLoader:\n",
126
- " batch_g,label = batch\n",
127
- " batch_g.to(device)\n",
128
- " "
129
- ],
130
- "id": "13bcff8166b0e35b",
131
- "outputs": [],
132
- "execution_count": 5
133
- },
134
- {
135
- "metadata": {
136
- "ExecuteTime": {
137
- "end_time": "2024-12-12T16:07:15.834856Z",
138
- "start_time": "2024-12-12T16:07:15.822783Z"
139
- }
140
- },
141
- "cell_type": "code",
142
- "source": [
143
- "from functools import partial\n",
144
- "import sys\n",
145
- "sys.path.append(\"lib\")\n",
146
- "from lib.metrics import sce_loss\n",
147
- "\n",
148
- "class GMae(nn.Module):\n",
149
- " def __init__(self, encoder,decoder,\n",
150
- " in_dim,hidden_dim,out_dim,mask_rate=0.3,replace_rate=0.1,alpha_l=2,\n",
151
- " embedding_layer_classes=4,embedding_layer_dim=4):\n",
152
- " super(GMae, self).__init__()\n",
153
- " self.Z_embedding = nn.Embedding(embedding_layer_classes,embedding_layer_dim)\n",
154
- " self.encoder = encoder\n",
155
- " self.decoder = decoder\n",
156
- " self.mask_rate = mask_rate\n",
157
- " self.replace_rate = replace_rate\n",
158
- " self.alpha_l = alpha_l\n",
159
- " self.in_dim = in_dim\n",
160
- " self.hidden_dim = hidden_dim\n",
161
- " self.out_dim = out_dim\n",
162
- " self.embedding_layer_classes = embedding_layer_classes\n",
163
- " self.embedding_layer_dim = embedding_layer_dim\n",
164
- " self.enc_mask_token = nn.Parameter(torch.zeros(1,in_dim))\n",
165
- " self.criterion = partial(sce_loss, alpha=alpha_l)\n",
166
- " self.encoder_to_decoder = nn.Linear(hidden_dim, hidden_dim, bias=False)\n",
167
- " def encode_atom_index(self,Z_index):\n",
168
- " return self.Z_embedding(Z_index)\n",
169
- " def encoding_mask_noise(self, g, x, mask_rate=0.3):\n",
170
- " num_nodes = g.num_nodes()\n",
171
- " perm = torch.randperm(num_nodes, device=x.device)\n",
172
- " # random masking\n",
173
- " num_mask_nodes = int(mask_rate * num_nodes)\n",
174
- " mask_nodes = perm[: num_mask_nodes]\n",
175
- " keep_nodes = perm[num_mask_nodes: ]\n",
176
- "\n",
177
- " if self.replace_rate > 0:\n",
178
- " num_noise_nodes = int(self.replace_rate * num_mask_nodes)\n",
179
- " perm_mask = torch.randperm(num_mask_nodes, device=x.device)\n",
180
- " token_nodes = mask_nodes[perm_mask[: int((1-self.replace_rate) * num_mask_nodes)]]\n",
181
- " noise_nodes = mask_nodes[perm_mask[-int(self.replace_rate * num_mask_nodes):]]\n",
182
- " noise_to_be_chosen = torch.randperm(num_nodes, device=x.device)[:num_noise_nodes]\n",
183
- " out_x = x.clone()\n",
184
- " out_x[token_nodes] = 0.0\n",
185
- " out_x[noise_nodes] = x[noise_to_be_chosen]\n",
186
- " else:\n",
187
- " out_x = x.clone()\n",
188
- " token_nodes = mask_nodes\n",
189
- " out_x[mask_nodes] = 0.0\n",
190
- "\n",
191
- " out_x[token_nodes] += self.enc_mask_token\n",
192
- " use_g = g.clone()\n",
193
- "\n",
194
- " return use_g, out_x, (mask_nodes, keep_nodes) \n",
195
- " def mask_attr_prediction(self, g, x):\n",
196
- " use_g, use_x, (mask_nodes, keep_nodes) = self.encoding_mask_noise(g, x, self.mask_rate)\n",
197
- " enc_rep = self.encoder(use_g, use_x)\n",
198
- " # ---- attribute reconstruction ----\n",
199
- " rep = self.encoder_to_decoder(enc_rep)\n",
200
- " recon = self.decoder(use_g, rep)\n",
201
- " x_init = x[mask_nodes]\n",
202
- " x_rec = recon[mask_nodes]\n",
203
- " loss = self.criterion(x_rec, x_init)\n",
204
- " return loss\n",
205
- "\n",
206
- " def embed(self, g, x):\n",
207
- " rep = self.encoder(g, x)\n",
208
- " return rep\n",
209
- " "
210
- ],
211
- "id": "1a5caea191a642bc",
212
- "outputs": [],
213
- "execution_count": 5
214
- },
215
- {
216
- "metadata": {
217
- "ExecuteTime": {
218
- "end_time": "2024-12-12T16:07:18.136174Z",
219
- "start_time": "2024-12-12T16:07:18.122456Z"
220
- }
221
- },
222
- "cell_type": "code",
223
- "source": [
224
- "import dgl.nn as dglnn\n",
225
- "import torch.nn as nn\n",
226
- "import torch.nn.functional as F\n",
227
- "class SimpleGNN(nn.Module):\n",
228
- " def __init__(self, in_feats, hid_feats, out_feats):\n",
229
- " super().__init__()\n",
230
- " self.conv1 = dglnn.SAGEConv(\n",
231
- " in_feats=in_feats, out_feats=hid_feats,aggregator_type=\"mean\")\n",
232
- " self.conv2 = dglnn.SAGEConv(\n",
233
- " in_feats=hid_feats, out_feats=out_feats,aggregator_type=\"mean\")\n",
234
- "\n",
235
- " def forward(self, graph, inputs):\n",
236
- " # 输入是节点的特征\n",
237
- " h = self.conv1(graph, inputs)\n",
238
- " h = F.relu(h)\n",
239
- " h = self.conv2(graph, h)\n",
240
- " return h"
241
- ],
242
- "id": "c99cb509ac0f1054",
243
- "outputs": [],
244
- "execution_count": 6
245
- },
246
- {
247
- "metadata": {
248
- "ExecuteTime": {
249
- "end_time": "2024-12-12T16:07:21.516476Z",
250
- "start_time": "2024-12-12T16:07:21.118135Z"
251
- }
252
- },
253
- "cell_type": "code",
254
- "source": [
255
- "sage_enc = SimpleGNN(in_feats=7,hid_feats=4,out_feats=4)\n",
256
- "sage_dec = SimpleGNN(in_feats=4,hid_feats=4,out_feats=7)\n",
257
- "gmae = GMae(sage_enc,sage_dec,7,4,7,replace_rate=0)\n",
258
- "epoches = 20\n",
259
- "optimizer = optim.Adam(gmae.parameters(), lr=1e-3)\n",
260
- "device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')"
261
- ],
262
- "id": "5a8a4e4dd753b642",
263
- "outputs": [],
264
- "execution_count": 7
265
- },
266
- {
267
- "metadata": {
268
- "ExecuteTime": {
269
- "end_time": "2024-12-12T16:10:52.354863Z",
270
- "start_time": "2024-12-12T16:10:52.311090Z"
271
- }
272
- },
273
- "cell_type": "code",
274
- "source": [
275
- "print(f\"epoch {0} started!\")\n",
276
- "gmae.train()\n",
277
- "gmae.encoder.train()\n",
278
- "gmae.decoder.train()\n",
279
- "gmae.to(device)\n",
280
- "loss_epoch = 0\n",
281
- "for batch in myGLoader:\n",
282
- " optimizer.zero_grad()\n",
283
- " batch_g, _ = batch\n",
284
- " R = batch_g.ndata[\"R\"].to(device)\n",
285
- " Z_index = batch_g.ndata[\"Z_index\"].to(device)\n",
286
- " Z_emb = gmae.encode_atom_index(Z_index)\n",
287
- " feat = torch.cat([R,Z_emb],dim=1)\n",
288
- " batch_g = batch_g.to(device)\n",
289
- " # loss = gmae.mask_attr_prediction(batch_g, feat)\n",
290
- " # loss.backward()\n",
291
- " # optimizer.step()\n",
292
- " # loss_epoch+=loss.item()"
293
- ],
294
- "id": "224529a988b81ef5",
295
- "outputs": [
296
- {
297
- "name": "stdout",
298
- "output_type": "stream",
299
- "text": [
300
- "epoch 0 started!\n"
301
- ]
302
- },
303
- {
304
- "ename": "RuntimeError",
305
- "evalue": "CUDA error: device-side assert triggered\nCUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.\nFor debugging consider passing CUDA_LAUNCH_BLOCKING=1.\nCompile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.\n",
306
- "output_type": "error",
307
- "traceback": [
308
- "\u001B[1;31m---------------------------------------------------------------------------\u001B[0m",
309
- "\u001B[1;31mRuntimeError\u001B[0m Traceback (most recent call last)",
310
- "Cell \u001B[1;32mIn[12], line 10\u001B[0m\n\u001B[0;32m 8\u001B[0m optimizer\u001B[38;5;241m.\u001B[39mzero_grad()\n\u001B[0;32m 9\u001B[0m batch_g, _ \u001B[38;5;241m=\u001B[39m batch\n\u001B[1;32m---> 10\u001B[0m R \u001B[38;5;241m=\u001B[39m \u001B[43mbatch_g\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mndata\u001B[49m\u001B[43m[\u001B[49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[38;5;124;43mR\u001B[39;49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[43m]\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mto\u001B[49m\u001B[43m(\u001B[49m\u001B[43mdevice\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 11\u001B[0m Z_index \u001B[38;5;241m=\u001B[39m batch_g\u001B[38;5;241m.\u001B[39mndata[\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mZ_index\u001B[39m\u001B[38;5;124m\"\u001B[39m]\u001B[38;5;241m.\u001B[39mto(device)\n\u001B[0;32m 12\u001B[0m Z_emb \u001B[38;5;241m=\u001B[39m gmae\u001B[38;5;241m.\u001B[39mencode_atom_index(Z_index)\n",
311
- "\u001B[1;31mRuntimeError\u001B[0m: CUDA error: device-side assert triggered\nCUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.\nFor debugging consider passing CUDA_LAUNCH_BLOCKING=1.\nCompile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.\n"
312
- ]
313
- }
314
- ],
315
- "execution_count": 12
316
- },
317
- {
318
- "metadata": {
319
- "ExecuteTime": {
320
- "end_time": "2024-12-12T15:59:46.502050Z",
321
- "start_time": "2024-12-12T15:59:44.442506Z"
322
- }
323
- },
324
- "cell_type": "code",
325
- "source": [
326
- "from datetime import datetime\n",
327
- "\n",
328
- "current_time = datetime.now().strftime(\"%m-%d@%H_%M\")\n",
329
- "best_loss = 10000\n",
330
- "for epoch in range(epoches):\n",
331
- " print(f\"epoch {epoch} started!\")\n",
332
- " gmae.train()\n",
333
- " gmae.encoder.train()\n",
334
- " gmae.decoder.train()\n",
335
- " gmae.to(device)\n",
336
- " loss_epoch = 0\n",
337
- " for batch in myGLoader:\n",
338
- " optimizer.zero_grad()\n",
339
- " batch_g, _ = batch\n",
340
- " R = batch_g.ndata[\"R\"].to(device)\n",
341
- " Z_index = batch_g.ndata[\"Z_index\"].to(device)\n",
342
- " Z_emb = gmae.encode_atom_index(Z_index)\n",
343
- " feat = torch.cat([R,Z_emb],dim=1)\n",
344
- " batch_g = batch_g.to(device)\n",
345
- " loss = gmae.mask_attr_prediction(batch_g, feat)\n",
346
- " loss.backward()\n",
347
- " optimizer.step()\n",
348
- " loss_epoch+=loss.item()\n",
349
- " if loss_epoch < best_loss:\n",
350
- " formatted_loss_epoch = f\"{loss_epoch:.3f}\"\n",
351
- " save_path = f\"./experiments/consumption/gmae/{current_time}/gmae_epoch-{epoch}-{formatted_loss_epoch}.pt\"\n",
352
- " save_dir = os.path.dirname(save_path)\n",
353
- " if not os.path.exists(save_dir):\n",
354
- " os.makedirs(save_dir,exist_ok=True)\n",
355
- " torch.save(gmae.state_dict(), save_path)\n",
356
- " best_loss = loss_epoch\n",
357
- " print(f\"best model saved-loss:{formatted_loss_epoch}-save_path:{save_path}\")\n",
358
- " print(f\"epoch {epoch}: loss {loss_epoch}\")"
359
- ],
360
- "id": "a22599c4e591125b",
361
- "outputs": [
362
- {
363
- "name": "stdout",
364
- "output_type": "stream",
365
- "text": [
366
- "epoch 0 started!\n"
367
- ]
368
- },
369
- {
370
- "ename": "RuntimeError",
371
- "evalue": "CUDA error: device-side assert triggered\nCUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.\nFor debugging consider passing CUDA_LAUNCH_BLOCKING=1.\nCompile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.\n",
372
- "output_type": "error",
373
- "traceback": [
374
- "\u001B[1;31m---------------------------------------------------------------------------\u001B[0m",
375
- "\u001B[1;31mRuntimeError\u001B[0m Traceback (most recent call last)",
376
- "Cell \u001B[1;32mIn[18], line 19\u001B[0m\n\u001B[0;32m 17\u001B[0m Z_emb \u001B[38;5;241m=\u001B[39m gmae\u001B[38;5;241m.\u001B[39mencode_atom_index(Z_index)\n\u001B[0;32m 18\u001B[0m feat \u001B[38;5;241m=\u001B[39m torch\u001B[38;5;241m.\u001B[39mcat([R,Z_emb],dim\u001B[38;5;241m=\u001B[39m\u001B[38;5;241m1\u001B[39m)\n\u001B[1;32m---> 19\u001B[0m batch_g \u001B[38;5;241m=\u001B[39m \u001B[43mbatch_g\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mto\u001B[49m\u001B[43m(\u001B[49m\u001B[43mdevice\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 20\u001B[0m loss \u001B[38;5;241m=\u001B[39m gmae\u001B[38;5;241m.\u001B[39mmask_attr_prediction(batch_g, feat)\n\u001B[0;32m 21\u001B[0m loss\u001B[38;5;241m.\u001B[39mbackward()\n",
377
- "File \u001B[1;32mE:\\Anaconda\\envs\\gnn_course\\lib\\site-packages\\dgl\\heterograph.py:5730\u001B[0m, in \u001B[0;36mDGLGraph.to\u001B[1;34m(self, device, **kwargs)\u001B[0m\n\u001B[0;32m 5728\u001B[0m \u001B[38;5;66;03m# 2. Copy misc info\u001B[39;00m\n\u001B[0;32m 5729\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_batch_num_nodes \u001B[38;5;129;01mis\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m \u001B[38;5;28;01mNone\u001B[39;00m:\n\u001B[1;32m-> 5730\u001B[0m new_bnn \u001B[38;5;241m=\u001B[39m {\n\u001B[0;32m 5731\u001B[0m k: F\u001B[38;5;241m.\u001B[39mcopy_to(num, device, \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkwargs)\n\u001B[0;32m 5732\u001B[0m \u001B[38;5;28;01mfor\u001B[39;00m k, num \u001B[38;5;129;01min\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_batch_num_nodes\u001B[38;5;241m.\u001B[39mitems()\n\u001B[0;32m 5733\u001B[0m }\n\u001B[0;32m 5734\u001B[0m ret\u001B[38;5;241m.\u001B[39m_batch_num_nodes \u001B[38;5;241m=\u001B[39m new_bnn\n\u001B[0;32m 5735\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_batch_num_edges \u001B[38;5;129;01mis\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m \u001B[38;5;28;01mNone\u001B[39;00m:\n",
378
- "File \u001B[1;32mE:\\Anaconda\\envs\\gnn_course\\lib\\site-packages\\dgl\\heterograph.py:5731\u001B[0m, in \u001B[0;36m<dictcomp>\u001B[1;34m(.0)\u001B[0m\n\u001B[0;32m 5728\u001B[0m \u001B[38;5;66;03m# 2. Copy misc info\u001B[39;00m\n\u001B[0;32m 5729\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_batch_num_nodes \u001B[38;5;129;01mis\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m \u001B[38;5;28;01mNone\u001B[39;00m:\n\u001B[0;32m 5730\u001B[0m new_bnn \u001B[38;5;241m=\u001B[39m {\n\u001B[1;32m-> 5731\u001B[0m k: \u001B[43mF\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mcopy_to\u001B[49m\u001B[43m(\u001B[49m\u001B[43mnum\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mdevice\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[43mkwargs\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 5732\u001B[0m \u001B[38;5;28;01mfor\u001B[39;00m k, num \u001B[38;5;129;01min\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_batch_num_nodes\u001B[38;5;241m.\u001B[39mitems()\n\u001B[0;32m 5733\u001B[0m }\n\u001B[0;32m 5734\u001B[0m ret\u001B[38;5;241m.\u001B[39m_batch_num_nodes \u001B[38;5;241m=\u001B[39m new_bnn\n\u001B[0;32m 5735\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_batch_num_edges \u001B[38;5;129;01mis\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m \u001B[38;5;28;01mNone\u001B[39;00m:\n",
379
- "File \u001B[1;32mE:\\Anaconda\\envs\\gnn_course\\lib\\site-packages\\dgl\\backend\\pytorch\\tensor.py:143\u001B[0m, in \u001B[0;36mcopy_to\u001B[1;34m(input, ctx, **kwargs)\u001B[0m\n\u001B[0;32m 141\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m ctx\u001B[38;5;241m.\u001B[39mindex \u001B[38;5;129;01mis\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m \u001B[38;5;28;01mNone\u001B[39;00m:\n\u001B[0;32m 142\u001B[0m th\u001B[38;5;241m.\u001B[39mcuda\u001B[38;5;241m.\u001B[39mset_device(ctx\u001B[38;5;241m.\u001B[39mindex)\n\u001B[1;32m--> 143\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28;43minput\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mcuda\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[43mkwargs\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 144\u001B[0m \u001B[38;5;28;01melse\u001B[39;00m:\n\u001B[0;32m 145\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mRuntimeError\u001B[39;00m(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mInvalid context\u001B[39m\u001B[38;5;124m\"\u001B[39m, ctx)\n",
380
- "\u001B[1;31mRuntimeError\u001B[0m: CUDA error: device-side assert triggered\nCUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.\nFor debugging consider passing CUDA_LAUNCH_BLOCKING=1.\nCompile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.\n"
381
- ]
382
- }
383
- ],
384
- "execution_count": 18
385
- }
386
- ],
387
- "metadata": {
388
- "kernelspec": {
389
- "name": "gnn_course",
390
- "language": "python",
391
- "display_name": "gnn_course"
392
- }
393
- },
394
- "nbformat": 4,
395
- "nbformat_minor": 5
396
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.ipynb_checkpoints/Untitled-checkpoint.ipynb DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "cells": [],
3
- "metadata": {},
4
- "nbformat": 4,
5
- "nbformat_minor": 5
6
- }