{
  "source_file": "0930",
  "source_platform": "Hashnode",
  "author": "Muhammad Fahad Bashir",
  "title_listed": "4. Logistic Regression Algorithm for Neural Network",
  "keywords": "",
  "domain": "机器学习",
  "content_type": "深度技术解析",
  "is_paid_flag": "否",
  "url": "https://mfahadbashir.hashnode.dev/4-logistic-regression-algorithm-for-neural-network",
  "publish_date": "2025-03-29",
  "corpus_stage": "",
  "notes": "",
  "id": "ed5cdeda625c",
  "collected_at": "2026-10-02T14:10:56",
  "title": "4. Logistic Regression Algorithm for Neural Network",
  "body_markdown": "4. Logistic Regression Algorithm for Neural Network\nPublished\nMarch 29, 2025\n•\n5\nmin read\n•\nView as Markdown\nM\nMuhammad Fahad Bashir\nMachine Learning, Artificial Intelligence\nPart of series\nDeep Learning Essentials\nThis is the fourth lecture of this series -\nDeep Learning Essential\ns. In this lecture, we will explore the concept of the logistic regression algorithm for neural networks. Sometimes, the ideas behind them can seem hard to grasp. To make things easier, we can use a simple algorithm called\nLogistic Regression\n.\nWhat is Logistic Regression?\nLogistic Regression is a way to solve problems where you have to pick between two choices. It helps us understand some core ideas in neural networks without getting lost in complicated details.\nLogistic Regression is a\nbinary classification\nalgorithm. Don't let the name confuse you! It's used when you only have two possible outcomes.\nFor example:\nIs a person a smoker or not?\nDo you have a certain disease, or not?\nIs an image a cat, or not?\nThese are all problems where Logistic Regression can help. It takes data and figures out which of the two outcomes is more likely.\nMany of the ideas used in Logistic Regression are also used in neural networks. This makes it a great way to learn about neural networks in a simpler way.\nUnderstanding the Basics\nTo understand Logistic Regression, we need to know some basic terms:\nInput (x):\nThis is the data we give to the algorithm.\nOutput (y):\nThis is the actual answer we are trying to predict. It can only be one of two things (0 or 1).\nTraining Examples (m):\nThese are the examples we use to teach the algorithm how to make predictions.\nCat vs. Non-Cat\nLet's use an example to make this clearer. Imagine we want to build a system that can tell if an image is a cat or not.\nInput (x):\nThe image.\nOutput (y):\n1 if the image is a cat, 0 if it is not.\nIf the system guesses \"1,\" it thinks the picture is a cat. If it guesses \"0,\" it thinks it's something else.\nIn binary classification, we often use the terms\npositive class\nand\nnegative class\n. The positive class is what we are most interested in finding. In our example, the positive class is \"cat.\" The negative class is \"not cat.\"\nHow Images Become Data\nImages are made of pixels, and each pixel has a color. Computers see colors as numbers. Each image has three color channels:\nred, green, and blue.\nTo use an image in Logistic Regression, we turn it into a long list of numbers (a\nvector\n). This vector contains all the pixel values for each color channel.\nFor example, if we have a 64x64 pixel image, the vector will have 12,288 numbers (64\n64\n3 = 12,288).\nNotation\nm\n: Number of training examples (images).\nn\n: Number of dimensions in an example (\n12,288\nfor a 64x64 image).\nx\n: Input vector (image data).\ny\n: Corresponding output label (0 or 1).\nMaking Predictions\nLogistic Regression takes the input (x) and tries to predict the output. We want to find a value called\ny-hat\n, which is our best guess for what the output should be.\nY-hat always has a value between 0 and 1. It tells us the chance that the input belongs to the positive class. In our example, it tells us the chance that the image is a cat.\nParameters: Weights and Bias\nTo make these predictions, Logistic Regression uses\nparameters.\nThese are values that the algorithm learns during training. The two main parameters are:\nWeight (w):\nA bunch of values that are adjusted to make accurate predictions.\nBias (b):\nA single number that shifts the prediction up or down.\nThink of the weight as how important that input data is. A higher weight means that the input data is more important in making an accurate prediction.\nMath Operations: Multiplication and Addition\nLogistic Regression uses only two math operations:\nmultiplication and addition.\nIt multiplies the input vector (x) by the weight vector (w) and then adds the bias (b). This gives us a single number.\nFrom Linear Regression to Logistic Regression\nThe calculation (w multiplied by x, plus b) is called\nLinear Regression\n. This calculation can result in a number that can be anywhere from very large to very small. But we need a number between 0 and 1. So, we add another step.\nWe use a function called\nSigmoid\nto squash the linear regression results into the range of 0 to 1.\nThe Sigmoid Function\nThe Sigmoid function looks like this:\nsigmoid(z) = 1 / (1 + e^(-z))\nWhere\ne\nis a mathematical constant (about 2.718), and\nz\nis the result of the linear regression calculation.\nThe Sigmoid function takes any number as input and outputs a value between 0 and 1. This value is our y-hat, which represents the probability of the input belonging to the positive class.\nHow Sigmoid Works\nLet's look at some examples:\nIf z is 0, the Sigmoid function outputs 0.5.\nIf z is a very large positive number, the Sigmoid function outputs a value close to 1.\nIf z is a very large negative number, the Sigmoid function outputs a value close to 0.\nConclusion\nLogistic Regression is a simple but effective algorithm for binary classification. It uses math operations and the Sigmoid function to make predictions. By understanding Logistic Regression, we can learn the basic concepts of neural networks in an easy way.\nReady to take your AI knowledge to the next level?\nLook for more tutorials to follow us on this journey of\nDeep Learning .\n#\ndeep-learning\n#\nneural-networks\n#\nlogistic-regression\n#\ntutorial\n#\nessential\n18\nviews",
  "metadata": {
    "title": "4. Logistic Regression Algorithm for Neural Network",
    "description": "Explore logistic regression in neural networks, key for binary classification, using simple examples and core mathematical concepts",
    "keywords": null,
    "author": null,
    "og:title": "4. Logistic Regression Algorithm for Neural Network",
    "og:description": "Explore logistic regression in neural networks, key for binary classification, using simple examples and core mathematical concepts",
    "og:url": "https://mfahadbashir.hashnode.dev/4-logistic-regression-algorithm-for-neural-network",
    "og:site_name": "Muhammad Fahad Bashir",
    "og:image": "https://cdn.hashnode.com/res/hashnode/image/upload/v1743258744617/59fbd081-7c9e-443f-912a-186a96e0f730.png",
    "og:image:width": "1200",
    "og:image:height": "630",
    "og:type": "article",
    "twitter:card": "summary_large_image",
    "twitter:title": "4. Logistic Regression Algorithm for Neural Network",
    "twitter:description": "Explore logistic regression in neural networks, key for binary classification, using simple examples and core mathematical concepts",
    "twitter:image": "https://cdn.hashnode.com/res/hashnode/image/upload/v1743258744617/59fbd081-7c9e-443f-912a-186a96e0f730.png",
    "article:published_time": "2025-03-29T14:33:28.591Z",
    "article:author": "https://mfahadbashir.hashnode.dev/@mfahadbashir"
  },
  "paywall": {
    "listed_paid": false,
    "detected": false,
    "marker": "",
    "public_only": false,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 200,
    "error": ""
  },
  "code_blocks": [
    {
      "file": "attachments/ed5cdeda625c/code/body-000.txt",
      "chars": 30,
      "language": "text"
    }
  ],
  "images": [
    {
      "status": "ok",
      "url": "https://cdn.hashnode.com/res/hashnode/image/upload/v1743258744617/59fbd081-7c9e-443f-912a-186a96e0f730.png",
      "bytes": 775992,
      "reused": true,
      "local_path": "attachments/ed5cdeda625c/images/000.png",
      "src": "https://cdn.hashnode.com/res/hashnode/image/upload/v1743258744617/59fbd081-7c9e-443f-912a-186a96e0f730.png",
      "alt": "4. Logistic Regression Algorithm for Neural Network",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://images.spiceworks.com/wp-content/uploads/2022/04/11040521/46-4-e1715636469361.png",
      "bytes": 9902,
      "reused": true,
      "local_path": "attachments/ed5cdeda625c/images/002.png",
      "src": "https://images.spiceworks.com/wp-content/uploads/2022/04/11040521/46-4-e1715636469361.png",
      "alt": "Everything You Need to Know About Logistic Regression - Spiceworks",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://blogger.googleusercontent.com/img/a/AVvXsEhEiHS16ec97wrxWbSyv91rCS2cregEVi5nymJESBdDoHqt-9WJGwBKN7_fs00L_f-WzKa7N0QQyriSk-7HtNrU5ae0rkuA5HGtl9Vlj30f9pqSbQfpZFnVDz6KkP_Fw1g3E8z3O-ATIFi7HJcFampaABqU6wYJgPzVMQi8x2TESlRPQZaiQVaAYR1HScw=w400-h225",
      "bytes": 39703,
      "reused": true,
      "local_path": "attachments/ed5cdeda625c/images/003.jpg",
      "src": "https://blogger.googleusercontent.com/img/a/AVvXsEhEiHS16ec97wrxWbSyv91rCS2cregEVi5nymJESBdDoHqt-9WJGwBKN7_fs00L_f-WzKa7N0QQyriSk-7HtNrU5ae0rkuA5HGtl9Vlj30f9pqSbQfpZFnVDz6KkP_Fw1g3E8z3O-ATIFi7HJcFampaABqU6wYJgPzVMQi8x2TESlRPQZaiQVaAYR1HScw=w400-h225",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://global.discourse-cdn.com/dlai/original/2X/7/743a6e319339e4c48b05f848334150e6ac02789a.png",
      "bytes": 72873,
      "reused": true,
      "local_path": "attachments/ed5cdeda625c/images/004.png",
      "src": "https://global.discourse-cdn.com/dlai/original/2X/7/743a6e319339e4c48b05f848334150e6ac02789a.png",
      "alt": "Image Vector Clarification - Neural Networks and Deep Learning -  DeepLearning.AI",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://carpentries-incubator.github.io/ml4bio-workshop/assets/logit_nodes.png",
      "bytes": 137149,
      "reused": true,
      "local_path": "attachments/ed5cdeda625c/images/005.png",
      "src": "https://carpentries-incubator.github.io/ml4bio-workshop/assets/logit_nodes.png",
      "alt": "Logistic Regression, Artificial Neural Networks, and Linear Separability –  Machine Learning for Biologists",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://blogger.googleusercontent.com/img/a/AVvXsEiPwX2lZAfZv8TE1VgaTbzCf-6cfi9_2mRr--UR3mmaPpI-g2nPT-43YG-2qiprk_pyhLhtBz0ud1sxAc8cPWDldzL_QRbNKIcEvtaFGmaOIr9PkKETXISu4CukTZBBZQkGuOC5Of5Uu8mwgu5qssaQWY99DDF8naiciYrJlP2en6X9Ga4jnjx73CoApL0=w400-h325",
      "bytes": 41681,
      "reused": false,
      "local_path": "attachments/ed5cdeda625c/images/body-78881a5d421868eeab2c.img",
      "src": "https://blogger.googleusercontent.com/img/a/AVvXsEiPwX2lZAfZv8TE1VgaTbzCf-6cfi9_2mRr--UR3mmaPpI-g2nPT-43YG-2qiprk_pyhLhtBz0ud1sxAc8cPWDldzL_QRbNKIcEvtaFGmaOIr9PkKETXISu4CukTZBBZQkGuOC5Of5Uu8mwgu5qssaQWY99DDF8naiciYrJlP2en6X9Ga4jnjx73CoApL0=w400-h325",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://miro.medium.com/v2/resize:fit:1036/1*AQOZAD25B9jyDgzDqfjfWg.png",
      "bytes": 144891,
      "reused": true,
      "local_path": "attachments/ed5cdeda625c/images/006.png",
      "src": "https://miro.medium.com/v2/resize:fit:1036/1*AQOZAD25B9jyDgzDqfjfWg.png",
      "alt": "Using a Logistic regression along with Neural Networks for Cat vs Non-Cat  Image Classification | by Aditi Mukerjee | Medium",
      "downloaded": true
    }
  ],
  "audio": [],
  "videos": [],
  "links": [
    {
      "href": "https://mfahadbashir.hashnode.dev/4-logistic-regression-algorithm-for-neural-network.md",
      "label": "View as Markdown",
      "type": "a"
    },
    {
      "href": "https://hashnode.com/@mfahadbashir",
      "label": "M",
      "type": "a"
    },
    {
      "href": "https://www.linkedin.com/in/muhammad-fahad-bashir-09568216a/",
      "label": "",
      "type": "a"
    },
    {
      "href": "https://mfahadbashir.hashnode.dev/series/deep-learning-essentials",
      "label": "Part of series Deep Learning Essentials",
      "type": "a"
    },
    {
      "href": "https://mfahadbashir.hashnode.dev/tag/deep-learning",
      "label": "# deep-learning",
      "type": "a"
    },
    {
      "href": "https://mfahadbashir.hashnode.dev/tag/neural-networks",
      "label": "# neural-networks",
      "type": "a"
    },
    {
      "href": "https://mfahadbashir.hashnode.dev/tag/logistic-regression",
      "label": "# logistic-regression",
      "type": "a"
    },
    {
      "href": "https://mfahadbashir.hashnode.dev/tag/tutorial",
      "label": "# tutorial",
      "type": "a"
    },
    {
      "href": "https://mfahadbashir.hashnode.dev/tag/essential",
      "label": "# essential",
      "type": "a"
    }
  ],
  "retry_at": "2026-10-03T08:08:04",
  "repair_version": 2,
  "repaired_at": "2026-10-14T10:50:43Z",
  "source_url": "https://mfahadbashir.hashnode.dev/4-logistic-regression-algorithm-for-neural-network",
  "papers": [],
  "actual_video_files": [],
  "body_chars": 5393,
  "expected_body_images": 7,
  "discovery_status": "ok",
  "delivery_status": "ok",
  "missing_reason": "",
  "raw_html": "attachments/ed5cdeda625c/pages/source.html",
  "local_html": "attachments/ed5cdeda625c/pages/article.html",
  "body_base_path": "attachments/ed5cdeda625c/pages/",
  "body_markdown_path": "attachments/ed5cdeda625c/pages/article.md"
}