[{"data":1,"prerenderedAt":2394},["ShallowReactive",2],{"lang-switch-post-\u002Fen\u002Fplaylists\u002Fmachine-learning-specialization\u002Fw3-lab06-gradient-descent":3,"post-en-machine-learning-specialization-w3-lab06-gradient-descent":4},"\u002Fplaylists\u002Fmachine-learning-specialization\u002Fw3-lab06-gradient-descent",{"id":5,"title":6,"body":7,"cover":2378,"date":2379,"description":2380,"extension":2381,"meta":2382,"navigation":1870,"order":2383,"path":2384,"playlist":2385,"seo":2386,"status":2387,"stem":2388,"tags":2389,"__hash__":2393},"posts\u002Fen\u002Fplaylists\u002Fmachine-learning-specialization\u002Fw3-lab06-gradient-descent.md","Gradient Descent Didn't Need to Learn Anything New",{"type":8,"value":9,"toc":2370},"minimark",[10,38,43,606,618,1806,1827,1831,1931,1980,1991,2011,2027,2031,2098,2121,2128,2150,2161,2173,2180,2184,2196,2211,2226,2234,2241,2245,2298,2302,2318,2324,2366],[11,12,13,14,19,20,24,25,28,29,33,34,37],"p",{},"Back in Week 1, gradient descent for linear regression was: compute the gradient, take a step, repeat. ",[15,16,18],"a",{"href":17},"\u002Fen\u002Fplaylists\u002Fmachine-learning-specialization\u002Fw3-lab05-cost-function","The code by now"," already has sigmoid, decision boundary, logistic loss and cost ready to go. One thing's missing: running gradient descent on top of that new cost to find the ",[21,22,23],"code",{},"w"," and ",[21,26,27],{},"b"," that minimize it. And here's the satisfying part of this chapter: the loop that takes the steps is ",[30,31,32],"strong",{},"literally the same one",". Only the math inside the loop (the gradient) changes, because ",[21,35,36],{},"f"," swapped from a line to a sigmoid.",[39,40,42],"h2",{"id":41},"the-loop-doesnt-change-only-what-it-derives","The loop doesn't change, only what it derives",[11,44,45],{},[46,47,50,170],"span",{"className":48},[49],"katex",[46,51,54],{"className":52},[53],"katex-mathml",[55,56,58],"math",{"xmlns":57},"http:\u002F\u002Fwww.w3.org\u002F1998\u002FMath\u002FMathML",[59,60,61,165],"semantics",{},[62,63,64,73,77,83,86,89,127,131,133,135,137,139,141],"mrow",{},[65,66,67,70],"msub",{},[68,69,23],"mi",{},[68,71,72],{},"j",[74,75,76],"mo",{},"=",[65,78,79,81],{},[68,80,23],{},[68,82,72],{},[74,84,85],{},"−",[68,87,88],{},"α",[90,91,92,117],"mfrac",{},[62,93,94,98,101,105,108,112,114],{},[68,95,97],{"mathvariant":96},"normal","∂",[68,99,100],{},"J",[74,102,104],{"stretchy":103},"false","(",[68,106,23],{"mathvariant":107},"bold",[74,109,111],{"separator":110},"true",",",[68,113,27],{},[74,115,116],{"stretchy":103},")",[62,118,119,121],{},[68,120,97],{"mathvariant":96},[65,122,123,125],{},[68,124,23],{},[68,126,72],{},[128,129],"mspace",{"width":130},"2em",[68,132,27],{},[74,134,76],{},[68,136,27],{},[74,138,85],{},[68,140,88],{},[90,142,143,159],{},[62,144,145,147,149,151,153,155,157],{},[68,146,97],{"mathvariant":96},[68,148,100],{},[74,150,104],{"stretchy":103},[68,152,23],{"mathvariant":107},[74,154,111],{"separator":110},[68,156,27],{},[74,158,116],{"stretchy":103},[62,160,161,163],{},[68,162,97],{"mathvariant":96},[68,164,27],{},[166,167,169],"annotation",{"encoding":168},"application\u002Fx-tex","w_j = w_j - \\alpha \\frac{\\partial J(\\mathbf{w},b)}{\\partial w_j} \\qquad b = b - \\alpha \\frac{\\partial J(\\mathbf{w},b)}{\\partial b}",[46,171,174,254,312,487,506],{"className":172,"ariaHidden":110},[173],"katex-html",[46,175,178,183,243,247,251],{"className":176},[177],"base",[46,179],{"className":180,"style":182},[181],"strut","height:0.7167em;vertical-align:-0.2861em;",[46,184,187,192],{"className":185},[186],"mord",[46,188,23],{"className":189,"style":191},[186,190],"mathnormal","margin-right:0.0269em;",[46,193,196],{"className":194},[195],"msupsub",[46,197,201,234],{"className":198},[199,200],"vlist-t","vlist-t2",[46,202,205,229],{"className":203},[204],"vlist-r",[46,206,210],{"className":207,"style":209},[208],"vlist","height:0.3117em;",[46,211,213,218],{"style":212},"top:-2.55em;margin-left:-0.0269em;margin-right:0.05em;",[46,214],{"className":215,"style":217},[216],"pstrut","height:2.7em;",[46,219,225],{"className":220},[221,222,223,224],"sizing","reset-size6","size3","mtight",[46,226,72],{"className":227,"style":228},[186,190,224],"margin-right:0.0572em;",[46,230,233],{"className":231},[232],"vlist-s","​",[46,235,237],{"className":236},[204],[46,238,241],{"className":239,"style":240},[208],"height:0.2861em;",[46,242],{},[46,244],{"className":245,"style":246},[128],"margin-right:0.2778em;",[46,248,76],{"className":249},[250],"mrel",[46,252],{"className":253,"style":246},[128],[46,255,257,261,301,305,309],{"className":256},[177],[46,258],{"className":259,"style":260},[181],"height:0.8694em;vertical-align:-0.2861em;",[46,262,264,267],{"className":263},[186],[46,265,23],{"className":266,"style":191},[186,190],[46,268,270],{"className":269},[195],[46,271,273,293],{"className":272},[199,200],[46,274,276,290],{"className":275},[204],[46,277,279],{"className":278,"style":209},[208],[46,280,281,284],{"style":212},[46,282],{"className":283,"style":217},[216],[46,285,287],{"className":286},[221,222,223,224],[46,288,72],{"className":289,"style":228},[186,190,224],[46,291,233],{"className":292},[232],[46,294,296],{"className":295},[204],[46,297,299],{"className":298,"style":240},[208],[46,300],{},[46,302],{"className":303,"style":304},[128],"margin-right:0.2222em;",[46,306,85],{"className":307},[308],"mbin",[46,310],{"className":311,"style":304},[128],[46,313,315,319,323,471,475,478,481,484],{"className":314},[177],[46,316],{"className":317,"style":318},[181],"height:1.5523em;vertical-align:-0.5423em;",[46,320,88],{"className":321,"style":322},[186,190],"margin-right:0.0037em;",[46,324,326,331,468],{"className":325},[186],[46,327],{"className":328},[329,330],"mopen","nulldelimiter",[46,332,334],{"className":333},[90],[46,335,337,459],{"className":336},[199,200],[46,338,340,456],{"className":339},[204],[46,341,344,407,418],{"className":342,"style":343},[208],"height:1.01em;",[46,345,347,351],{"style":346},"top:-2.655em;",[46,348],{"className":349,"style":350},[216],"height:3em;",[46,352,354],{"className":353},[221,222,223,224],[46,355,357,361],{"className":356},[186,224],[46,358,97],{"className":359,"style":360},[186,224],"margin-right:0.0556em;",[46,362,364,367],{"className":363},[186,224],[46,365,23],{"className":366,"style":191},[186,190,224],[46,368,370],{"className":369},[195],[46,371,373,398],{"className":372},[199,200],[46,374,376,395],{"className":375},[204],[46,377,380],{"className":378,"style":379},[208],"height:0.3281em;",[46,381,383,387],{"style":382},"top:-2.357em;margin-left:-0.0269em;margin-right:0.0714em;",[46,384],{"className":385,"style":386},[216],"height:2.5em;",[46,388,392],{"className":389},[221,390,391,224],"reset-size3","size1",[46,393,72],{"className":394,"style":228},[186,190,224],[46,396,233],{"className":397},[232],[46,399,401],{"className":400},[204],[46,402,405],{"className":403,"style":404},[208],"height:0.2819em;",[46,406],{},[46,408,410,413],{"style":409},"top:-3.23em;",[46,411],{"className":412,"style":350},[216],[46,414],{"className":415,"style":417},[416],"frac-line","border-bottom-width:0.04em;",[46,419,421,424],{"style":420},"top:-3.485em;",[46,422],{"className":423,"style":350},[216],[46,425,427],{"className":426},[221,222,223,224],[46,428,430,433,437,440,445,449,452],{"className":429},[186,224],[46,431,97],{"className":432,"style":360},[186,224],[46,434,100],{"className":435,"style":436},[186,190,224],"margin-right:0.0962em;",[46,438,104],{"className":439},[329,224],[46,441,23],{"className":442,"style":444},[186,443,224],"mathbf","margin-right:0.016em;",[46,446,111],{"className":447},[448,224],"mpunct",[46,450,27],{"className":451},[186,190,224],[46,453,116],{"className":454},[455,224],"mclose",[46,457,233],{"className":458},[232],[46,460,462],{"className":461},[204],[46,463,466],{"className":464,"style":465},[208],"height:0.5423em;",[46,467],{},[46,469],{"className":470},[455,330],[46,472],{"className":473,"style":474},[128],"margin-right:2em;",[46,476,27],{"className":477},[186,190],[46,479],{"className":480,"style":246},[128],[46,482,76],{"className":483},[250],[46,485],{"className":486,"style":246},[128],[46,488,490,494,497,500,503],{"className":489},[177],[46,491],{"className":492,"style":493},[181],"height:0.7778em;vertical-align:-0.0833em;",[46,495,27],{"className":496},[186,190],[46,498],{"className":499,"style":304},[128],[46,501,85],{"className":502},[308],[46,504],{"className":505,"style":304},[128],[46,507,509,513,516],{"className":508},[177],[46,510],{"className":511,"style":512},[181],"height:1.355em;vertical-align:-0.345em;",[46,514,88],{"className":515,"style":322},[186,190],[46,517,519,522,603],{"className":518},[186],[46,520],{"className":521},[329,330],[46,523,525],{"className":524},[90],[46,526,528,594],{"className":527},[199,200],[46,529,531,591],{"className":530},[204],[46,532,534,551,559],{"className":533,"style":343},[208],[46,535,536,539],{"style":346},[46,537],{"className":538,"style":350},[216],[46,540,542],{"className":541},[221,222,223,224],[46,543,545,548],{"className":544},[186,224],[46,546,97],{"className":547,"style":360},[186,224],[46,549,27],{"className":550},[186,190,224],[46,552,553,556],{"style":409},[46,554],{"className":555,"style":350},[216],[46,557],{"className":558,"style":417},[416],[46,560,561,564],{"style":420},[46,562],{"className":563,"style":350},[216],[46,565,567],{"className":566},[221,222,223,224],[46,568,570,573,576,579,582,585,588],{"className":569},[186,224],[46,571,97],{"className":572,"style":360},[186,224],[46,574,100],{"className":575,"style":436},[186,190,224],[46,577,104],{"className":578},[329,224],[46,580,23],{"className":581,"style":444},[186,443,224],[46,583,111],{"className":584},[448,224],[46,586,27],{"className":587},[186,190,224],[46,589,116],{"className":590},[455,224],[46,592,233],{"className":593},[232],[46,595,597],{"className":596},[204],[46,598,601],{"className":599,"style":600},[208],"height:0.345em;",[46,602],{},[46,604],{"className":605},[455,330],[11,607,608,609,612,613,24,615,617],{},"Same recipe as always: take the gradient, step in the opposite direction by ",[21,610,611],{},"alpha"," (updating ",[21,614,23],{},[21,616,27],{}," at the same time), repeat until it stops improving. And the partial derivatives have the same familiar shape too:",[11,619,620],{},[46,621,623,863],{"className":622},[49],[46,624,626],{"className":625},[53],[55,627,628],{"xmlns":57},[59,629,630,860],{},[62,631,632,660,662,671,695,697,709,711,725,727,729,742,744,758,760,762,786,788,794,814,816,828,830,842,844,846,858],{},[90,633,634,650],{},[62,635,636,638,640,642,644,646,648],{},[68,637,97],{"mathvariant":96},[68,639,100],{},[74,641,104],{"stretchy":103},[68,643,23],{"mathvariant":107},[74,645,111],{"separator":110},[68,647,27],{},[74,649,116],{"stretchy":103},[62,651,652,654],{},[68,653,97],{"mathvariant":96},[65,655,656,658],{},[68,657,23],{},[68,659,72],{},[74,661,76],{},[90,663,664,668],{},[665,666,667],"mn",{},"1",[68,669,670],{},"m",[672,673,674,677,687],"msubsup",{},[74,675,676],{},"∑",[62,678,679,682,684],{},[68,680,681],{},"i",[74,683,76],{},[665,685,686],{},"0",[62,688,689,691,693],{},[68,690,670],{},[74,692,85],{},[665,694,667],{},[74,696,104],{"stretchy":103},[65,698,699,701],{},[68,700,36],{},[62,702,703,705,707],{},[68,704,23],{"mathvariant":107},[74,706,111],{"separator":110},[68,708,27],{},[74,710,104],{"stretchy":103},[712,713,714,717],"msup",{},[68,715,716],{"mathvariant":107},"x",[62,718,719,721,723],{},[74,720,104],{"stretchy":103},[68,722,681],{},[74,724,116],{"stretchy":103},[74,726,116],{"stretchy":103},[74,728,85],{},[712,730,731,734],{},[68,732,733],{},"y",[62,735,736,738,740],{},[74,737,104],{"stretchy":103},[68,739,681],{},[74,741,116],{"stretchy":103},[74,743,116],{"stretchy":103},[672,745,746,748,750],{},[68,747,716],{},[68,749,72],{},[62,751,752,754,756],{},[74,753,104],{"stretchy":103},[68,755,681],{},[74,757,116],{"stretchy":103},[74,759,111],{"separator":110},[128,761],{"width":130},[90,763,764,780],{},[62,765,766,768,770,772,774,776,778],{},[68,767,97],{"mathvariant":96},[68,769,100],{},[74,771,104],{"stretchy":103},[68,773,23],{"mathvariant":107},[74,775,111],{"separator":110},[68,777,27],{},[74,779,116],{"stretchy":103},[62,781,782,784],{},[68,783,97],{"mathvariant":96},[68,785,27],{},[74,787,76],{},[90,789,790,792],{},[665,791,667],{},[68,793,670],{},[672,795,796,798,806],{},[74,797,676],{},[62,799,800,802,804],{},[68,801,681],{},[74,803,76],{},[665,805,686],{},[62,807,808,810,812],{},[68,809,670],{},[74,811,85],{},[665,813,667],{},[74,815,104],{"stretchy":103},[65,817,818,820],{},[68,819,36],{},[62,821,822,824,826],{},[68,823,23],{"mathvariant":107},[74,825,111],{"separator":110},[68,827,27],{},[74,829,104],{"stretchy":103},[712,831,832,834],{},[68,833,716],{"mathvariant":107},[62,835,836,838,840],{},[74,837,104],{"stretchy":103},[68,839,681],{},[74,841,116],{"stretchy":103},[74,843,116],{"stretchy":103},[74,845,85],{},[712,847,848,850],{},[68,849,733],{},[62,851,852,854,856],{},[74,853,104],{"stretchy":103},[68,855,681],{},[74,857,116],{"stretchy":103},[74,859,116],{"stretchy":103},[166,861,862],{"encoding":168},"\\frac{\\partial J(\\mathbf{w},b)}{\\partial w_j}  = \\frac{1}{m} \\sum\\limits_{i = 0}^{m-1} (f_{\\mathbf{w},b}(\\mathbf{x}^{(i)}) - y^{(i)})x_{j}^{(i)}, \\qquad \\frac{\\partial J(\\mathbf{w},b)}{\\partial b}  = \\frac{1}{m} \\sum\\limits_{i = 0}^{m-1} (f_{\\mathbf{w},b}(\\mathbf{x}^{(i)}) - y^{(i)})",[46,864,866,1007,1280,1503,1758],{"className":865,"ariaHidden":110},[173],[46,867,869,872,998,1001,1004],{"className":868},[177],[46,870],{"className":871,"style":318},[181],[46,873,875,878,995],{"className":874},[186],[46,876],{"className":877},[329,330],[46,879,881],{"className":880},[90],[46,882,884,987],{"className":883},[199,200],[46,885,887,984],{"className":886},[204],[46,888,890,944,952],{"className":889,"style":343},[208],[46,891,892,895],{"style":346},[46,893],{"className":894,"style":350},[216],[46,896,898],{"className":897},[221,222,223,224],[46,899,901,904],{"className":900},[186,224],[46,902,97],{"className":903,"style":360},[186,224],[46,905,907,910],{"className":906},[186,224],[46,908,23],{"className":909,"style":191},[186,190,224],[46,911,913],{"className":912},[195],[46,914,916,936],{"className":915},[199,200],[46,917,919,933],{"className":918},[204],[46,920,922],{"className":921,"style":379},[208],[46,923,924,927],{"style":382},[46,925],{"className":926,"style":386},[216],[46,928,930],{"className":929},[221,390,391,224],[46,931,72],{"className":932,"style":228},[186,190,224],[46,934,233],{"className":935},[232],[46,937,939],{"className":938},[204],[46,940,942],{"className":941,"style":404},[208],[46,943],{},[46,945,946,949],{"style":409},[46,947],{"className":948,"style":350},[216],[46,950],{"className":951,"style":417},[416],[46,953,954,957],{"style":420},[46,955],{"className":956,"style":350},[216],[46,958,960],{"className":959},[221,222,223,224],[46,961,963,966,969,972,975,978,981],{"className":962},[186,224],[46,964,97],{"className":965,"style":360},[186,224],[46,967,100],{"className":968,"style":436},[186,190,224],[46,970,104],{"className":971},[329,224],[46,973,23],{"className":974,"style":444},[186,443,224],[46,976,111],{"className":977},[448,224],[46,979,27],{"className":980},[186,190,224],[46,982,116],{"className":983},[455,224],[46,985,233],{"className":986},[232],[46,988,990],{"className":989},[204],[46,991,993],{"className":992,"style":465},[208],[46,994],{},[46,996],{"className":997},[455,330],[46,999],{"className":1000,"style":246},[128],[46,1002,76],{"className":1003},[250],[46,1005],{"className":1006,"style":246},[128],[46,1008,1010,1014,1084,1088,1170,1173,1225,1228,1268,1271,1274,1277],{"className":1009},[177],[46,1011],{"className":1012,"style":1013},[181],"height:2.4788em;vertical-align:-0.9777em;",[46,1015,1017,1020,1081],{"className":1016},[186],[46,1018],{"className":1019},[329,330],[46,1021,1023],{"className":1022},[90],[46,1024,1026,1073],{"className":1025},[199,200],[46,1027,1029,1070],{"className":1028},[204],[46,1030,1033,1047,1055],{"className":1031,"style":1032},[208],"height:0.8451em;",[46,1034,1035,1038],{"style":346},[46,1036],{"className":1037,"style":350},[216],[46,1039,1041],{"className":1040},[221,222,223,224],[46,1042,1044],{"className":1043},[186,224],[46,1045,670],{"className":1046},[186,190,224],[46,1048,1049,1052],{"style":409},[46,1050],{"className":1051,"style":350},[216],[46,1053],{"className":1054,"style":417},[416],[46,1056,1058,1061],{"style":1057},"top:-3.394em;",[46,1059],{"className":1060,"style":350},[216],[46,1062,1064],{"className":1063},[221,222,223,224],[46,1065,1067],{"className":1066},[186,224],[46,1068,667],{"className":1069},[186,224],[46,1071,233],{"className":1072},[232],[46,1074,1076],{"className":1075},[204],[46,1077,1079],{"className":1078,"style":600},[208],[46,1080],{},[46,1082],{"className":1083},[455,330],[46,1085],{"className":1086,"style":1087},[128],"margin-right:0.1667em;",[46,1089,1093],{"className":1090},[1091,1092],"mop","op-limits",[46,1094,1096,1161],{"className":1095},[199,200],[46,1097,1099,1158],{"className":1098},[204],[46,1100,1103,1124,1137],{"className":1101,"style":1102},[208],"height:1.5011em;",[46,1104,1106,1109],{"style":1105},"top:-2.1223em;margin-left:0em;",[46,1107],{"className":1108,"style":350},[216],[46,1110,1112],{"className":1111},[221,222,223,224],[46,1113,1115,1118,1121],{"className":1114},[186,224],[46,1116,681],{"className":1117},[186,190,224],[46,1119,76],{"className":1120},[250,224],[46,1122,686],{"className":1123},[186,224],[46,1125,1127,1130],{"style":1126},"top:-3em;",[46,1128],{"className":1129,"style":350},[216],[46,1131,1132],{},[46,1133,676],{"className":1134},[1091,1135,1136],"op-symbol","small-op",[46,1138,1140,1143],{"style":1139},"top:-3.95em;margin-left:0em;",[46,1141],{"className":1142,"style":350},[216],[46,1144,1146],{"className":1145},[221,222,223,224],[46,1147,1149,1152,1155],{"className":1148},[186,224],[46,1150,670],{"className":1151},[186,190,224],[46,1153,85],{"className":1154},[308,224],[46,1156,667],{"className":1157},[186,224],[46,1159,233],{"className":1160},[232],[46,1162,1164],{"className":1163},[204],[46,1165,1168],{"className":1166,"style":1167},[208],"height:0.9777em;",[46,1169],{},[46,1171,104],{"className":1172},[329],[46,1174,1176,1180],{"className":1175},[186],[46,1177,36],{"className":1178,"style":1179},[186,190],"margin-right:0.1076em;",[46,1181,1183],{"className":1182},[195],[46,1184,1186,1217],{"className":1185},[199,200],[46,1187,1189,1214],{"className":1188},[204],[46,1190,1193],{"className":1191,"style":1192},[208],"height:0.3361em;",[46,1194,1196,1199],{"style":1195},"top:-2.55em;margin-left:-0.1076em;margin-right:0.05em;",[46,1197],{"className":1198,"style":217},[216],[46,1200,1202],{"className":1201},[221,222,223,224],[46,1203,1205,1208,1211],{"className":1204},[186,224],[46,1206,23],{"className":1207,"style":444},[186,443,224],[46,1209,111],{"className":1210},[448,224],[46,1212,27],{"className":1213},[186,190,224],[46,1215,233],{"className":1216},[232],[46,1218,1220],{"className":1219},[204],[46,1221,1223],{"className":1222,"style":240},[208],[46,1224],{},[46,1226,104],{"className":1227},[329],[46,1229,1231,1234],{"className":1230},[186],[46,1232,716],{"className":1233},[186,443],[46,1235,1237],{"className":1236},[195],[46,1238,1240],{"className":1239},[199],[46,1241,1243],{"className":1242},[204],[46,1244,1247],{"className":1245,"style":1246},[208],"height:0.888em;",[46,1248,1250,1253],{"style":1249},"top:-3.063em;margin-right:0.05em;",[46,1251],{"className":1252,"style":217},[216],[46,1254,1256],{"className":1255},[221,222,223,224],[46,1257,1259,1262,1265],{"className":1258},[186,224],[46,1260,104],{"className":1261},[329,224],[46,1263,681],{"className":1264},[186,190,224],[46,1266,116],{"className":1267},[455,224],[46,1269,116],{"className":1270},[455],[46,1272],{"className":1273,"style":304},[128],[46,1275,85],{"className":1276},[308],[46,1278],{"className":1279,"style":304},[128],[46,1281,1283,1287,1326,1329,1396,1399,1402,1405,1494,1497,1500],{"className":1282},[177],[46,1284],{"className":1285,"style":1286},[181],"height:1.4578em;vertical-align:-0.413em;",[46,1288,1290,1294],{"className":1289},[186],[46,1291,733],{"className":1292,"style":1293},[186,190],"margin-right:0.0359em;",[46,1295,1297],{"className":1296},[195],[46,1298,1300],{"className":1299},[199],[46,1301,1303],{"className":1302},[204],[46,1304,1306],{"className":1305,"style":1246},[208],[46,1307,1308,1311],{"style":1249},[46,1309],{"className":1310,"style":217},[216],[46,1312,1314],{"className":1313},[221,222,223,224],[46,1315,1317,1320,1323],{"className":1316},[186,224],[46,1318,104],{"className":1319},[329,224],[46,1321,681],{"className":1322},[186,190,224],[46,1324,116],{"className":1325},[455,224],[46,1327,116],{"className":1328},[455],[46,1330,1332,1335],{"className":1331},[186],[46,1333,716],{"className":1334},[186,190],[46,1336,1338],{"className":1337},[195],[46,1339,1341,1387],{"className":1340},[199,200],[46,1342,1344,1384],{"className":1343},[204],[46,1345,1348,1363],{"className":1346,"style":1347},[208],"height:1.0448em;",[46,1349,1351,1354],{"style":1350},"top:-2.4231em;margin-left:0em;margin-right:0.05em;",[46,1352],{"className":1353,"style":217},[216],[46,1355,1357],{"className":1356},[221,222,223,224],[46,1358,1360],{"className":1359},[186,224],[46,1361,72],{"className":1362,"style":228},[186,190,224],[46,1364,1366,1369],{"style":1365},"top:-3.2198em;margin-right:0.05em;",[46,1367],{"className":1368,"style":217},[216],[46,1370,1372],{"className":1371},[221,222,223,224],[46,1373,1375,1378,1381],{"className":1374},[186,224],[46,1376,104],{"className":1377},[329,224],[46,1379,681],{"className":1380},[186,190,224],[46,1382,116],{"className":1383},[455,224],[46,1385,233],{"className":1386},[232],[46,1388,1390],{"className":1389},[204],[46,1391,1394],{"className":1392,"style":1393},[208],"height:0.413em;",[46,1395],{},[46,1397,111],{"className":1398},[448],[46,1400],{"className":1401,"style":474},[128],[46,1403],{"className":1404,"style":1087},[128],[46,1406,1408,1411,1491],{"className":1407},[186],[46,1409],{"className":1410},[329,330],[46,1412,1414],{"className":1413},[90],[46,1415,1417,1483],{"className":1416},[199,200],[46,1418,1420,1480],{"className":1419},[204],[46,1421,1423,1440,1448],{"className":1422,"style":343},[208],[46,1424,1425,1428],{"style":346},[46,1426],{"className":1427,"style":350},[216],[46,1429,1431],{"className":1430},[221,222,223,224],[46,1432,1434,1437],{"className":1433},[186,224],[46,1435,97],{"className":1436,"style":360},[186,224],[46,1438,27],{"className":1439},[186,190,224],[46,1441,1442,1445],{"style":409},[46,1443],{"className":1444,"style":350},[216],[46,1446],{"className":1447,"style":417},[416],[46,1449,1450,1453],{"style":420},[46,1451],{"className":1452,"style":350},[216],[46,1454,1456],{"className":1455},[221,222,223,224],[46,1457,1459,1462,1465,1468,1471,1474,1477],{"className":1458},[186,224],[46,1460,97],{"className":1461,"style":360},[186,224],[46,1463,100],{"className":1464,"style":436},[186,190,224],[46,1466,104],{"className":1467},[329,224],[46,1469,23],{"className":1470,"style":444},[186,443,224],[46,1472,111],{"className":1473},[448,224],[46,1475,27],{"className":1476},[186,190,224],[46,1478,116],{"className":1479},[455,224],[46,1481,233],{"className":1482},[232],[46,1484,1486],{"className":1485},[204],[46,1487,1489],{"className":1488,"style":600},[208],[46,1490],{},[46,1492],{"className":1493},[455,330],[46,1495],{"className":1496,"style":246},[128],[46,1498,76],{"className":1499},[250],[46,1501],{"className":1502,"style":246},[128],[46,1504,1506,1509,1577,1580,1653,1656,1705,1708,1746,1749,1752,1755],{"className":1505},[177],[46,1507],{"className":1508,"style":1013},[181],[46,1510,1512,1515,1574],{"className":1511},[186],[46,1513],{"className":1514},[329,330],[46,1516,1518],{"className":1517},[90],[46,1519,1521,1566],{"className":1520},[199,200],[46,1522,1524,1563],{"className":1523},[204],[46,1525,1527,1541,1549],{"className":1526,"style":1032},[208],[46,1528,1529,1532],{"style":346},[46,1530],{"className":1531,"style":350},[216],[46,1533,1535],{"className":1534},[221,222,223,224],[46,1536,1538],{"className":1537},[186,224],[46,1539,670],{"className":1540},[186,190,224],[46,1542,1543,1546],{"style":409},[46,1544],{"className":1545,"style":350},[216],[46,1547],{"className":1548,"style":417},[416],[46,1550,1551,1554],{"style":1057},[46,1552],{"className":1553,"style":350},[216],[46,1555,1557],{"className":1556},[221,222,223,224],[46,1558,1560],{"className":1559},[186,224],[46,1561,667],{"className":1562},[186,224],[46,1564,233],{"className":1565},[232],[46,1567,1569],{"className":1568},[204],[46,1570,1572],{"className":1571,"style":600},[208],[46,1573],{},[46,1575],{"className":1576},[455,330],[46,1578],{"className":1579,"style":1087},[128],[46,1581,1583],{"className":1582},[1091,1092],[46,1584,1586,1645],{"className":1585},[199,200],[46,1587,1589,1642],{"className":1588},[204],[46,1590,1592,1612,1622],{"className":1591,"style":1102},[208],[46,1593,1594,1597],{"style":1105},[46,1595],{"className":1596,"style":350},[216],[46,1598,1600],{"className":1599},[221,222,223,224],[46,1601,1603,1606,1609],{"className":1602},[186,224],[46,1604,681],{"className":1605},[186,190,224],[46,1607,76],{"className":1608},[250,224],[46,1610,686],{"className":1611},[186,224],[46,1613,1614,1617],{"style":1126},[46,1615],{"className":1616,"style":350},[216],[46,1618,1619],{},[46,1620,676],{"className":1621},[1091,1135,1136],[46,1623,1624,1627],{"style":1139},[46,1625],{"className":1626,"style":350},[216],[46,1628,1630],{"className":1629},[221,222,223,224],[46,1631,1633,1636,1639],{"className":1632},[186,224],[46,1634,670],{"className":1635},[186,190,224],[46,1637,85],{"className":1638},[308,224],[46,1640,667],{"className":1641},[186,224],[46,1643,233],{"className":1644},[232],[46,1646,1648],{"className":1647},[204],[46,1649,1651],{"className":1650,"style":1167},[208],[46,1652],{},[46,1654,104],{"className":1655},[329],[46,1657,1659,1662],{"className":1658},[186],[46,1660,36],{"className":1661,"style":1179},[186,190],[46,1663,1665],{"className":1664},[195],[46,1666,1668,1697],{"className":1667},[199,200],[46,1669,1671,1694],{"className":1670},[204],[46,1672,1674],{"className":1673,"style":1192},[208],[46,1675,1676,1679],{"style":1195},[46,1677],{"className":1678,"style":217},[216],[46,1680,1682],{"className":1681},[221,222,223,224],[46,1683,1685,1688,1691],{"className":1684},[186,224],[46,1686,23],{"className":1687,"style":444},[186,443,224],[46,1689,111],{"className":1690},[448,224],[46,1692,27],{"className":1693},[186,190,224],[46,1695,233],{"className":1696},[232],[46,1698,1700],{"className":1699},[204],[46,1701,1703],{"className":1702,"style":240},[208],[46,1704],{},[46,1706,104],{"className":1707},[329],[46,1709,1711,1714],{"className":1710},[186],[46,1712,716],{"className":1713},[186,443],[46,1715,1717],{"className":1716},[195],[46,1718,1720],{"className":1719},[199],[46,1721,1723],{"className":1722},[204],[46,1724,1726],{"className":1725,"style":1246},[208],[46,1727,1728,1731],{"style":1249},[46,1729],{"className":1730,"style":217},[216],[46,1732,1734],{"className":1733},[221,222,223,224],[46,1735,1737,1740,1743],{"className":1736},[186,224],[46,1738,104],{"className":1739},[329,224],[46,1741,681],{"className":1742},[186,190,224],[46,1744,116],{"className":1745},[455,224],[46,1747,116],{"className":1748},[455],[46,1750],{"className":1751,"style":304},[128],[46,1753,85],{"className":1754},[308],[46,1756],{"className":1757,"style":304},[128],[46,1759,1761,1765,1803],{"className":1760},[177],[46,1762],{"className":1763,"style":1764},[181],"height:1.138em;vertical-align:-0.25em;",[46,1766,1768,1771],{"className":1767},[186],[46,1769,733],{"className":1770,"style":1293},[186,190],[46,1772,1774],{"className":1773},[195],[46,1775,1777],{"className":1776},[199],[46,1778,1780],{"className":1779},[204],[46,1781,1783],{"className":1782,"style":1246},[208],[46,1784,1785,1788],{"style":1249},[46,1786],{"className":1787,"style":217},[216],[46,1789,1791],{"className":1790},[221,222,223,224],[46,1792,1794,1797,1800],{"className":1793},[186,224],[46,1795,104],{"className":1796},[329,224],[46,1798,681],{"className":1799},[186,190,224],[46,1801,116],{"className":1802},[455,224],[46,1804,116],{"className":1805},[455],[11,1807,1808,1809,1812,1813,1815,1816,1819,1820,1823,1824,1826],{},"Glance at it quickly and this formula is indistinguishable from linear regression's. The good kind of gotcha: it ",[30,1810,1811],{},"is"," identical, byte for byte. What changes is what ",[21,1814,36],{}," means: in linear regression, ",[21,1817,1818],{},"f = w·x + b","; here, ",[21,1821,1822],{},"f = sigmoid(w·x + b)",". That swap, hidden inside ",[21,1825,36],{},", is what makes the rest of the math behave differently without rewriting a single line of the gradient formula.",[39,1828,1830],{"id":1829},"the-code-line-by-line","The code, line by line",[1832,1833,1838],"pre",{"className":1834,"code":1835,"language":1836,"meta":1837,"style":1837},"language-python shiki shiki-themes github-light github-dark","def compute_gradient_logistic(X, y, w, b):\n    m, n = X.shape\n    dj_dw = np.zeros((n,))\n    dj_db = 0.\n\n    for i in range(m):\n        f_wb_i = sigmoid(np.dot(X[i], w) + b)\n        err_i = f_wb_i - y[i]\n        for j in range(n):\n            dj_dw[j] = dj_dw[j] + err_i * X[i, j]\n        dj_db = dj_db + err_i\n    dj_dw = dj_dw \u002F m\n    dj_db = dj_db \u002F m\n\n    return dj_db, dj_dw\n","python","",[21,1839,1840,1847,1853,1859,1865,1872,1878,1884,1890,1896,1902,1908,1914,1920,1925],{"__ignoreMap":1837},[46,1841,1844],{"class":1842,"line":1843},"line",1,[46,1845,1846],{},"def compute_gradient_logistic(X, y, w, b):\n",[46,1848,1850],{"class":1842,"line":1849},2,[46,1851,1852],{},"    m, n = X.shape\n",[46,1854,1856],{"class":1842,"line":1855},3,[46,1857,1858],{},"    dj_dw = np.zeros((n,))\n",[46,1860,1862],{"class":1842,"line":1861},4,[46,1863,1864],{},"    dj_db = 0.\n",[46,1866,1868],{"class":1842,"line":1867},5,[46,1869,1871],{"emptyLinePlaceholder":1870},true,"\n",[46,1873,1875],{"class":1842,"line":1874},6,[46,1876,1877],{},"    for i in range(m):\n",[46,1879,1881],{"class":1842,"line":1880},7,[46,1882,1883],{},"        f_wb_i = sigmoid(np.dot(X[i], w) + b)\n",[46,1885,1887],{"class":1842,"line":1886},8,[46,1888,1889],{},"        err_i = f_wb_i - y[i]\n",[46,1891,1893],{"class":1842,"line":1892},9,[46,1894,1895],{},"        for j in range(n):\n",[46,1897,1899],{"class":1842,"line":1898},10,[46,1900,1901],{},"            dj_dw[j] = dj_dw[j] + err_i * X[i, j]\n",[46,1903,1905],{"class":1842,"line":1904},11,[46,1906,1907],{},"        dj_db = dj_db + err_i\n",[46,1909,1911],{"class":1842,"line":1910},12,[46,1912,1913],{},"    dj_dw = dj_dw \u002F m\n",[46,1915,1917],{"class":1842,"line":1916},13,[46,1918,1919],{},"    dj_db = dj_db \u002F m\n",[46,1921,1923],{"class":1842,"line":1922},14,[46,1924,1871],{"emptyLinePlaceholder":1870},[46,1926,1928],{"class":1842,"line":1927},15,[46,1929,1930],{},"    return dj_db, dj_dw\n",[1932,1933,1934,1946,1952,1967,1973],"ul",{},[1935,1936,1937,1940,1941,1945],"li",{},[21,1938,1939],{},"f_wb_i = sigmoid(...)",": ",[15,1942,1944],{"href":1943},"\u002Fen\u002Fplaylists\u002Fmachine-learning-specialization\u002Fw3-lab03-decision-boundary","the same linear combination as always",", squashed by the sigmoid into a probability.",[1935,1947,1948,1951],{},[21,1949,1950],{},"err_i = f_wb_i - y[i]",": this patient's error, prediction minus real label.",[1935,1953,1954,1955,1958,1959,1962,1963,1966],{},"the inner ",[21,1956,1957],{},"for j"," multiplies that error by each variable ",[21,1960,1961],{},"X[i,j]"," and accumulates it into ",[21,1964,1965],{},"dj_dw[j]",", the same \"error times input\" mechanic linear regression already used.",[1935,1968,1969,1972],{},[21,1970,1971],{},"dj_db"," accumulates just the raw error, no multiplication, also identical to linear regression.",[1935,1974,1975,1976,1979],{},"at the end, both become an average (",[21,1977,1978],{},"\u002F m",").",[11,1981,1982,1983,1986,1987,1990],{},"Checking against ",[21,1984,1985],{},"w=[2,3]",", ",[21,1988,1989],{},"b=1"," on the usual dataset:",[1832,1992,1994],{"className":1834,"code":1993,"language":1836,"meta":1837,"style":1837},"dj_db_tmp, dj_dw_tmp = compute_gradient_logistic(X_tmp, y_tmp, w_tmp, b_tmp)\nprint(f\"dj_db: {dj_db_tmp}\")\nprint(f\"dj_dw: {dj_dw_tmp.tolist()}\")\n",[21,1995,1996,2001,2006],{"__ignoreMap":1837},[46,1997,1998],{"class":1842,"line":1843},[46,1999,2000],{},"dj_db_tmp, dj_dw_tmp = compute_gradient_logistic(X_tmp, y_tmp, w_tmp, b_tmp)\n",[46,2002,2003],{"class":1842,"line":1849},[46,2004,2005],{},"print(f\"dj_db: {dj_db_tmp}\")\n",[46,2007,2008],{"class":1842,"line":1855},[46,2009,2010],{},"print(f\"dj_dw: {dj_dw_tmp.tolist()}\")\n",[2012,2013,2014],"blockquote",{},[11,2015,2016,2019,2020,2023,2024],{},[30,2017,2018],{},"Output:"," ",[21,2021,2022],{},"dj_db: 0.49861806546328574"," · ",[21,2025,2026],{},"dj_dw: [0.498333393278696, 0.49883942983996693]",[39,2028,2030],{"id":2029},"the-outer-loop-really-is-copy-paste","The outer loop really is copy-paste",[1832,2032,2034],{"className":1834,"code":2033,"language":1836,"meta":1837,"style":1837},"def gradient_descent(X, y, w_in, b_in, alpha, num_iters):\n    w = copy.deepcopy(w_in)\n    b = b_in\n\n    for i in range(num_iters):\n        dj_db, dj_dw = compute_gradient_logistic(X, y, w, b)\n        w = w - alpha * dj_dw\n        b = b - alpha * dj_db\n\n        if i % math.ceil(num_iters \u002F 10) == 0:\n            print(f\"Iteration {i:4d}: Cost {compute_cost_logistic(X, y, w, b)}\")\n\n    return w, b\n",[21,2035,2036,2041,2046,2051,2055,2060,2065,2070,2075,2079,2084,2089,2093],{"__ignoreMap":1837},[46,2037,2038],{"class":1842,"line":1843},[46,2039,2040],{},"def gradient_descent(X, y, w_in, b_in, alpha, num_iters):\n",[46,2042,2043],{"class":1842,"line":1849},[46,2044,2045],{},"    w = copy.deepcopy(w_in)\n",[46,2047,2048],{"class":1842,"line":1855},[46,2049,2050],{},"    b = b_in\n",[46,2052,2053],{"class":1842,"line":1861},[46,2054,1871],{"emptyLinePlaceholder":1870},[46,2056,2057],{"class":1842,"line":1867},[46,2058,2059],{},"    for i in range(num_iters):\n",[46,2061,2062],{"class":1842,"line":1874},[46,2063,2064],{},"        dj_db, dj_dw = compute_gradient_logistic(X, y, w, b)\n",[46,2066,2067],{"class":1842,"line":1880},[46,2068,2069],{},"        w = w - alpha * dj_dw\n",[46,2071,2072],{"class":1842,"line":1886},[46,2073,2074],{},"        b = b - alpha * dj_db\n",[46,2076,2077],{"class":1842,"line":1892},[46,2078,1871],{"emptyLinePlaceholder":1870},[46,2080,2081],{"class":1842,"line":1898},[46,2082,2083],{},"        if i % math.ceil(num_iters \u002F 10) == 0:\n",[46,2085,2086],{"class":1842,"line":1904},[46,2087,2088],{},"            print(f\"Iteration {i:4d}: Cost {compute_cost_logistic(X, y, w, b)}\")\n",[46,2090,2091],{"class":1842,"line":1910},[46,2092,1871],{"emptyLinePlaceholder":1870},[46,2094,2095],{"class":1842,"line":1916},[46,2096,2097],{},"    return w, b\n",[11,2099,2100,2101,2108,2109,2112,2113,2116,2117,2120],{},"Compare it to ",[15,2102,2104,2105],{"href":2103},"\u002Fen\u002Fplaylists\u002Fmachine-learning-specialization\u002Flab04-gradient-descent","Week 1's ",[21,2106,2107],{},"gradient_descent",": the only real difference is which cost function feeds the progress ",[21,2110,2111],{},"print",". The ",[21,2114,2115],{},"for"," loop, the ",[21,2118,2119],{},"w = w - alpha * dj_dw"," update, all identical.",[11,2122,2123,2124,2127],{},"Running it on the usual six-patient dataset, ",[21,2125,2126],{},"alpha=0.1",", 10,000 iterations:",[2012,2129,2130,2134,2142],{},[11,2131,2132],{},[30,2133,2018],{},[1832,2135,2140],{"className":2136,"code":2138,"language":2139},[2137],"language-text","Iteration    0: Cost 0.6846\nIteration 1000: Cost 0.1591\nIteration 2000: Cost 0.0846\nIteration 3000: Cost 0.0571\nIteration 4000: Cost 0.0429\nIteration 5000: Cost 0.0343\nIteration 6000: Cost 0.0286\nIteration 7000: Cost 0.0245\nIteration 8000: Cost 0.0214\nIteration 9000: Cost 0.0190\n","text",[21,2141,2138],{"__ignoreMap":1837},[11,2143,2144,1986,2147],{},[21,2145,2146],{},"w: [5.2812, 5.0782]",[21,2148,2149],{},"b: -14.2224",[11,2151,2152,2153,2156,2157,2160],{},"Cost plummets early (from ",[21,2154,2155],{},"0.68"," to ",[21,2158,2159],{},"0.16"," in just the first thousand rounds) and then keeps refining slowly, the same \"learns fast at first, polishes later\" curve that's shown up on every convex cost surface trained so far in this playlist.",[2162,2163],"classification-boundary-comparison-chart",{":boundaries":2164,":classes":2165,":points":2166,":x-max":2167,":x-min":686,":y-max":2168,":y-min":686,"negative-label":2169,"positive-label":2170,"x-label":2171,"y-label":2172},"[{\"w\":[5.2812,5.0782],\"bias\":-14.2224,\"label\":\"boundary after 10k steps\"}]","[-1,-1,-1,1,1,1]","[[0.5,1.5],[1,1],[1.5,0.5],[3,0.5],[2,2],[1,2.5]]","4","3.5","y=0","y=1","x0","x1",[11,2174,2175,2176,2179],{},"The boundary separates all six patients with no mistakes, exactly like ",[15,2177,2178],{"href":1943},"the hand-trained version shown earlier",", except this time I watched gradient descent get there step by step, instead of receiving the weights ready-made.",[39,2181,2183],{"id":2182},"walking-downhill-live","Walking downhill, live",[11,2185,2186,2187,2190,2191,2195],{},"The dataset above has two variables, so its cost surface lives in a 4-dimensional space (",[21,2188,2189],{},"w0, w1, b, cost",") that can't be drawn. To actually watch gradient descent walk, I go back to a single-variable dataset, the same six patients ",[15,2192,2194],{"href":2193},"\u002Fen\u002Fplaylists\u002Fmachine-learning-specialization\u002Fw3-lab01-classification","from the week's first lab",":",[1832,2197,2199],{"className":1834,"code":2198,"language":1836,"meta":1837,"style":1837},"x_train = np.array([0., 1, 2, 3, 4, 5])\ny_train = np.array([0,  0, 0, 1, 1, 1])\n",[21,2200,2201,2206],{"__ignoreMap":1837},[46,2202,2203],{"class":1842,"line":1843},[46,2204,2205],{},"x_train = np.array([0., 1, 2, 3, 4, 5])\n",[46,2207,2208],{"class":1842,"line":1849},[46,2209,2210],{},"y_train = np.array([0,  0, 0, 1, 1, 1])\n",[11,2212,2213,2214,24,2216,2218,2219,2222,2223,2225],{},"With just ",[21,2215,23],{},[21,2217,27],{},", the logistic cost becomes a real 3D surface, the same convex bowl ",[15,2220,2221],{"href":17},"the last lab already compared against the \"wrong cost\" attempt"," (that one, riddled with fake valleys). Drag ",[21,2224,611],{},", click \"Run\" and watch the red dot descend to the bottom, always along the path the convex shape guarantees:",[2227,2228],"gradient-descent-simulator",{":b-range":2229,":w-range":2230,":x-train":2231,":y-train":2232,"b-label":27,"fn":2233,"w-label":23},"[-14,1]","[-1,7]","[0,1,2,3,4,5]","[0,0,0,1,1,1]","logistic",[11,2235,2236,2237,2240],{},"Notice the controls are the same ones you already used ",[15,2238,2239],{"href":2103},"on the linear regression posts",": alpha, step-by-step, run in batches, switch between 2D\u002F3D\u002Fparabola. Gradient descent doesn't get any smarter or dumber working on a different cost, it just descends whatever surface you hand it.",[39,2242,2244],{"id":2243},"wrapping-up","Wrapping up",[2246,2247,2248,2262],"table",{},[2249,2250,2251],"thead",{},[2252,2253,2254,2259],"tr",{},[2255,2256,2258],"th",{"align":2257},"left","What I already knew",[2255,2260,2261],{"align":2257},"What this lecture settled",[2263,2264,2265,2282,2290],"tbody",{},[2252,2266,2267,2276],{},[2268,2269,2270,2271,24,2273,2275],"td",{"align":2257},"Gradient descent updates ",[21,2272,23],{},[21,2274,27],{}," opposite to the gradient",[2268,2277,2278,2279,2281],{"align":2257},"The gradient formula is identical to linear regression's, ",[21,2280,36],{}," is just the sigmoid now, not the line",[2252,2283,2284,2287],{},[2268,2285,2286],{"align":2257},"The logistic cost is convex",[2268,2288,2289],{"align":2257},"That guarantees gradient descent always finds the same valley bottom, no matter where it starts",[2252,2291,2292,2295],{},[2268,2293,2294],{"align":2257},"I saw the trained boundary ready-made",[2268,2296,2297],{"align":2257},"Now I watched it get born step by step, the same loop that already ran for linear regression",[39,2299,2301],{"id":2300},"practical-application","Practical Application",[11,2303,2304,2305,2309,2310,2313,2314,2317],{},"I reuse ",[15,2306,2308],{"href":2307},"\u002Fen\u002Fplaylists\u002Fmachine-learning-specialization\u002Fw3-lab02-sigmoid-function","the same real variable this playlist keeps coming back to"," (",[21,2311,2312],{},"worst concave points",", z-score normalized), now with the 60-patient sample ",[15,2315,2316],{"href":1943},"from the decision boundary lab",", and run gradient descent myself instead of receiving the weights ready-made:",[2227,2319],{":b-range":2320,":w-range":2321,":x-train":2322,":y-train":2323,"b-label":27,"fn":2233,"w-label":23},"[-3,1]","[-1,6]","[-0.32,-0.488,1.029,-1.323,-1.107,0.028,1.357,-0.482,0.645,2.438,-0.216,0.423,0.592,-1.75,-0.581,-0.006,-0.409,2.699,0.097,2.365,0.635,1.917,-1.357,-0.144,1.455,0.537,-1.09,-0.456,-0.343,-0.464,-0.231,-1.29,-1.608,-0.191,0.42,-0.617,-0.135,-0.45,-1.015,-0.397,-0.473,1.894,0.495,-0.289,2.369,-1.004,2.196,-0.095,0.816,0.888,0.406,-0.785,-0.251,0.497,-1.385,-0.185,0.955,1.487,-0.842,0.986]","[1,0,1,0,0,1,1,0,1,1,0,1,1,0,0,0,0,1,0,1,1,1,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,1,0,1,1,0,0,0,1,0,0,1,1,0,1]",[11,2325,2326,2327,2330,2331,2334,2335,2338,2339,2342,2343,2346,2347,2353,2354,2357,2358,2361,2362,2365],{},"Running with ",[21,2328,2329],{},"alpha=0.5",", cost drops from ",[21,2332,2333],{},"0.6931"," (the worst possible guess, ",[21,2336,2337],{},"-log(0.5)",") to ",[21,2340,2341],{},"0.2372"," and converges around ",[21,2344,2345],{},"w=4.175, b=-1.094",", close to ",[15,2348,2349,2350],{"href":2307},"the ",[21,2351,2352],{},"w=3.9565, b=-1.1326"," earlier labs cite for the full training set (this sample here is only 60 patients, the full model saw a lot more people). Accuracy on this sample: ",[21,2355,2356],{},"0.90",", in the same ballpark as the ",[21,2359,2360],{},"0.91","-",[21,2363,2364],{},"0.93"," earlier labs already reported. The same loop that ran on six toy points now runs on real patients, no code change needed, just a different dataset going in.",[2367,2368,2369],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":1837,"searchDepth":1849,"depth":1849,"links":2371},[2372,2373,2374,2375,2376,2377],{"id":41,"depth":1849,"text":42},{"id":1829,"depth":1849,"text":1830},{"id":2029,"depth":1849,"text":2030},{"id":2182,"depth":1849,"text":2183},{"id":2243,"depth":1849,"text":2244},{"id":2300,"depth":1849,"text":2301},null,"2026-09-08","Week 3, Lab 6: after sigmoid, decision boundary, logistic loss and cost, only one piece is left to actually train something. Good news: that piece has existed since Week 1, the same gradient descent loop, just walking down a different hill.","md",{},17,"\u002Fen\u002Fplaylists\u002Fmachine-learning-specialization\u002Fw3-lab06-gradient-descent","machine-learning-specialization",{"title":6,"description":2380},"published","en\u002Fplaylists\u002Fmachine-learning-specialization\u002Fw3-lab06-gradient-descent",[2390,2391,2392],"classification","logistic-regression","gradient-descent","Q4ezJ7PJrLok0lc2qNlujpkroyivZpdMzTjblFtA26Q",1788965096420]