{"id":4496,"date":"2022-08-15T02:26:28","date_gmt":"2022-08-15T02:26:28","guid":{"rendered":"https:\/\/www.pythontutorial.net\/?page_id=4496"},"modified":"2022-08-15T15:35:15","modified_gmt":"2022-08-15T15:35:15","slug":"numpy-broadcasting","status":"publish","type":"page","link":"https:\/\/www.pythontutorial.net\/python-numpy\/numpy-broadcasting\/","title":{"rendered":"NumPy Broadcasting"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you&#8217;ll learn about NumPy broadcasting and understand how it works.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='introduction-to-the-numpy-broadcasting'>Introduction to the NumPy broadcasting <a href=\"#introduction-to-the-numpy-broadcasting\" class=\"anchor\" id=\"introduction-to-the-numpy-broadcasting\" title=\"Anchor for Introduction to the NumPy broadcasting\">#<\/a><\/h2>\n\n\n\n<p>In previous tutorials, you learned how to perform arithmetic operations on equal-sized arrays using the <code><a href=\"https:\/\/www.pythontutorial.net\/python-numpy\/numpy-add\/\"><code>add()<\/code><\/a><\/code>, <code><a href=\"https:\/\/www.pythontutorial.net\/python-numpy\/numpy-subtract\/\"><code>subtract()<\/code><\/a><\/code>, <code><a href=\"https:\/\/www.pythontutorial.net\/python-numpy\/numpy-multiply\/\"><code>multiply()<\/code><\/a><\/code>, and <code><a href=\"https:\/\/www.pythontutorial.net\/python-numpy\/numpy-divide\/\"><code>divide()<\/code><\/a><\/code> functions or as <code>+<\/code>, <code>-<\/code>, <code>*<\/code>, and <code>\/<\/code> operators.<\/p>\n\n\n\n<p>To perform arithmetic operations on arrays of different shapes, NumPy uses a technique called broadcasting.<\/p>\n\n\n\n<p>By definition, broadcasting is a set of rules for applying arithmetic operations on arrays of different shapes. We&#8217;ll cover these rules in detail shortly.<\/p>\n\n\n\n<p>Before that, let&#8217;s take some simple broadcasting examples. For instance, you can use the + operator to add a number to an array like this:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">import<\/span> numpy <span class=\"hljs-keyword\">as<\/span> np\n\na = np.array(&#91;<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">3<\/span>])\nb = a + <span class=\"hljs-number\">1<\/span>\nprint(b)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">&#91;<span class=\"hljs-number\">2<\/span> <span class=\"hljs-number\">3<\/span> <span class=\"hljs-number\">4<\/span>]<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>This example adds the number one to a 1D array using the operator <code>+<\/code>. Internally, NumPy adds the number 1 to every element of the array. This technique is called broadcasting. <\/p>\n\n\n\n<p>In other words, NumPy broadcasts the number one across the first dimension to match the shape of the 1D array.<\/p>\n\n\n\n<p>Conceptually, you can think of the above broadcasting as equivalent to the following:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">import<\/span> numpy <span class=\"hljs-keyword\">as<\/span> np\n\na = np.array(&#91;<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">3<\/span>])\nb = a + np.array(&#91;<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">1<\/span>])\nprint(b)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>So adding the number one to a 1D array is like duplicating the number one into another 1D array [1, 1, 1] and adding that array to the array:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2022\/08\/numpy-broadcasting-1d-array.svg\" alt=\"NumPy Broadcasting\" class=\"wp-image-4499\" width=\"464\" height=\"42\"\/><\/figure>\n\n\n\n<p>However, NumPy broadcasts number one without duplicating it. By doing this, NumPy can manage effciently and speeds up calculation in most cases.<\/p>\n\n\n\n<p>Similarly, you can add a 1D array to a 2D array using broadcasting like this:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">import<\/span> numpy <span class=\"hljs-keyword\">as<\/span> np\n\na = np.array(&#91;\n    &#91;<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">3<\/span>],\n    &#91;<span class=\"hljs-number\">4<\/span>, <span class=\"hljs-number\">5<\/span>, <span class=\"hljs-number\">6<\/span>]\n])\nb = np.array(&#91;<span class=\"hljs-number\">10<\/span>, <span class=\"hljs-number\">20<\/span>, <span class=\"hljs-number\">30<\/span>])\nc = a + b\nprint(c)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">&#91;&#91;<span class=\"hljs-number\">11<\/span> <span class=\"hljs-number\">22<\/span> <span class=\"hljs-number\">33<\/span>]\n &#91;<span class=\"hljs-number\">14<\/span> <span class=\"hljs-number\">25<\/span> <span class=\"hljs-number\">36<\/span>]]<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this example, NumPy broadcasts the 1D array <code>b<\/code> across the second dimension to match the shape of the array a.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='numpy-broadcasting-rules'>NumPy broadcasting rules <a href=\"#numpy-broadcasting-rules\" class=\"anchor\" id=\"numpy-broadcasting-rules\" title=\"Anchor for NumPy broadcasting rules\">#<\/a><\/h2>\n\n\n\n<p>NumPy defines a set of rules for broadcasting:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Rule 1: if two arrays have different dimensions, it pads ones on the left side of the shape of the array that has fewer dimensions.<\/li><li>Rule 2: if two dimensions of arrays do not match in any dimension, the array with a shape equal to one in that dimension is stretched (or broadcast) to match the shape of another array.<\/li><li>Rule 3: if any dimension of two arrays is not equal and neither is equal to one, NumPy raises an error.<\/li><\/ul>\n\n\n\n<p>Let&#8217;s take some examples to understand these rules.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='1-numpy-broadcasting-on-one-array-example'>1) NumPy broadcasting on one array example <a href=\"#1-numpy-broadcasting-on-one-array-example\" class=\"anchor\" id=\"1-numpy-broadcasting-on-one-array-example\" title=\"Anchor for 1) NumPy broadcasting on one array example\">#<\/a><\/h3>\n\n\n\n<p>The following example adds a 2-D array to a 1D array:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">import<\/span> numpy <span class=\"hljs-keyword\">as<\/span> np\n\na = np.array(&#91;\n    &#91;<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">3<\/span>],\n    &#91;<span class=\"hljs-number\">4<\/span>, <span class=\"hljs-number\">5<\/span>, <span class=\"hljs-number\">6<\/span>]\n])\nb = np.ones(<span class=\"hljs-number\">3<\/span>)\nc = a + b\nprint(c)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">&#91;&#91;<span class=\"hljs-number\">2.<\/span> <span class=\"hljs-number\">3.<\/span> <span class=\"hljs-number\">4.<\/span>]\n &#91;<span class=\"hljs-number\">5.<\/span> <span class=\"hljs-number\">6.<\/span> <span class=\"hljs-number\">7.<\/span>]]<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The following table shows the shapes of a and b:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Array<\/th><th>Shape<\/th><\/tr><\/thead><tbody><tr><td>a<\/td><td>(2,3)<\/td><\/tr><tr><td>b<\/td><td>(3,)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>By rule 1, because the array b has fewer dimensions, NumPy pads one on the left:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Array<\/th><th>Shape<\/th><\/tr><\/thead><tbody><tr><td>a<\/td><td>(2,3)<\/td><\/tr><tr><td>b<\/td><td>(1,3)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>By rule 2, the first dimensions of two shapes are not equal, NumPy stretches (or broadcasts) the first dimension of the array b to match:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Array<\/th><th>Shape<\/th><\/tr><\/thead><tbody><tr><td>a<\/td><td>(2,3)<\/td><\/tr><tr><td>b<\/td><td>(2,3)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Now, the dimensions of both arrays match. The shape of the result array is (2,3).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='2-numpy-broadcasting-on-both-arrays-example'>2) NumPy broadcasting on both arrays example <a href=\"#2-numpy-broadcasting-on-both-arrays-example\" class=\"anchor\" id=\"2-numpy-broadcasting-on-both-arrays-example\" title=\"Anchor for 2) NumPy broadcasting on both arrays example\">#<\/a><\/h3>\n\n\n\n<p>The following example illustrates the case where NumPy broadcasts both arrays:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">import<\/span> numpy <span class=\"hljs-keyword\">as<\/span> np\n\na = np.array(&#91;\n    &#91;<span class=\"hljs-number\">1<\/span>],\n    &#91;<span class=\"hljs-number\">2<\/span>],\n    &#91;<span class=\"hljs-number\">3<\/span>],\n])\nprint(<span class=\"hljs-string\">f\"a shape: \"<\/span>, a.shape)\n\nb = np.array(&#91;<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">3<\/span>])\nprint(<span class=\"hljs-string\">f\"b shape: \"<\/span>, b.shape)\n\nc = a + b\nprint(c)\nprint(<span class=\"hljs-string\">f\"c shape: \"<\/span>, c.shape)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">a shape:  (<span class=\"hljs-number\">3<\/span>, <span class=\"hljs-number\">1<\/span>)\nb shape:  (<span class=\"hljs-number\">3<\/span>,)\n&#91;&#91;<span class=\"hljs-number\">2<\/span> <span class=\"hljs-number\">3<\/span> <span class=\"hljs-number\">4<\/span>]\n &#91;<span class=\"hljs-number\">3<\/span> <span class=\"hljs-number\">4<\/span> <span class=\"hljs-number\">5<\/span>]\n &#91;<span class=\"hljs-number\">4<\/span> <span class=\"hljs-number\">5<\/span> <span class=\"hljs-number\">6<\/span>]]\nc shape:  (<span class=\"hljs-number\">3<\/span>, <span class=\"hljs-number\">3<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this example, the shape of a and b arrays are (3,1) and (3,) respectively.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Array<\/th><th>Shape<\/th><\/tr><\/thead><tbody><tr><td>a<\/td><td>(3,1)<\/td><\/tr><tr><td>b<\/td><td>(3,)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>By rule 1, NumPy pads the shape of b with ones:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Array<\/th><th>Shape<\/th><\/tr><\/thead><tbody><tr><td>a<\/td><td>(3,1)<\/td><\/tr><tr><td>b<\/td><td>(1,3)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>By rule 2, NumPy stretches the dimensions of both arrays a and b to match because they&#8217;re both ones:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Array<\/th><th>Shape<\/th><\/tr><\/thead><tbody><tr><td>a<\/td><td>(3,3)<\/td><\/tr><tr><td>b<\/td><td>(3,3)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>The resulting array has the shape of (3,3).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='3-numpy-broadcasting-with-error-example'>3) NumPy broadcasting with error example <a href=\"#3-numpy-broadcasting-with-error-example\" class=\"anchor\" id=\"3-numpy-broadcasting-with-error-example\" title=\"Anchor for 3) NumPy broadcasting with error example\">#<\/a><\/h3>\n\n\n\n<p>The following example adds two arrays that are not compatible:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">import<\/span> numpy <span class=\"hljs-keyword\">as<\/span> np\n\na = np.array(&#91;\n    &#91;<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>],\n    &#91;<span class=\"hljs-number\">3<\/span>, <span class=\"hljs-number\">4<\/span>],\n    &#91;<span class=\"hljs-number\">5<\/span>, <span class=\"hljs-number\">6<\/span>],\n])\nprint(<span class=\"hljs-string\">f\"a shape: \"<\/span>, a.shape)\n\nb = np.array(&#91;<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">3<\/span>])\nprint(<span class=\"hljs-string\">f\"b shape: \"<\/span>, b.shape)\n\nc = a + b<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>It issues the following error:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">a shape:  (<span class=\"hljs-number\">3<\/span>, <span class=\"hljs-number\">2<\/span>)\nb shape:  (<span class=\"hljs-number\">3<\/span>,)\nValueError: operands could <span class=\"hljs-keyword\">not<\/span> be broadcast together <span class=\"hljs-keyword\">with<\/span> shapes (<span class=\"hljs-number\">3<\/span>,<span class=\"hljs-number\">2<\/span>) (<span class=\"hljs-number\">3<\/span>,)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this example, the array a and b have the following shapes:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Array<\/th><th>Shape<\/th><\/tr><\/thead><tbody><tr><td>a<\/td><td>(3,2)<\/td><\/tr><tr><td>b<\/td><td>(3,)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>By rule 1, NumPy pads the shape of the second array with ones:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Array<\/th><th>Shape<\/th><\/tr><\/thead><tbody><tr><td>a<\/td><td>(3,2)<\/td><\/tr><tr><td>b<\/td><td>(1,3)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>By rule 2, NumPy stretches the first dimension of the b array from 1 to 3 to match:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Array<\/th><th>Shape<\/th><\/tr><\/thead><tbody><tr><td>a<\/td><td>(3,2)<\/td><\/tr><tr><td>b<\/td><td>(3,3)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>By rule 3, the final shapes do not match, therefore, NumPy raises an error.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>NumPy broadcasting is a set of rules for applying arithmetic operations on arrays of different shapes.<\/li><\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful ?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"4496\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pythontutorial.net\/python-numpy\/numpy-broadcasting\/\"\n\t\t\t\tdata-post-title=\"NumPy Broadcasting\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"4496\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pythontutorial.net\/python-numpy\/numpy-broadcasting\/\"\n\t\t\t\tdata-post-title=\"NumPy Broadcasting\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\t\t\t<input type=\"button\" name=\"wth-submit\" class=\"wth-btn wth-btn-submit\" id=\"wth-submit\" \/>\n\t\t\t<input type=\"button\" class=\"wth-btn wth-btn-cancel\" value=\"Cancel\" \/>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you&#8217;ll learn about NumPy broadcasting and understand how it works.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":3406,"menu_order":29,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-4496","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/4496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/comments?post=4496"}],"version-history":[{"count":0,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/4496\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/3406"}],"wp:attachment":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/media?parent=4496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}