{"id":8,"date":"2024-08-10T15:31:18","date_gmt":"2024-08-10T15:31:18","guid":{"rendered":"https:\/\/kindsonthegenius.com\/pytorch\/?p=8"},"modified":"2024-10-18T21:40:12","modified_gmt":"2024-10-18T21:40:12","slug":"deep-learning-with-pytorch-tutorials-part-1-setup-pytorch","status":"publish","type":"post","link":"https:\/\/kindsonthegenius.com\/pytorch\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\/","title":{"rendered":"PyTorch Tutorial &#8211; Setup PyTorch"},"content":{"rendered":"<p>This is the first in the series of tutorials on Building Deep Learning Models with Pytorch. In this part we would cover the following:<\/p>\n<ol>\n<li><a href=\"#t1\">Introduction to Pytorch<\/a><\/li>\n<li><a href=\"#t2\">Setup Pytorch Locally<\/a><\/li>\n<li><a href=\"#t3\">Import the Required Modules<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h4 id=\"t1\"><strong>1. Introduction to Pytorch<\/strong><\/h4>\n<p>Pytorch is a Python library (some call it framework) developed by <a href=\"https:\/\/en.wikipedia.org\/wiki\/Meta_AI\" target=\"_blank\" rel=\"noopener\">Meta AI<\/a> used for building deep learning models.\u00a0 And you know that deep learning is a subset of machine learning. Therefore we can say that Pytorch is a tool for building advanced machine learning models.<\/p>\n<p>In conventional machine learning, we performed tasks like building classification models (classifiers), regression models etc. With Pytorch we can do more. We could build more complex models for tasks like image recognition and language processing,<\/p>\n<p>&nbsp;<\/p>\n<h4 id=\"t2\"><strong>2. Setup Pytorch Locally<\/strong><\/h4>\n<p>In this tutorial, we would be using Jupyter Notebook.<\/p>\n<p>You can setup PyTorch on Windows, Mac or Linux by running the command below:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">conda install pytorch torchvision <span style=\"color: #333333;\">-<\/span>c pytorch\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>This command may take several minutes to complete if you are installing PyTorch for the first time<\/p>\n<p>&nbsp;<\/p>\n<h4 id=\"t3\"><strong>3. Import the Required Modules<\/strong><\/h4>\n<p>We would need a number of modules including:<\/p>\n<ul>\n<li>nn &#8211; provided by PyTorch and helps you create a NeuralNetwork<\/li>\n<li>DataLoader &#8211; helps you efficiently load data for training<\/li>\n<li>datasets &#8211; from torchvision and provides us with datasets for image analysis<\/li>\n<li>ToTensor &#8211; converts an image or ndarray to PyTorch tensor and scales the values as needed.<\/li>\n<\/ul>\n<p>So add the following:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">torch<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">from<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">torch<\/span> <span style=\"color: #008800; font-weight: bold;\">import<\/span> nn\r\n<span style=\"color: #008800; font-weight: bold;\">from<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">torch.utils.data<\/span> <span style=\"color: #008800; font-weight: bold;\">import<\/span> DataLoader\r\n<span style=\"color: #008800; font-weight: bold;\">from<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">torchvision<\/span> <span style=\"color: #008800; font-weight: bold;\">import<\/span> datasets\r\n<span style=\"color: #008800; font-weight: bold;\">from<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">torchvision.transforms<\/span> <span style=\"color: #008800; font-weight: bold;\">import<\/span> ToTensor\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>In the next tutorial, we would download our training and test datasets.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is the first in the series of tutorials on Building Deep Learning Models with Pytorch. In this part we would cover the following: Introduction &hellip; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[78],"tags":[],"class_list":["post-8","post","type-post","status-publish","format-standard","hentry","category-pytorch-tutorial"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PyTorch Tutorial - Setup PyTorch - PyTorch Simplified Tutorial<\/title>\n<meta name=\"description\" content=\"This is Tutorial 1 of PyTorch tutorial for beginners. In this part, you will setup PyTorch and import required modules\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kindsonthegenius.com\/pytorch\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PyTorch Tutorial - Setup PyTorch - PyTorch Simplified Tutorial\" \/>\n<meta property=\"og:description\" content=\"This is Tutorial 1 of PyTorch tutorial for beginners. In this part, you will setup PyTorch and import required modules\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kindsonthegenius.com\/pytorch\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\/\" \/>\n<meta property=\"og:site_name\" content=\"PyTorch Simplified Tutorial\" \/>\n<meta property=\"article:published_time\" content=\"2024-08-10T15:31:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-18T21:40:12+00:00\" \/>\n<meta name=\"author\" content=\"Kindson Munonye\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kindson Munonye\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/pytorch\\\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/pytorch\\\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\\\/\"},\"author\":{\"name\":\"Kindson Munonye\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/pytorch\\\/#\\\/schema\\\/person\\\/2b1e3e1f9e5335a8493d437c3c835c66\"},\"headline\":\"PyTorch Tutorial &#8211; Setup PyTorch\",\"datePublished\":\"2024-08-10T15:31:18+00:00\",\"dateModified\":\"2024-10-18T21:40:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/pytorch\\\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\\\/\"},\"wordCount\":247,\"commentCount\":0,\"articleSection\":[\"PyTorch Tutorial\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/kindsonthegenius.com\\\/pytorch\\\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/pytorch\\\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\\\/\",\"url\":\"https:\\\/\\\/kindsonthegenius.com\\\/pytorch\\\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\\\/\",\"name\":\"PyTorch Tutorial - Setup PyTorch - PyTorch Simplified Tutorial\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/pytorch\\\/#website\"},\"datePublished\":\"2024-08-10T15:31:18+00:00\",\"dateModified\":\"2024-10-18T21:40:12+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/pytorch\\\/#\\\/schema\\\/person\\\/2b1e3e1f9e5335a8493d437c3c835c66\"},\"description\":\"This is Tutorial 1 of PyTorch tutorial for beginners. In this part, you will setup PyTorch and import required modules\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/pytorch\\\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/kindsonthegenius.com\\\/pytorch\\\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/pytorch\\\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/kindsonthegenius.com\\\/pytorch\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PyTorch Tutorial &#8211; Setup PyTorch\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/pytorch\\\/#website\",\"url\":\"https:\\\/\\\/kindsonthegenius.com\\\/pytorch\\\/\",\"name\":\"PyTorch Simplified Tutorial\",\"description\":\"Learn how to build deep learning models with Pytorch\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/kindsonthegenius.com\\\/pytorch\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/pytorch\\\/#\\\/schema\\\/person\\\/2b1e3e1f9e5335a8493d437c3c835c66\",\"name\":\"Kindson Munonye\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3b0f9291f0924a109c2372c345a86a4059732be59aad1f8795a216f0b96f855b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3b0f9291f0924a109c2372c345a86a4059732be59aad1f8795a216f0b96f855b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3b0f9291f0924a109c2372c345a86a4059732be59aad1f8795a216f0b96f855b?s=96&d=mm&r=g\",\"caption\":\"Kindson Munonye\"},\"sameAs\":[\"http:\\\/\\\/www.kindsonthegeniuscom\"],\"url\":\"https:\\\/\\\/kindsonthegenius.com\\\/pytorch\\\/author\\\/kindsonthegenius\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PyTorch Tutorial - Setup PyTorch - PyTorch Simplified Tutorial","description":"This is Tutorial 1 of PyTorch tutorial for beginners. In this part, you will setup PyTorch and import required modules","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:\/\/kindsonthegenius.com\/pytorch\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\/","og_locale":"en_US","og_type":"article","og_title":"PyTorch Tutorial - Setup PyTorch - PyTorch Simplified Tutorial","og_description":"This is Tutorial 1 of PyTorch tutorial for beginners. In this part, you will setup PyTorch and import required modules","og_url":"https:\/\/kindsonthegenius.com\/pytorch\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\/","og_site_name":"PyTorch Simplified Tutorial","article_published_time":"2024-08-10T15:31:18+00:00","article_modified_time":"2024-10-18T21:40:12+00:00","author":"Kindson Munonye","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kindson Munonye","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/kindsonthegenius.com\/pytorch\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\/#article","isPartOf":{"@id":"https:\/\/kindsonthegenius.com\/pytorch\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\/"},"author":{"name":"Kindson Munonye","@id":"https:\/\/kindsonthegenius.com\/pytorch\/#\/schema\/person\/2b1e3e1f9e5335a8493d437c3c835c66"},"headline":"PyTorch Tutorial &#8211; Setup PyTorch","datePublished":"2024-08-10T15:31:18+00:00","dateModified":"2024-10-18T21:40:12+00:00","mainEntityOfPage":{"@id":"https:\/\/kindsonthegenius.com\/pytorch\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\/"},"wordCount":247,"commentCount":0,"articleSection":["PyTorch Tutorial"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/kindsonthegenius.com\/pytorch\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/kindsonthegenius.com\/pytorch\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\/","url":"https:\/\/kindsonthegenius.com\/pytorch\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\/","name":"PyTorch Tutorial - Setup PyTorch - PyTorch Simplified Tutorial","isPartOf":{"@id":"https:\/\/kindsonthegenius.com\/pytorch\/#website"},"datePublished":"2024-08-10T15:31:18+00:00","dateModified":"2024-10-18T21:40:12+00:00","author":{"@id":"https:\/\/kindsonthegenius.com\/pytorch\/#\/schema\/person\/2b1e3e1f9e5335a8493d437c3c835c66"},"description":"This is Tutorial 1 of PyTorch tutorial for beginners. In this part, you will setup PyTorch and import required modules","breadcrumb":{"@id":"https:\/\/kindsonthegenius.com\/pytorch\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kindsonthegenius.com\/pytorch\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/kindsonthegenius.com\/pytorch\/deep-learning-with-pytorch-tutorials-part-1-setup-pytorch\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/kindsonthegenius.com\/pytorch\/"},{"@type":"ListItem","position":2,"name":"PyTorch Tutorial &#8211; Setup PyTorch"}]},{"@type":"WebSite","@id":"https:\/\/kindsonthegenius.com\/pytorch\/#website","url":"https:\/\/kindsonthegenius.com\/pytorch\/","name":"PyTorch Simplified Tutorial","description":"Learn how to build deep learning models with Pytorch","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kindsonthegenius.com\/pytorch\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/kindsonthegenius.com\/pytorch\/#\/schema\/person\/2b1e3e1f9e5335a8493d437c3c835c66","name":"Kindson Munonye","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3b0f9291f0924a109c2372c345a86a4059732be59aad1f8795a216f0b96f855b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3b0f9291f0924a109c2372c345a86a4059732be59aad1f8795a216f0b96f855b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3b0f9291f0924a109c2372c345a86a4059732be59aad1f8795a216f0b96f855b?s=96&d=mm&r=g","caption":"Kindson Munonye"},"sameAs":["http:\/\/www.kindsonthegeniuscom"],"url":"https:\/\/kindsonthegenius.com\/pytorch\/author\/kindsonthegenius\/"}]}},"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/kindsonthegenius.com\/pytorch\/wp-json\/wp\/v2\/posts\/8","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kindsonthegenius.com\/pytorch\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kindsonthegenius.com\/pytorch\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/pytorch\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/pytorch\/wp-json\/wp\/v2\/comments?post=8"}],"version-history":[{"count":6,"href":"https:\/\/kindsonthegenius.com\/pytorch\/wp-json\/wp\/v2\/posts\/8\/revisions"}],"predecessor-version":[{"id":41,"href":"https:\/\/kindsonthegenius.com\/pytorch\/wp-json\/wp\/v2\/posts\/8\/revisions\/41"}],"wp:attachment":[{"href":"https:\/\/kindsonthegenius.com\/pytorch\/wp-json\/wp\/v2\/media?parent=8"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/pytorch\/wp-json\/wp\/v2\/categories?post=8"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/pytorch\/wp-json\/wp\/v2\/tags?post=8"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}