{"id":36527,"date":"2024-11-01T09:49:15","date_gmt":"2024-11-01T09:49:15","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=36527"},"modified":"2024-11-01T11:52:50","modified_gmt":"2024-11-01T11:52:50","slug":"deep-learning-pytorch-course-graph-neural-networks","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/36527\/","title":{"rendered":"Deep Learning PyTorch Course, Graph Neural Networks"},"content":{"rendered":"<p><body><\/p>\n<h2>Table of Contents<\/h2>\n<ol>\n<li><a href=\"#introduction\">1. Introduction<\/a><\/li>\n<li><a href=\"#graph_neural_networks\">2. Overview of Graph Neural Networks (GNN)<\/a><\/li>\n<li><a href=\"#applications\">3. Applications of Graph Neural Networks<\/a><\/li>\n<li><a href=\"#pytorch_graph\">4. Implementing GNN in PyTorch<\/a><\/li>\n<li><a href=\"#conclusion\">5. Conclusion<\/a><\/li>\n<li><a href=\"#further_reading\">6. Further Reading<\/a><\/li>\n<\/ol>\n<h2 id=\"introduction\">1. Introduction<\/h2>\n<p>\n        In recent years, the field of deep learning has rapidly advanced due to various new research and technological developments. Among them, Graph Neural Networks (GNN) are receiving increasing attention and showing promising results in various fields. This course aims to explain the concept of GNN, how it works, and how to implement it using PyTorch. Ultimately, it aims to provide a deep understanding of the types of problems that GNN is well-suited to solve.\n    <\/p>\n<h2 id=\"graph_neural_networks\">2. Overview of Graph Neural Networks (GNN)<\/h2>\n<p>\n        Graph Neural Networks are a neural network structure based on nodes and edges in unstructured data. Unlike traditional neural networks, GNN can learn both the features and connectivity of nodes while considering the structure of the graph. GNN is primarily used for tasks such as node classification, link prediction, and graph classification.\n    <\/p>\n<h3>2.1 Basic Components of GNN<\/h3>\n<p>\n        The main components of a GNN are as follows:<\/p>\n<ul>\n<li>Node: Each point in the graph, representing an object.<\/li>\n<li>Edge: The connections between nodes, representing the relationships between them.<\/li>\n<li>Feature Vector: The information that each node or edge possesses.<\/li>\n<\/ul>\n<h3>2.2 How GNN Works<\/h3>\n<p>\n        GNN primarily operates in two stages:<\/p>\n<ol>\n<li><strong>Message Passing Stage:<\/strong> Each node receives information from neighboring nodes to update its internal state.<\/li>\n<li><strong>Node Update Stage:<\/strong> Each node updates itself based on the information received.<\/li>\n<\/ol>\n<h2 id=\"applications\">3. Applications of Graph Neural Networks<\/h2>\n<p>\n        GNN can be effectively used in various fields:<\/p>\n<ul>\n<li><strong>Social Network Analysis:<\/strong> Modeling users and their relationships to make predictions or build recommendation systems.<\/li>\n<li><strong>Chemical Substance Analysis:<\/strong> Using graph representations of molecules to predict their properties.<\/li>\n<li><strong>Knowledge Graph:<\/strong> Utilizing relationships between various pieces of information to provide answers to questions.<\/li>\n<\/ul>\n<h2 id=\"pytorch_graph\">4. Implementing GNN in PyTorch<\/h2>\n<p>\n        This section describes the process of implementing a simple graph neural network using PyTorch. We will use the PyTorch Geometric library to implement GNN.\n    <\/p>\n<h3>4.1 Environment Setup<\/h3>\n<p>\n        First, you need to install PyTorch and PyTorch Geometric. You can do this using the following commands:<\/p>\n<pre><code>pip install torch torchvision torchaudio<\/code><\/pre>\n<pre><code>pip install torch-geometric<\/code><\/pre>\n<\/p>\n<h3>4.2 Preparing the Dataset<\/h3>\n<p>\n        PyTorch Geometric provides various datasets. We will use the Cora dataset, which is a representative paper network dataset. The code to load the data is as follows:\n    <\/p>\n<pre><code>\nimport torch\nfrom torch_geometric.datasets import Planetoid\n\n# Loading the dataset\ndataset = Planetoid(root='\/tmp\/Cora', name='Cora')\ndata = dataset[0]\n    <\/code><\/pre>\n<h3>4.3 Defining the Graph Neural Network Model<\/h3>\n<p>\n        Now we will define a simple GNN model. We will use a Graph Convolutional Network (GCN) as our GNN architecture.\n    <\/p>\n<pre><code>\nimport torch.nn.functional as F\nfrom torch_geometric.nn import GCNConv\n\nclass GCN(torch.nn.Module):\n    def __init__(self, num_node_features, num_classes):\n        super(GCN, self).__init__()\n        self.conv1 = GCNConv(num_node_features, 16)\n        self.conv2 = GCNConv(16, num_classes)\n\n    def forward(self, data):\n        x, edge_index = data.x, data.edge_index\n        x = self.conv1(x, edge_index)\n        x = F.relu(x)\n        x = F.dropout(x, training=self.training)\n        x = self.conv2(x, edge_index)\n        return F.log_softmax(x, dim=1)\n    <\/code><\/pre>\n<h3>4.4 Training the Model<\/h3>\n<p>\n        Let&#8217;s look at the main steps for training the model. We will use cross-entropy loss as the loss function and choose Adam as the optimizer.\n    <\/p>\n<pre><code>\nmodel = GCN(num_node_features=dataset.num_node_features, num_classes=dataset.num_classes)\noptimizer = torch.optim.Adam(model.parameters(), lr=0.01)\nloss_fn = F.nll_loss\n\ndef train():\n    model.train()\n    optimizer.zero_grad()\n    out = model(data)\n    loss = loss_fn(out[data.train_mask], data.y[data.train_mask])\n    loss.backward()\n    optimizer.step()\n    return loss.item()\n    <\/code><\/pre>\n<h3>4.5 Evaluating the Model<\/h3>\n<p>\n        After training, the following is how to evaluate the model&#8217;s performance:\n    <\/p>\n<pre><code>\ndef test():\n    model.eval()\n    with torch.no_grad():\n        pred = model(data).argmax(dim=1)\n        correct = pred[data.test_mask].eq(data.y[data.test_mask]).sum().item()\n        acc = correct \/ data.test_mask.sum().item()\n    return acc\n\nfor epoch in range(200):\n    loss = train()\n    if epoch % 10 == 0:\n        acc = test()\n        print(f'Epoch: {epoch}, Loss: {loss:.4f}, Test Accuracy: {acc:.4f}')\n    <\/code><\/pre>\n<h2 id=\"conclusion\">5. Conclusion<\/h2>\n<p>\n        Graph Neural Networks are a valuable model that can effectively learn complex structural information from unstructured data. In this course, we examined the basic concepts and principles of GNN, as well as practical examples using PyTorch. GNN has great potential, especially in various fields such as social network analysis and chemical data modeling. We anticipate that research related to GNN will become more active, leading to the emergence of more applications in the future.\n    <\/p>\n<h2 id=\"further_reading\">6. Further Reading<\/h2>\n<ul>\n<li><a href=\"https:\/\/pytorch.org\/docs\/stable\/index.html\">Official PyTorch Documentation<\/a><\/li>\n<li><a href=\"https:\/\/pytorch-geometric.readthedocs.io\/en\/latest\/\">Official PyTorch Geometric Documentation<\/a><\/li>\n<li><a href=\"https:\/\/arxiv.org\/abs\/2002.05267\">A Comprehensive Survey on Community Detection with Deep Learning<\/a><\/li>\n<\/ul>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Table of Contents 1. Introduction 2. Overview of Graph Neural Networks (GNN) 3. Applications of Graph Neural Networks 4. Implementing GNN in PyTorch 5. Conclusion 6. Further Reading 1. Introduction In recent years, the field of deep learning has rapidly advanced due to various new research and technological developments. Among them, Graph Neural Networks (GNN) &hellip; <a href=\"https:\/\/atmokpo.com\/w\/36527\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Deep Learning PyTorch Course, Graph Neural Networks&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[149],"tags":[],"class_list":["post-36527","post","type-post","status-publish","format-standard","hentry","category-pytorch-study"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Deep Learning PyTorch Course, Graph Neural Networks - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/36527\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Deep Learning PyTorch Course, Graph Neural Networks - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Table of Contents 1. Introduction 2. Overview of Graph Neural Networks (GNN) 3. Applications of Graph Neural Networks 4. Implementing GNN in PyTorch 5. Conclusion 6. Further Reading 1. Introduction In recent years, the field of deep learning has rapidly advanced due to various new research and technological developments. Among them, Graph Neural Networks (GNN) &hellip; \ub354 \ubcf4\uae30 &quot;Deep Learning PyTorch Course, Graph Neural Networks&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/36527\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:49:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:52:50+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"4\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/36527\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/36527\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Deep Learning PyTorch Course, Graph Neural Networks\",\"datePublished\":\"2024-11-01T09:49:15+00:00\",\"dateModified\":\"2024-11-01T11:52:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/36527\/\"},\"wordCount\":534,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"PyTorch Study\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/36527\/\",\"url\":\"https:\/\/atmokpo.com\/w\/36527\/\",\"name\":\"Deep Learning PyTorch Course, Graph Neural Networks - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:49:15+00:00\",\"dateModified\":\"2024-11-01T11:52:50+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/36527\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/36527\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/36527\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Deep Learning PyTorch Course, Graph Neural Networks\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Deep Learning PyTorch Course, Graph Neural Networks - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/36527\/","og_locale":"ko_KR","og_type":"article","og_title":"Deep Learning PyTorch Course, Graph Neural Networks - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Table of Contents 1. Introduction 2. Overview of Graph Neural Networks (GNN) 3. Applications of Graph Neural Networks 4. Implementing GNN in PyTorch 5. Conclusion 6. Further Reading 1. Introduction In recent years, the field of deep learning has rapidly advanced due to various new research and technological developments. Among them, Graph Neural Networks (GNN) &hellip; \ub354 \ubcf4\uae30 \"Deep Learning PyTorch Course, Graph Neural Networks\"","og_url":"https:\/\/atmokpo.com\/w\/36527\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:49:15+00:00","article_modified_time":"2024-11-01T11:52:50+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"4\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/36527\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/36527\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Deep Learning PyTorch Course, Graph Neural Networks","datePublished":"2024-11-01T09:49:15+00:00","dateModified":"2024-11-01T11:52:50+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/36527\/"},"wordCount":534,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["PyTorch Study"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/36527\/","url":"https:\/\/atmokpo.com\/w\/36527\/","name":"Deep Learning PyTorch Course, Graph Neural Networks - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:49:15+00:00","dateModified":"2024-11-01T11:52:50+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/36527\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/36527\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/36527\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Deep Learning PyTorch Course, Graph Neural Networks"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/36527","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=36527"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/36527\/revisions"}],"predecessor-version":[{"id":36528,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/36527\/revisions\/36528"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=36527"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=36527"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=36527"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}