<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Romrawin (Jin) Chumpu on Medium]]></title>
        <description><![CDATA[Stories by Romrawin (Jin) Chumpu on Medium]]></description>
        <link>https://medium.com/@romrawinjp?source=rss-65b0790419ed------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*kjdbPJIIEZA0rgNU</url>
            <title>Stories by Romrawin (Jin) Chumpu on Medium</title>
            <link>https://medium.com/@romrawinjp?source=rss-65b0790419ed------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 22:08:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@romrawinjp/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Graphical Notes on Machine Learning — Gradient Descent]]></title>
            <link>https://romrawinjp.medium.com/graphical-notes-on-machine-learning-gradient-descent-a1c2cd3698fa?source=rss-65b0790419ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1c2cd3698fa</guid>
            <category><![CDATA[learning-rate]]></category>
            <category><![CDATA[illustration]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[gradient-descent]]></category>
            <dc:creator><![CDATA[Romrawin (Jin) Chumpu]]></dc:creator>
            <pubDate>Mon, 04 Mar 2024 17:32:03 GMT</pubDate>
            <atom:updated>2024-03-07T07:23:09.897Z</atom:updated>
            <content:encoded><![CDATA[<h3>Graphical Notes on Machine Learning — Gradient Descent</h3><h4><strong>Demystifying Gradient Descent: A Visual Guide to Understanding and Applying this Optimization Technique</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YRWXEGQEmcF4iNvaULwZBw.png" /><figcaption>Gradient descent (fun) illustration by author</figcaption></figure><p><strong>Gradient descent</strong> — is an<em> optimization algorithm</em>, which commonly used in <em>machine learning</em> to find the optimal parameters for the models during training step. Imagine you’re lost in a hilly landscape and want to find the lowest valley. Gradient descent helps you get there by iteratively taking steps in the direction that goes downhill the fastest as in above illustration.</p><h4>Recap on cost function</h4><p><strong>Cost function</strong> — also sometimes called a <em>loss function</em>, is a mathematical tool used in machine learning to evaluate how well a model is performing. It essentially quantifies the <strong>error</strong> between the <strong>predicted values</strong> of the model and the <strong>actual values</strong> it’s trying to learn from. In each application, the cost function can be any function regarding problem setting. In our example here, we will see the simplest form of <em>linear regression</em> as representing the main equation using throughout the note.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q-dk-hxToJZBELAWVz5LyQ.jpeg" /><figcaption>Cost function and goal of gradient descent (image by author)</figcaption></figure><p><strong>Goal —</strong> minimize the cost function <em>J(w,b) </em>by finding the optimal values of <em>w</em> and <em>b</em>.</p><h4>How does gradient descent work in a simple way</h4><p>Gradient descent starts with initializing the position of <em>(w, b)</em> on the graph, where the location keeps reflecting back on the cost function <em>J</em>, or random values of <em>w</em> and <em>b </em>anywhere at the initial step. And then, the algorithm performs repeating steps to update parameters <em>w</em> and <em>b </em>until the trajectory reaches somewhere closer to the local minima.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mx1-dtXOB1rx-AfpXLT9sg.jpeg" /><figcaption>How does gradient descent work (image by author)</figcaption></figure><h4><strong>Gradient descent algorithm</strong></h4><p>Let’s dive deeper into the Gradient Descent algorithm!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KCCOkgsMlDQLguAXSh27hw.jpeg" /><figcaption>Gradient descent algorithm (image by author)</figcaption></figure><p>The update rule for each parameter is determined by the <strong>learning rate </strong>and the <strong>partial derivative of the cost function with respect to that parameter.</strong></p><p>Here’s a step-by-step breakdown:</p><ol><li><strong>Start with a guess — </strong>You begin with an initial guess for the position of the minimum (like a random point on the graph). This guess represents the initial values of the model’s parameters.</li><li><strong>Calculate the gradient —</strong> The gradient tells you the direction of steepest descent at your current position. It’s like having a compass that points downhill. Mathematically, the gradient is calculated using calculus.</li><li><strong>Take a step — </strong>You move in the negative direction of the gradient by a small amount called the <em>learning rate</em>. This ensures you don’t jump over the valley but gradually descend towards it. The learning rate controls how big of a step you take; a larger rate means faster movement but also a higher risk of missing the valley altogether.</li><li><strong>Repeat — </strong>Go back to step 2 and keep calculating the gradient at your new position. Update your position based on the new gradient and learning rate.</li><li><strong>Convergence — </strong>Continue iterating (steps 2–4) until you reach a point where the cost function doesn’t change much anymore, or you meet a pre-defined stopping criterion. This indicates you’ve (hopefully) found a minimum.</li></ol><h4>Intuition</h4><p>Here are some general intuition during the updating towards the goal of finding the <strong>lowest point</strong> (the minimum) in this graph. From the derivative terms in the update for <em>w</em>, we can see that the differentiation of the cost function represents the <strong>slope</strong> of the function <em>J</em>. If the <strong>slope is positive</strong>, the update value (learning rate) will be <strong>subtracted</strong>, making the step size <strong>smaller</strong> over time. Conversely, if the <strong>slope is negative</strong>, the update value will be <strong>added</strong>, making the step size <strong>larger</strong> over time until it reaches a <strong>minimum</strong>, which is often close to <strong>zero</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*u7iRUL5lLYXk4BcaO9g7NA.jpeg" /><figcaption>Gradient descent intuition (image by author)</figcaption></figure><h4>Learning rate</h4><p><strong>Learning rate — </strong>is a crucial hyperparameter in the update term. It controls the <strong>step size</strong> taken by the algorithm during each iteration as it navigates towards the minimum of a cost function.</p><p>An appropriate learning rate helps the algorithm <strong>converge</strong> smoothly to the minimum point, meaning it reaches the optimal solution efficiently and avoids getting stuck in local minima (false bottoms).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PclUqw7-VqQL2Fs_8rVMzg.jpeg" /><figcaption>Learning rate is too small or too large (image by author)</figcaption></figure><p>When the learning rate is too small, it can cause slow convergence during the training, reflecting on the tiny step on algorithm takes significantly longer time to reach the minimum point.</p><p>When the learning rate is too small, this can cause the oscillation and instability. The algorithm takes large steps, potentially <strong>overshooting</strong> the minimum point and oscillating around it, resulting that it will never reach the minimum point.</p><p>Problem can also appear when the function is too complicated. The algorithm might get trapped in shallow valleys (local minima) instead of reaching the global minimum (the absolute lowest point). It might mistake a small improvement for the optimal solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lYWlU8IS4l4_Vt2Id4W1iA.jpeg" /><figcaption>Learning rate get stuck (image by author)</figcaption></figure><p>The more modification we can do with learning rate is setting <strong>adaptive learning rates </strong>or <strong>learning rate decay. </strong>This will adjust automatically during training based on the progress made.</p><p>While a fixed learning rate is the simplest approach, it can also lead the algorithm to reach local minima. This happens because both the derivative term and the parameter <em>w</em> become smaller during updates in some simple functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YKeLEa2wK3qeJk4GH8KHJA.jpeg" /><figcaption>Fixed learning rate (image by author)</figcaption></figure><h3>Grouping all parts together</h3><p>From the linear regression model, we can link the predicted values to the cost function terms. The cost function here is in the form of squared error, which can be visualized as the bowl shape, and it contains a global minimum. Next step, gradient descent relies heavily on the cost function. By calculating the gradient (the rate of change) of the cost function with respect to the model’s parameters, gradient descent can determine the direction in which the model needs to adjust to minimize the error and improve its performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VcafrtBA4sHFVLzNNy_3_A.jpeg" /><figcaption>Gradient descent with linear regression (image by author)</figcaption></figure><p>Using calculus, we can derive the update term, which is the derivative of the cost function. The algorithm iteratively updates the parameters, resembling a walk towards the minimum point on a contour plot. This process helps us find a model that closely approximates the function <em>f</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*et37STgr27KFfQWn3mw0fg.jpeg" /><figcaption>Visualizing gradient descent with linear regression (image by author)</figcaption></figure><p>When all training examples are used to calculate the gradient and update the model parameters in each iteration, this is called <strong>batch gradient descent</strong>. However, this can be computationally expensive for large datasets. In such cases, subsets of the data, called mini batches, can be used to optimize the model efficiently. <strong>Stochastic gradient descent (SGD)</strong> is another variation where the model parameters are updated after each individual data point. We’ll delve deeper into SGD in a future note!</p><p>Thanks for reading! Stay tuned for more.</p><p><em>If you like my note, here is the way to </em><a href="https://www.buymeacoffee.com/romrawinjp"><em>buy me a coffee☕</em></a><em>.</em></p><h4>References</h4><p>This note is illustrated from <a href="https://www.coursera.org/specializations/machine-learning-introduction">machine learning specialization</a> by Stanford Online x Deeplearning.AI — Supervised Machine Learning: Regression and Classification</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1c2cd3698fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Summary of Artificial Intelligence, Ethics and Governance from GYSS 2022 (Thai version)]]></title>
            <link>https://romrawinjp.medium.com/summary-artificial-intelligence-ethics-and-governance-from-gyss-2022-ee0fab66755d?source=rss-65b0790419ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee0fab66755d</guid>
            <category><![CDATA[ai-ethics]]></category>
            <category><![CDATA[singapore]]></category>
            <category><![CDATA[young-scientist]]></category>
            <category><![CDATA[gys]]></category>
            <dc:creator><![CDATA[Romrawin (Jin) Chumpu]]></dc:creator>
            <pubDate>Thu, 31 Aug 2023 07:32:57 GMT</pubDate>
            <atom:updated>2023-08-31T08:30:59.879Z</atom:updated>
            <content:encoded><![CDATA[<h4>เทคโนโลยีปัญญาประดิษฐ์ จริยธรรม การควบคุมและหลักการนำไปใช้อย่างเหมาะสม</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*eYU5FIUppVsREdvuTeXmFQ.png" /></figure><p>ในปัจจุบัน พัฒนาการทางด้านการสื่อสารระดับโลกและวิวัฒนาการอย่างต่อเนื่องของคอมพิวเตอร์ ทำให้การประยุกต์ใช้เทคโนโลยีปัญญาประดิษฐ์ หรือที่รู้จักกันว่า Artificial Intelligence (AI) AI เข้ามามีบทบาทสำคัญในชีวิตประจำวันมนุษย์อย่างก้าวกระโดด และการเข้ามาของ AI นั้น เป็นไปอย่างแยบยล ตัวอย่างเช่น การใช้ social media (Facebook หรือ Line) ในการสื่อสารกับผู้คนใกล้ชิดรอบตัว ภายใต้การทำงานของ social media มีอัลกอริทึ่มมากมายภายใต้ระบบนั้นเหนือกว่าสิ่งที่เราเห็นภายนอก ระบบที่เราคุ้นเคยกันและเป็นประโยชน์ต่อผู้ใช้งานจำนวนมาก ได้แก่ ระบบคัดกรองข้อความที่อันตรายและระบบแนะนำสินค้าตามความนิยมของผู้ใช้ ในขณะเดียวกันการนำ AI มาใช้ สามารถก่อให้เกิดผลเสียร้ายแรงได้มากมาย ตัวอย่างที่เราอาจจะได้พบเห็น เช่น การนำข้อมูลความเป็นส่วนตัวมาใช้ ยิ่งไปกว่านั้นคือการรั่วไหลของข้อมูลส่วนตัว ทำให้บุคคลนั้นเกิดอันตรายในชีวิตประจำวัน ดังนั้นจริยธรรมและหลักควบคุมการใช้ในเทคโนโลยีปัญญาประดิษฐ์ จึงเป็นสิ่งที่ควรนำมาหารือถึงแนวทางการปฏิบัติ ในทั้งระดับผลผลิตของบริษัทจนถึงระดับการควบคุมการใช้งานที่ระดับโลกเห็นตรงกัน</p><p>เมื่อวันที่ 24 พฤศจิกายน พ.ศ. 2564 องค์กร UNESCO ได้ออกข้อตกลงระดับโลกครั้งแรกเกี่ยวกับจริยธรรมและข้อแนะนำในการใช้ AI การออกข้อตกลงครั้งนี้ เพิ่มความสนใจให้นานาประเทศมากมาย ทำให้องค์กรแต่ส่วนในโลก ริเริ่มจะนำข้อดีและข้อเสียของการใช้ AI มาอภิปรายและหาแนวทางปฏิบัติอย่างเหมาะสมร่วมกัน รวมถึง panel discussion ในงาน GYSS 2022 ครั้งนี้ คณะอภิปรายนำโดย ศาสตราจารย์ Leslie Valiant ผู้เชี่ยวชาญทางวิทยาศาสตร์คอมพิวเตอร์จากรางวัล Turing award ศาสตร์จารย์ Cédric Villani นักการเมืองและนักคณิตศาสตร์รางวัล Fields Medal ศาสตราจารย์ Simon Chesterman คณะนิติศาสตร์และผู้อำนวยการอาวุโส AI Governance ที่มหาวิทยาลัยนันยาง การอภิปรายหัวข้อนี้ดำเนินการโดย เอกอัครราชทูต Heng Chee Chan</p><p>เนื่องด้วยการเข้ามาของเทคโนโลยีปัญญาประดิษฐ์เกิดขึ้นอย่างรวดเร็วในทศวรรษนี้ การอภิปรายครั้งนี้จึงมีประโยชน์ต่อนักวิทยาศาสตร์รุ่นใหม่อย่างมาก โดยหัวข้อที่น่าสนใจที่ผู้ดำเนินรายการได้ยกขึ้นมา ครอบคลุมทั้ง 3 หัวข้อหลักดังนี้ หัวข้อที่หนึ่ง ทำไมเทคโนโลยีปัญญาประดิษฐ์ถึงทรงพลังในการประยุกต์กับศาสตร์ต่าง ๆ หัวข้อที่สอง อะไรบ้างคือความท้าทายในการการควบคุมและข้อกังวลด้านจริยธรรมที่ตามมาจากการใช้ AI และสุดท้าย เราจะสร้างโลกที่สามารถใช้ AI ในทางที่ดีได้อย่างไร</p><p><strong>ทำไมเทคโนโลยีปัญญาประดิษฐ์ถึงทรงพลังในการประยุกต์กับศาสตร์ต่างๆ</strong></p><p>เทคโนโลยีปัญญาประดิษฐ์ หรือ Artificial Intelligence (AI) มีระบบที่สำคัญคือการเรียนรู้ของเครื่อง หรือ Machine Learning (ML) ML เป็นเทคนิคทางคอมพิวเตอร์ในการตรวจหาธรรมชาติของรูปแบบ (Pattern) ที่พบเห็นได้จากข้อมูลจำนวณมาก (Big data) และเนื่องจากข้อมูลที่มากขึ้นเกินขีดจำกัดที่มนุษย์รับได้ จึงทำให้การเรียนรู้ของคอมพิวเตอร์เป็นจุดเปลี่ยนที่ทรงพลังและช่วยให้การทำงานต่างๆนั้นง่ายขึ้น วิวัฒนาการของ ML พัฒนาไปไกลอย่างมากในเรื่องที่ซับซ้อน เช่นการเล่นหมากรุก เริ่มต้นในประมาณปีทศวรรษที่ 1990s และในที่สุด ML ก็สามารถชนะมนุษย์ได้ในเวลาต่อมา ตัวอย่างอื่น ๆ ที่เห็นในปัจจุบัน เช่น การศึกษารูปของชั้นในตามนุษย์ ML สามารถแยกได้ความแตกต่างของตาของผู้หญิงและผู้ชายได้ โดยความถูกต้องถึง 97% โดยที่ไม่มีจักษุแพทย์คนใดพบเห็นความแตกต่างนั้นมาก่อน1 ในการสื่อสาร เทคโนโลยีการแปลภาษาสามารถช่วยมนุษย์ต่างพื้นที่ ต่างภาษา ให้เข้าใจกันและกันได้อย่างราบรื่นมากยิ่งขึ้น2 อีกทั้งในส่วนของงานระบบโมเลกุลอย่าง การพับของโปรตีน (Protein folding) อัลฟ่าโฟล (AlphaFold) โดยการค้นพบของบริษัท Deepmind ได้แก้ปัญหาการสร้างแบบจำลองที่นักชีววิทยาได้พยายามแก้ปัญหากันมานานถึง 50 ปี ได้สำเร็จ3 โดยที่กล่าวมานี้ เป็นเพียงไม่กี่ตัวอย่างที่พิสูจน์ได้ชัดเจนว่า การนำ AI มาประยุกต์ใช้เป็นวิธีการทรงพลังเป็นอย่างมาก ศาสตราจารย์ Valiant กล่าวว่า ในอนาคต เราสามารถสันนิษฐานได้เลยว่า งานต่างๆที่ใช้หลักการที่ซับซ้อน คอมพิวเตอร์จะสามารถทำงานได้ดีกว่ามนุษย์อย่างแน่นอน และมนุษย์อาจจะต้องเพิ่งพาคำแนะนำที่ไม่ลำเอียงจาก AI ไม่มากก็น้อย</p><p>อีกหนึ่งจุดประสงค์ที่สำคัญในการนำ AI มาใช้คือ ความผิดพลาดในธรรมชาติของความเป็นมนุษย์ ท้ายที่สุดแล้วมนุษย์เราไม่สามารถหลีกเลี่ยงการทำผิดพลาดซ้ำ ๆ ได้เลย และการนำคอมพิวเตอร์มาแทนที่นั้น สามารถลดอคติ ความไม่เท่าเทียมที่เกิดจากจิตวิทยาของมนุษย์ที่มาครอบงำการตัดสินใจนั้น ๆ ได้ ตัวอย่างเช่น การคัดเลือกบุคลากรเข้าทำงานในองค์กร การสัมภาษณ์งานกับผู้สมัครอาจจะทำให้ผู้สัมภาษณ์เกิดความชื่นชอบในตัวบางคน ถึงแม้ว่าประสบการณ์ของผู้สมัครคนนั้นอาจจะไม่ตรงตามคุณสมบัติของงานเลยก็ตาม การนำการวิเคราะห์โดย AI เข้ามาคัดเลือกในรอบแรก จะช่วยให้ได้ผู้สมัครที่ตรงตามมาตรฐานและทำได้รวดเร็วในการคัดกรองใบสมัครจำนวนมาก แต่กระบวนการเช่นนี้ไม่ได้เป็นตัวชี้วัดเลยกว่า เขานั้นสามารถทำงานกับผู้อื่นได้หรือไม่ เหตุการณ์นี้ นำไปสู่ความกังวลของผู้เชี่ยวชาญหลายในวงการที่ว่า การนำ AI มาใช้เป็นสิ่งที่ดีจริงหรือไม่</p><h4>แล้วอะไรคือปัญหาและสิ่งที่เราควรกังวลในประสิทธิภาพของ AI?</h4><p>ศาสตร์จารย์ Valiant ได้กล่าวถึง 3 ปัญหาหลักในการพัฒนา ML ซึ่งแท้ที่จริงแล้วปัญหาเหล่านี้เป็นปัญหาที่ค่อนข้างเก่า แต่เป็นสิ่งที่ผู้พัฒนาทุกคนควรตระหนักถึงในทุก ๆ ครั้งที่สร้าง AI ขึ้นมา</p><ol><li>ความเป็นธรรมต่อชนกลุ่มน้อย (Fairness to minorities) — ปัญหานี้เกิดจากการที่ผู้พัฒนาใช้ข้อมูลไม่มากเพียงพอ ทำให้ ML เรียนรู้ได้อย่างจำกัด มีความแม่นยำน้อยในโลกความเป็นจริง และเกิดอคติที่เป็นผลกระทบที่ตามมาในที่สุด และวิธีการแก้ปัญหานี้คือ ผู้พัฒนาควรมีข้อมูลที่มากเพียงพอ</li><li>การเฝ้าระวัง (Surveillance) — ในการเปลี่ยนแปลงระดับการใช้งานจากเล็กไปถึงใหญ่ ผู้พัฒนาอาจจะมีการเฝ้าระวังเหตุการณ์จำเพาะต่าง ๆ ได้อย่างไม่รอบคอบ จึงทำให้เกิดปัญหาทางด้านเทคนิคความถูกต้อง เพราะฉะนั้นในการนำไปใช้ ผู้พัฒนาควรตรวจสอบให้อย่างรอบคอบมากยิ่งขึ้น</li><li>การเข้าถึงความรับผิดชอบ (Link of responsibility) — ปัญหานี้ยังเป็นปัญหาที่ไม่ชัดเจน ตัวอย่างเช่น หากเกิดอุบัติเหตุกับรถยนต์ระบบอัตโนมัติ ใครคือผู้รับผิดชอบในกรณีนี้ ซึ่งปัญหานี้สามารถแก้ปัญหาได้โดยย้อนกลับไปที่ปัญหาที่ 1 และปัญหาที่ 2 เป็นต้น</li></ol><p>โดยหากผู้พัฒนาทุกคนสามารถรักษามาตรฐานในการสร้างโปรแกรม AI ได้ ก็อาจจะทำให้ลดปัญหาที่กล่าวมาได้</p><p>และถ้าหากปัญหาเหล่านี้ยังคงอยู่ มนุษย์เราจะสบายใจแค่ไหนที่จะให้ ML ตัดสินใจแทนเรา?</p><p>ถึงแม้ว่ายังไม่มีคำตอบที่แน่นอน แต่ศาสตราจารย์ Valiant ได้กล่าววว่า <strong>มนุษย์ต้องเป็นคนตัดสินใจ (human have to decide) </strong>เราต้องตัดสินใจว่า ในงานต่าง ๆ จากการวิเคราะห์จาก AI การตัดสินใจนั้นควรมีบทบาทขนาดไหน เราควรพิจารณาอย่างถี่ถ้วน ว่าส่วนไหนที่ทำให้ลดความขัดแย้งหรือผลเสียที่จะเกิดขึ้น และถ้าหากเรานำ ML มาช่วยในทำงาน อย่างการปฏิเสธใบสมัคร การปฏิเสธที่นั่งในมหาวิทยาลัยต่อคุณสมบัติของเยาวชน การเลือกใช้อาวุธร้ายแรงเพื่อก่อสงคราม การตัดสินใจในการปกครองประเทศ เป็นสิ่งที่ดีจริง ๆ หรือไม่ ศาสตร์จารย์ Valiant เชื่อว่า ในอนาคตมนุษย์เราจะต้องใช้คำแนะนำจากคอมพิวเตอร์ในท้ายที่สุดแล้ว ไม่มากก็น้อย</p><p><strong>อะไรบ้างคือความท้าทายในการการควบคุมและข้อกังวลด้านจริยธรรมที่ตามมาจากการใช้ AI</strong></p><p>ในหัวข้อนี้ ศาสตราจารย์ Chesterman ได้เล่าถึง ความพยายามในการควบคุม AI และปัญหาที่เกี่ยวข้อง ไว้ว่า ในช่วงเวลา 5–6 ปีที่ผ่านมา มีเอกสารประกาศขึ้นมากมายประมาณ 100+ ฉบับ แต่ในช่วงปี 2016–2018 เป็นช่วงที่มีเอกสารเกิดขึ้นมากที่สุด เกี่ยวกับความคุ้มครองด้านการใช้ข้อมูลส่วนตัว จากเหตุการณ์ Cambridge Analytica data scandal จากการที่ข้อมูลส่วนตัวของผู้ใช้ Facebook นับล้านได้นำมาใช้โดยไม่ได้รับอนุญาต เหตุการณ์ดังกล่าวทำให้เกิดความกระตือรือร้นในภาคส่วนต่าง ๆ บนโลก ที่จะหาแนวทางควบคุมการใช้ข้อมูลที่เหมาะสม โดยประเด็นหลัก มุ่งไปตอบคำถามที่ว่า<strong> </strong><em>เราจะลดความเสี่ยงได้อย่างไร? (How do we mitigate the risks?)</em></p><h4>คำถามต่อไปจากการพิจารณาถึงความเสี่ยงคือ กฏอะไรบ้างที่ควรจะมี (What are the rules?)</h4><p>ศาสตราจารย์ Chesterman กล่าวว่า มุมนี้ จริง ๆ แล้ว เราก็มีทั้งแนวทางที่ยากและแนวทางที่ง่าย แนวทางที่ยากคือ มันแสดงให้เห็นว่าเราต้องสร้างวงล้อขึ้นมาใหม่ คิดกฏหมายขึ้นมาใหม่เพื่อที่จะควบคุมผลผลิตที่จะเกิดขึ้นหลังจากนี้ แต่สิ่งที่สำคัญจริง ๆ ของกระบวนการควบคุมนี้คือ <strong>แล้วเราจะทำกฏหมายที่มีอยู่ไปใช้กับระบบ AI ได้อย่างไร? </strong>นี่คือประเด็นที่สำคัญที่ผู้อภิปรายทั้ง 4 ท่านเห็นตรงกันเป็นอย่างมาก</p><p>ณ ตอนนี้ ในความกังวลดังกล่าว เราอาจจะต้องย้อนกลับไปถามคำถาม 3 ข้อเกี่ยวกับกฎระเบียบและการกำกับดูแลของ AI</p><ol><li>เพื่ออะไร (Why?) — เรากำลังพยายามบรรลุจุดประสงค์อะไร</li><li>เมื่อไหร่ (When?) — เมื่อไหร่ที่เราควรปล่อยนวัตกรรมนี้ออกมา</li><li>อย่างไร (How?) — เราจะทำอย่างไรให้นวัตกรรมที่ออกมาทำในสิ่งที่ดี รวมทั้งพิจารณาถึงระเบียบข้อบังคับในการสร้าง AI</li></ol><p>ศาสตราจารย์ Chesterman กล่าวว่า ในจุดประสงค์หลักของเราจะลดความเสี่ยงนั้น ๆ แนวโน้มที่จะคิดว่าทางออกเดียวจะเหมาะกับทุกคน ทุกประเทศ แนวทางนั้นแทบจะเป็นไปไม่ได้เลย ดังนั้นการคำนึงถึงการใช้งานโดยจำเพาะเจาะจงในแต่ลงประเทศ แต่ละพื้นที่ ควรพิจารณาอย่างละเอียดรอบคอบ โดยเฉพาะการตัดสินใจที่เกี่ยวกับชีวิตและความตาย ตัวอย่างเช่น การตัดสินความผิดของโจทก์ในศาล การตัดสินความผิดโดยใช้ AI มาช่วยก็สามารถเป็นไปได้ แต่ความชอบธรรมนั้นเป็นสิ่งที่ AI สามารถรับรู้ได้ด้วยหรือไม่ ดังนั้น ความชอบธรรมของการตัดสินใจนั้นควรมาจากผู้ดำรงตำแหน่งผู้พิพากษาโดยตรง ที่จะตัดสินชะตาชีวิตของมนุษย์คนหนึ่ง</p><p><strong>เราจะสร้างโลกที่สามารถใช้ AI ในทางที่ดีได้อย่างไร</strong></p><p>ในมุมมองของ ศาสตราจารย์ Villani ผู้ซึ่งเป็นทั้งคนในวงการวิทยาศาสตร์และนักการเมือง ได้ตอบคำถามในหลายประเด็น จากคำถามที่ว่า อนาคตของ AI สามารถนำมาซึ่งสถานการณ์ในอุดมคติได้อย่างไร และรัฐบาลและองค์กรต่างๆ จะรับประกันได้อย่างไรว่า AI จะถูกนำไปใช้และนำไปปฏิบัติในทางที่ดี</p><p>ศาสตราจารย์ Villani กล่าวขึ้นมาเป็นประเด็นแรกว่า <strong>เราจะสร้าง AI ในทางที่ดีได้ ก็ต่อเมื่อเรารู้รอบ ทั้งข้อดีและของเสียของสิ่งนั้น </strong>ศาสตราจารย์ Villani ได้ยกตัวอย่างจากหนังสือ Weapons of Math Destruction หรือหนังสือในภาษาไทยชื่อว่า บิ๊กดาต้ามหาประลัย เหตุผลส่วนใหญ่ของปัญหาด้านจริยธรรมเกิดขึ้นมาจากความประมาท ความผิดพลาดในการใช้งาน ล้วนเกิดจากอคติ เพราะมนุษย์ขาดความเข้มงวด หรือในบางครั้ง AI ถูกใช้โดยบุคคลหรือบริษัทที่ไม่มีความรู้ด้านการใช้งาน จึงทำให้เกิดปัญหามากมายในสังคม ผู้สร้าง AI จึงต้องมองให้รอบในหลาย ๆ ด้าน ตัวอย่างเช่น มีคนฝั่งหนึ่งยืนยันว่า AI มีความสำคัญต่อการเปลี่ยนแปลงด้านสิ่งแวดล้อม การวิเคราะห์จะช่วยให้เราหาวิธีประหยัดพลังงานหรือวางแผงโซลาร์เซลล์ที่เหมาะสมได้ ในทางกลับกัน AI ยังเป็นประโยชน์สำหรับผู้ที่ต้องการเจาะน้ำมัน พวกเขาอาจจะใช้ประโยชน์จากโฆษณาส่วนบุคคลที่จะโน้มโน้วให้ผู้คนใช้น้ำมันมากขึ้นก็เป็นไปได้ สุดท้ายเราก็ต้องยอมรับความจริงที่จะเกิดขึ้นว่า AI สามารถไปในทิศทางที่ถูกต้องได้ แต่ก็สามารถเป็นสื่อกลางในการนำไปอีกเส้นทางได้เช่นกัน เพราะฉะนั้นเราอาจจะตัดสินเด็ดขาดไม่ได้ว่าทางไหนดีหรือทางไหนไม่ดี</p><p>ในด้านการเปลี่ยนแปลงในของผู้นำในสังคม ตัวอย่างของ การสร้างแผนงานโดยใช้การทำนาย (Predictive policy) ด้วยข้อมูลการก่ออาชญากรรม การวิเคราะห์โดย AI สามารถทำนายได้ว่า อาชญากรรมครั้งต่อไปหรือเหตุการณ์ที่จะเกิดขึ้นอยู่ที่ไหน และเราก็อาจจะสามารถโยกย้ายตำรวจไป ณ สถานที่นั้นก่อนได้ ซึ่งบางทีเหตุการณ์นั้นอาจจะไม่เกิดขึ้นด้วยซ้ำ ในเรื่องเกี่ยวข้องกับปรับตารางเวลาพนักงานในบริษัทให้เหมาะสม ถึงแม้ว่า AI จะวิเคราะห์จากข้อมูลว่า ตารางนั้นเหมาะสมในแต่ละหน้าที่ แต่ในบางครั้ง ตารางที่แน่นเกินไปอาจจะทำให้ตัวพนักงานเหนื่อยล้า และไม่พอใจ ตัวอย่างนี้แสดงให้เห็นถึงตัวแปรทางด้านจิตใจของมนุษย์ที่มีผลถึงการนำ AI มาปรับใช้ทางด้านนโยบายอย่างมาก</p><p><strong>หลักการทางการเมืองที่ดีควรทำอย่างไร?</strong></p><p>ในทางการเมือง เพื่อที่จะชนะการเลือกตั้ง สามารถทำได้โดยใช้การวิเคราะห์ทางศาสตร์ Natural language processing เพื่อปรับนโยบายหาเสียงให้ตรงกับพื้นที่นั้น ๆ เลือกหัวข้อในการปาฐกถาในสิ่งที่ผู้มีสิทธิเลือกตั้งต้องการฟัง การทำเช่นนี้ก็สามารถทำได้และเป็นผลกระทบในทางที่ดีและหากผู้ลงสมัครเลือกตั้งทำได้จริง</p><p>และสุดท้าย ศาสตราจารย์ Villani ได้กล่าวถึงในประเด็นที่ว่า AI จะเป็นอย่างไร ซึ่งแม้ว่าจะทำงานได้ดีในการปรับทิศทางของสังคม? ในความเป็นจริงเราต้องสังเกตอย่างระมัดระวังและทำการทดลองต่อไป ในตอนนี้ไม่มีใครรู้ว่ามันทำงานอย่างไรในทางปฏิบัติทางสังคม แต่ ศาสตราจารย์ Villani กล่าวว่า AI ปัจจุบันยังเป็นตัวตัดสินใจที่ไม่เท่าเทียม เพราะฉะนั้นผู้สร้างยังคงต้องศึกษาต่อไป</p><p>โดยสรุปจากการอภิปรายเรื่อง เทคโนโลยีปัญญาประดิษฐ์ จริยธรรม การควบคุมและหลักการนำไปใช้อย่างเหมะสม ในครั้งนี้ การควบคุมเทคนิคที่สร้างจุดเปลี่ยนให้กับโลกนี้มากมาย ยังคงเป็นสิ่งที่ต้องใช้การตัดสินใจโดยมนุษย์มาประกอบ เพราะยังมีตัวแปรทางความรู้สึกของมนุษย์และผลกระทบมากมายทางสังคมที่เราอาจจะคาดการณ์กันไม่ถึง และในทางปฏิบัติเราควรที่จะสังเกตการทำงานและควรใช้อย่างระมัดระวังมากขึ้น อย่างไรก็ตามในอนาคต ศาสตร์ต่าง ๆ ที่ประยุกต์ใช้ด้วย AI อาจจะทำได้ดีกว่าเดิม โดยที่ผู้พัฒนา AI ทุกคนบนโลก ควรคำนึงถึงการใช้งานในทางที่ดี (AI for good) และเป็นประโยชน์รวมถึงเป็นการเปลี่ยนแปลงที่ยิ่งใหญ่ในสังคมยิ่งต่อไป</p><p><strong>Acknowledgement — </strong>Thank you, NSTDA and NSF for this opportunity. It was an honour and inspiring for a young researcher like me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee0fab66755d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stanford ME344S HPC-AI Summer Seminar — Week 1 in Review:  Codesigning Computing Systems for…]]></title>
            <link>https://romrawinjp.medium.com/stanford-me344s-hpc-ai-summer-seminar-week-1-in-review-codesigning-computing-systems-for-2e0ddcd9392d?source=rss-65b0790419ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e0ddcd9392d</guid>
            <category><![CDATA[codesign]]></category>
            <category><![CDATA[supercomputer]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Romrawin (Jin) Chumpu]]></dc:creator>
            <pubDate>Thu, 20 Jul 2023 00:23:01 GMT</pubDate>
            <atom:updated>2024-03-06T06:27:36.084Z</atom:updated>
            <content:encoded><![CDATA[<h3>Stanford ME344S HPC-AI Summer Seminar — Week 1 in Review: Codesigning Computing Systems for Artificial Intelligence</h3><h4>This article is a weekly review from the ME344S HPC-AI Summer Seminar Series (by Prof. Steve Jones) at Stanford University in the summer quarter 2023, and I find that the topics are very interesting — it would be worth reading.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l9laNfuUlhK9QFR13BQgPQ.png" /><figcaption>Codesigning paradigm overview from the talk</figcaption></figure><p>In week 1 of Stanford-ME344S, the seminar was giving by Karthik Srinivasa Murthy and Suvinay Subramanian from Google. Title of this seminar is “Codesigning Computing Systems for Artificial Intelligence”. They also presented interesting works on the behalf of many Googlers.</p><h4>TL;DR — The talk introduces the Codesign paradigm at Google. Codesign is a way of catching on to the growth of ML. The layers of design are simple but impactful for the development. TPUs have been used at Google for decades; the processor has achieved the performance and energy efficiency of large models end-to-end. TPUs have also demonstrated SOTA performance on a wide range of workloads, ranging from matrix multiplication to engine strategy. This paradigm has emphasized scaling up with good efficiency.</h4><p>The talk is about the co-design paradigm and critical aspects of getting performance for AI and ML workloads. Let’s touch on it step-by-step.</p><p>An emerging technology like generative models that are capable of answering natural questions like humans, such as ChatGPT, Bard AI, Github Copilot, or FourCastNet has been successful in the public eye recently. Not only from the introduction of Transformers, but there are also other aspects of constructing this domain that somehow are marked by the success of the ML domain. That is the compute infrastructure.</p><p>Only ML advancements, including algorithms, transformers, and CNNs, are not enough to scale the model out. Large models need the compute infrastructure to accelerate the workloads. Imagine if Bard AI still took 3–5 years to train; no company would be willing to spend resources on developing the models. Now a days, the computing time is so much faster, not in the scale of years anymore. For example, the 4000 units of the H100 chip can train GPT4.0 in 11 minutes. Even though there are different model sizes (i.e., batch sizes, sequence steps), 11 minutes is an achievably amazing time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v0cOIluyUNMmRRq5bOAb1Q.png" /><figcaption>Computing time has grown exponentially in 3 months!</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vxlcZU8pQCnTObszkPm3Mg.png" /><figcaption>These are the application which utilizes co-paradigm.</figcaption></figure><p>In the ML and AI workloads since 1960, the trend went from 300,000x in 2020 only because of the advancement in compute infrastructure. It is scaled linearly with respect to Moore’s law. It is doubling in 3.5 months, previously 6 months. That is why we need to Codesign the models and workloads with interchanging advancements and adapting processes.</p><h3>Codesigning Computing Systems for AI</h3><p>There are multiple layers of codesigning paradigm as in figure below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l9laNfuUlhK9QFR13BQgPQ.png" /><figcaption>Layers of codesigning paradigm</figcaption></figure><h4>Hardware</h4><p>What is Google TPUs?</p><p>Google TPUs are the co-processor that are focused on accelerating ML and AI workloads.</p><p>TPUs were first introduced in 2015. In 2015, the workloads of ML and AI doubled every 3.5 months, which inspired Google to design its first tensor processing units v1 in an efficient way with performance and power efficiency.</p><p>Imagine if you had to design the new workload. What would you do? There are two approaches. One is going through the traditional processors. The process starts with taking general processor units, extending the instruction set on the architecture, and including new instructions that tackle this workload to run faster. The problem with this approach is the increase in instruction latency. Because it is a general-purpose processor, it is based on latency-oriented processors. In this case, the processors keep doing the same instruction repeatedly. However, they have to be good at issuing new instructions and doing them. Consequently, if we take the ML workload to the general-purpose processor, then we extend its instruction. The amount of latency would increase with the typical instruction issue.</p><p>The second approach is co-processors, or specialized processors. How specialized processors are used depends on the company, such as Asic which fabricated an actual processor. In Google, this is also TPUs. TPUs were developed over a lot of generations; today is v4. Today, workloads such as Translate and AlphaGo run on these TPU processors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Op6fFtJw87j152togsDMA.png" /><figcaption>TPU and supercomputers</figcaption></figure><p>Why TPU is important?</p><p>GPUs have been a little slow in catching up to the TPU workload previously. That because they have varied workloads to target. When TPU is narrowed to a single domain, they are able to get perfect speed. The graph on the right shows the better performance of TPU v1 16 times more than the GPUs in terms of performance per watt. Even now, the GPUs have drastically developed, but TPU v4 is still better.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bgy1g2uF9CIIAO2XvVDvYA.png" /><figcaption>TPUs vs GPUs</figcaption></figure><p>In a simple ML application, for example, image classification, the process of a neural network is to learn the characteristics of an image and predict whether it is a cat or not.</p><p>In depth, the computation generally performs the matrix multiplication billions or trillions of times. This matrix is being translated into TPU and computed by it. The systolic array is the system in TPU that overcomes the traditional matrix multiplication method.</p><p>Systolic arrays were introduced in 1970s computer architecture [Kung and Leisserson]. Systolic arrays are the champions of matrix multiplication by seeing the matrix as the data moving for a 2D grid processor with pipelined and neighbor exchanges.</p><p>The process is illustrated in the two figures below. The weight matrix and input matrix are local and share the result. As we proceed, the movement of multiplication and sum of the whole 3D grid processor and the result are the same as in the natural way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K42N3zoOpz8fe5tgO1G9Dw.png" /><figcaption>Systolic array for matrix multiplication</figcaption></figure><p>Systolic array is translating load in stores from SRAM by sharing among processors. So, it is able to achieve much better performance. Not only its performance, but also its power efficiency. Because it converts loads and stores into near-neighbor communication between processors. Then getting much better performance than the traditional executions of matrix multiplication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wYpWXVBx38CNyLr8iPgLew.png" /><figcaption>OCS — Optical Circuit Switches</figcaption></figure><p>Google deploys many MEMS-based optical switches (OCS) for the standard datacenter networking routers and routing hardware. This is also useful in scaling up TPUs and some supercomputers to many thousands of chips.</p><p>On the application end, ML applications require scale and throughput to be very efficient. With hundreds of billions of parameters, we would need scale in order to serve and train a large model. In order to do that, they pack up multiple chips together if we want high throughput. We would need communication fabric that is both lightweight, energy efficient, and cost effective.</p><p>OCS provides good energy efficiency. They have low latency and high bandwidth. It is like a mirror that is controlled electromechanically. You have the input and output of optical fibers. By changing the direction of the mirror, you can route the light from one set of fibers to the resultant output fibers. This is energy efficient compared to the packet switched electrical network, where every single package might have to reconfigure switches, which depends on the applications. We will get the speed of light propagation delay. Low power consumption because the pipeline is not switching electrical networks. Once you set the MEMS mirror arrays in a particular manner, light just flows through without consuming any power.</p><h4>Systems</h4><p>How do we use this OCS in a large scale?</p><p>Due to the need for a huge training dataset and more scaling, there are also rapid changes to the algorithms and model structure. Datacenters have scaled up to 4000 chips in TPU v4. OCS is enabled to reconfigure networks on the supercomputers.</p><p>When considering large scale, the first thing we need to consider is the improved availability at scale. For example, if you take an individual chip, it might fail. When packing these chips together, the chance of one chip failing is low, and the system can still run.</p><p>Google constructs 4 by 4 chip blocks, and OCS is linked to the blocks. If one chip closes down, we detect that (after a hundred ms) and slack the system to find a new block in the datacenter, reset the OCS, and route to that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BZ3g545xAqAzlmltrUmhjA.png" /><figcaption>OCS system</figcaption></figure><p>The OCS is bandwidth independent; more fibers to the optical switch as long as it satisfies the bandwidth and the network vendors.</p><h4>Software</h4><p>In programming model side effects, we will focus on two high-level optimizations, <em>DeepFustion</em> and <em>Flexible Parallelization</em>. Both of them are critical for performance workloads.</p><p><em>DeepFusion</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bMcDgVjb0CP3R_OIYEtP6A.png" /></figure><p>This is how traditional contractors’ work. The convolution reads the inputs from your slow memory SRAM and then writes out its output to slow memory. And read it again and write out the full result with the same value. In this case, the memory transfer becomes a bottleneck. Because they are doing 2 bytes in one flop; it is almost like 50 operational intensities.</p><p><em>Machine and loop balance</em></p><p>Therefore, we should consider Machine balance and loop balance; this was introduced by Karl and Kenedy before roofline analysis. Machine balance is the theoretical peak of flops that can be achieved per byte of red operation from memory. Loop balance is generally what the compiler generates and the characteristic that it exhibits.</p><p>If machine balance says we can do 4 flops for every byte rate from memory, then the compiler’s best loop generates four. It would not be linear. Awesome complier. Google tries to get as close to machine balance as possible. They fuse three layers together. This Deep Fusion triples the operational intensity three times compared to the unfused one.</p><p>A key optimization is hardware utilization on the second iteration of the loop. Memory utilization benefits from avoiding the transfers of the intermediate tensors. But the con is that the output is no longer in the slow SRAM. The main one is achieving parity between machine and loop balance. It hit the theoretical roof line, which is the number of flops per byte consumed from SRAM. These are a few examples of research.</p><p>Examples</p><ul><li>Flash attention — fusion and recompute developed from TPU complier.</li><li>This is still in develop. from deep multi-operator from PLDI’21 which is matrix matrix fusions are unprofitable and more complex to orchestrate.</li></ul><p>Fusion is a first-class primitive in the TPU complier. They are done performantly on the TPU.</p><p>In the attention mechanism, they fuse the attention logit and softmax together. To overcome the bottlenecks from compute bound and memory bound, FLAT tries to fix the input with a small input tensor and a large intermediate tensor. They fuse three operators together unless there is a large intermediate tensor in the system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p72l7OF_85KO9NPC-GF_4w.png" /><figcaption>FLAT optimization for attention mechanism</figcaption></figure><p><em>Flexible parallelization</em></p><p>Based on the model benchmark, for example, in LLM, there are different types of parallelization strategies. The first approach to flexible parallelization is GSPMD. From reconfigurable OCS, by looking at the workload, Google is able to configure the topology to what it needs.</p><h4>Math</h4><p>Two mains topic is focused here: numeric and sparsity.</p><p><em>Numeric</em></p><p>In general, we often use floating point like scientific notation 6.02e32.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8fwqdCLb3l0KvyaYSKY82A.png" /></figure><p>The change in numeric type could have an effect on the quality of the model. They discover that what models wanted was slightly different than the standardized. They introduce bfloat16 because they want more exponent bits compared to mantissa bits. Compared to fp16, we can see that the number of exponent bits is higher, but the number of mantissa bits is significantly lower. Multipliers grow as thin as a mantissa bit. The lower mantissa bits can actually improve the performance and energy efficiency of the hardware.</p><p><em>Sparsity</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j4rx6nUcicTW4ivnxp0FVw.png" /></figure><p>Sparsity can come in many forms, including weight, activation, and semantic sparsity. Different types of sparsity cause different granularities between fine-grained and coarse-grained (0 and 1). The structures need to be selected for a specific domain of this solution to determine the right strategy for a profitable system.</p><p>Example</p><ul><li>SparseCore in TPU v4 is recent research on developing system solution with software and hardware to accelerate the computation for application like CNN, GNN. Hessians base augmentation for mixed precision training</li></ul><h4>Application and Infrastructure</h4><p>It has been concerned about the power consumption of the AI workload. Google has been thinking about power and energy efficiency for a very long time. They move the location to where it has access to clean energy.</p><p>The cost of training a large model is high. Responsible AI is a broad topic focusing on its carbon emissions from ML training. We can measure here in the datacenter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YxOUbdokf1uOBAa6XX8mSw.png" /></figure><p>4Ms is the strategy for reducing energy and carbon emissions. The model can change from Transformers to Primer. The processing machine, using TPUv4, has improved 14x compared to P100. There is the consideration of mechanization and maps, which are based on the resource’s location.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xJSI0jpRVekSb70z9Y7MZA.png" /><figcaption>4Ms overview</figcaption></figure><p>Google tries to locate where datacenters can access energy sources.</p><h3><strong>Conclusion</strong></h3><p>This talk has been looking at TPU and using codesign as a paradigm to improve its efficiency and performance. The codesign is composed of different layers to work collaboratively on a problem. The process is perhaps simple, but the outcome of codesign is very impactful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aPc-qCyeP7sotdzdkR1Rzg.png" /></figure><p>Codesign has been a key paradigm in how they design TPU at Google. It spans multiple layers of the stack and can have a substantial impact on the realizable end-to-end performance. TPU has demonstrated SOTA performance on a wide range of workloads as well as energy efficiency. These have been done fairly opinioned; they have been made across the stack, ranging from matrix multiplication to multiply engines. This paradigm has served well in the last decade to emphasize scaling with good efficiency to the algorithmic stack as well as numeric sparsity.</p><h3>Papers from the talks</h3><ul><li><em>Norman P. Jouppi, Cliff Young, Nishant Patil, and David Patterson. 2018. A domain-specific architecture for deep neural networks. Commun. ACM 61, 9 (September 2018), 50–59. </em><a href="https://doi.org/10.1145/3154484"><em>https://doi.org/10.1145/3154484</em></a></li><li>D. Patterson <em>et al</em>., “The Carbon Footprint of Machine Learning Training Will Plateau, Then Shrink,” in <em>Computer</em>, vol. 55, no. 7, pp. 18–28, July 2022, doi: 10.1109/MC.2022.3148714.</li><li><em>Sheng-Chun Kao, Suvinay Subramanian, Gaurav Agrawal, Amir Yazdanbakhsh, and Tushar Krishna. 2023. FLAT: An Optimized Dataflow for Mitigating Attention Bottlenecks. In Proceedings of the 28th ACM International Conference on Architectural Support for Programming Languages and Operating Systems, Volume 2 (ASPLOS 2023). Association for Computing Machinery, New York, NY, USA, 295–310. </em><a href="https://doi.org/10.1145/3575693.3575747"><em>https://doi.org/10.1145/3575693.3575747</em></a></li><li><em>Shibo Wang, Jinliang Wei, Amit Sabne, Andy Davis, Berkin Ilbeyi, Blake Hechtman, Dehao Chen, Karthik Srinivasa Murthy, Marcello Maggioni, Qiao Zhang, Sameer Kumar, Tongfei Guo, Yuanzhong Xu, and Zongwei Zhou. 2022. Overlap Communication with Dependent Computation via Decomposition in Large Deep Learning Models. In Proceedings of the 28th ACM International Conference on Architectural Support for Programming Languages and Operating Systems, Volume 1 (ASPLOS 2023). Association for Computing Machinery, New York, NY, USA, 93–106. </em><a href="https://doi.org/10.1145/3567955.3567959"><em>https://doi.org/10.1145/3567955.3567959</em></a></li></ul><p><em>If you like my note here,➡️ Just</em><a href="https://www.buymeacoffee.com/romrawinjp"><em> buy me some ☕</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e0ddcd9392d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[รูปนี้มีอะไรบ้าง ตอบคำถามนี้ด้วย UNet-like Network]]></title>
            <link>https://medium.com/super-ai-engineer/%E0%B8%A3%E0%B8%B9%E0%B8%9B%E0%B8%99%E0%B8%B5%E0%B9%89%E0%B8%A1%E0%B8%B5%E0%B8%AD%E0%B8%B0%E0%B9%84%E0%B8%A3%E0%B8%9A%E0%B9%89%E0%B8%B2%E0%B8%87-%E0%B8%95%E0%B8%AD%E0%B8%9A%E0%B8%84%E0%B8%B3%E0%B8%96%E0%B8%B2%E0%B8%A1%E0%B8%99%E0%B8%B5%E0%B9%89%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-unet-like-network-f239d2f50d92?source=rss-65b0790419ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/f239d2f50d92</guid>
            <category><![CDATA[super-ai-engineer]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[unet]]></category>
            <category><![CDATA[image-segmentation]]></category>
            <category><![CDATA[machchimasuperai]]></category>
            <dc:creator><![CDATA[Romrawin (Jin) Chumpu]]></dc:creator>
            <pubDate>Wed, 31 Mar 2021 07:29:06 GMT</pubDate>
            <atom:updated>2024-03-06T06:29:06.592Z</atom:updated>
            <content:encoded><![CDATA[<p>Image Segmentation with UNet-like Network</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qD50NprZq7aVhzUElKI8mg.jpeg" /></figure><p>สวัสดีค่า บทความนี้เขียนขึ้นมาระหว่างการเข้าร่วมในโครงการ Super AI Engineer Level 2 โดยอ้างอิงมาจาก <a href="https://keras.io/examples/vision/oxford_pets_image_segmentation/">Image segmentation with a U-Net-like architecture (keras.io)</a> จากบทความของ keras โดยผ่านลิ้งค์นี้ และเนื่องจากผู้เขียนกำลังเรียนรู้อยู่เช่นกัน หากมีอะไรเพิ่มเติม แนะนำชี้แนะได้เลยค่า</p><h3>What is UNet?</h3><p>UNet คือหนึ่ง neural network architecture ที่พัฒนามาจาก convolutional neural network แบบดั้งเดิม ถูกคิดค้นขึ้นมาครั้งแรกและถูกนำมาใช้กับรูปทางการแพทย์ในปี 2015 เพื่อวิเคราะห์โรคหรือระบุจุดของความผิดปกติในภาพถ่าย โดยรูปแบบสถาปัตยกรรมของ network นี้ มีรูปแบบที่ย่อและขยายข้อมูลในแต่ละ layers ลักษณะคล้ายรูปตัว U (อ้างอิงจากรูปที่แสดงด้านล่างนี้)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tu-LIoqb891UqD0bDkvEVA.png" /><figcaption>The architecture of Unet from <a href="https://www.researchgate.net/publication/334287825_A_Stacked_Multi-Connection_Simple_Reducing_Net_for_Brain_Tumor_Segmentation">https://www.researchgate.net/publication/334287825_A_Stacked_Multi-Connection_Simple_Reducing_Net_for_Brain_Tumor_Segmentation</a></figcaption></figure><p>UNet ถูกนำมาแก้ปัญหานี้โดยเฉพาะ เพราะว่าเทคนิคนี้ สามารถระบุพื้นที่และแยกเส้นขอบได้ดี ในระดับ pixel space จึงเหมาะการโจทย์ image segmentation หรือ image classification โดย input และ output ของ UNet เป็นขนาดเท่ากัน</p><p>เรามาเริ่มทำกันเลยดีกว่า! ทุกคนสามารถเปิดทำใน colab ได้เลย</p><ol><li>เริ่มแรกต้องโหลด data มาก่อน<br>ข้อมูลที่เราโหลดมา จะเป็นรูปของสัตว์ต่างๆ ทั้งหมดสองไฟล์ใหญ่ ไฟล์แรก คือ ไฟล์รูปภาพ images.tar.gz และ ไฟล์ที่สอง คือ ไฟล์ annotations.tar.gz</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JTDjVZPF-pOikJQR-io-cA.png" /></figure><p>2. จัดการ path ของรูปภาพ input และ target segmentation masks</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M7ZEMDrfKnJA_kncB17lPw.png" /></figure><p>เมื่อจัดการเสร็จแล้ว ก็มา visualize ดูกันค่ะว่า input และ target masks ของเราเป็นยังไง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ah2BxPwH1mWFlnxbaU4SQw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*fKwMkHwfKJQoUbNka8QkkA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*7CO1aBuJV8DvrAKzk9hzDg.png" /></figure><p>และนี่ก็คือตัวอย่าง input ของ UNet-like network</p><p>3. สร้าง class พร้อมกับจัดเตรียมข้อมูลในรูปแบบ batches</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XDvVc7FB6xU2TGnG3Ht48g.png" /></figure><p>4. จัดเตรียม U-Net Xception-style model</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*x50rvD-GD4AOj_va8en18A.png" /></figure><p>5. Train model!!</p><p>แต่ก่อนที่เราจะ train โมเดลกัน เราจะต้องแยกข้อมูลเป็นสองส่วนก่อน ให้ส่วนนึงเป็น train data และอีกส่วนเป็น validate data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wnXq_18fEbg2WPgC_Brqbw.png" /></figure><p>เทรนโมเดลกันเลย โดยกำหนดให้โมเดลเทรนทั้งหมด 15 epochs (อย่าลืมเปลี่ยนเป็น runtime GPU ก่อนนะ)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pM7T7ziBTbpBT8aNs9_0-Q.png" /></figure><p>สุดท้าย เราก็มาดูกันว่าโมเดลของเราทำนายถูกหรือเปล่า</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gc89XN-nHdMRB5VDns-oAg.png" /></figure><p>นี่ก็คือผลลัพท์ของ UNet-like Network</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*j2E5Z_45_UxwjWiqVUD9Pg.jpeg" /><figcaption>Real Image</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*lSXeE2bmIB7Qp1bAwZHQcA.png" /><figcaption>Mask</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/160/1*8XYVtx4gkS0H0wSTWkrasg.png" /><figcaption>Predicted mask</figcaption></figure><p>สรุป</p><ul><li>UNet-like Network สามารถทำการโลคัลไลเซชั่นภาพได้โดยการคาดคะเนพิกเซลภาพทีละพิกเซลได้ แต่โค้ดนี้อาจจะต้องใช้เวลาในการเทรนนานกว่านี้หน่อย</li><li>Network มีความแข็งแกร่งเพียงพอที่จะทำการคาดการณ์ที่ดีโดยอาศัยชุดข้อมูลเพียงไม่กี่ชุดโดยใช้เทคนิคการเพิ่มข้อมูลที่มากเกินไป</li><li>สนุกดีค่ะ</li></ul><p>ขอบคุณที่อ่านมาจนจบค่า ถ้าว่างๆและมีโอกาสหน้าจะมาโชว์ของตัวเองบ้างค่า</p><p><a href="https://www.buymeacoffee.com/romrawinjp"><em>☕ เลี้ยงกาแฟได้ที่นี่</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f239d2f50d92" width="1" height="1" alt=""><hr><p><a href="https://medium.com/super-ai-engineer/%E0%B8%A3%E0%B8%B9%E0%B8%9B%E0%B8%99%E0%B8%B5%E0%B9%89%E0%B8%A1%E0%B8%B5%E0%B8%AD%E0%B8%B0%E0%B9%84%E0%B8%A3%E0%B8%9A%E0%B9%89%E0%B8%B2%E0%B8%87-%E0%B8%95%E0%B8%AD%E0%B8%9A%E0%B8%84%E0%B8%B3%E0%B8%96%E0%B8%B2%E0%B8%A1%E0%B8%99%E0%B8%B5%E0%B9%89%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-unet-like-network-f239d2f50d92">รูปนี้มีอะไรบ้าง ตอบคำถามนี้ด้วย UNet-like Network</a> was originally published in <a href="https://medium.com/super-ai-engineer">Super AI Engineer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basic Mathematics behind Machine Learning (with Code): Linear Algebra]]></title>
            <link>https://medium.com/super-ai-engineer/basic-mathematics-behind-machine-learning-with-code-linear-algebra-abc65114fa4?source=rss-65b0790419ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/abc65114fa4</guid>
            <category><![CDATA[general]]></category>
            <category><![CDATA[machchimasuperai]]></category>
            <category><![CDATA[super-ai-engineer]]></category>
            <dc:creator><![CDATA[Romrawin (Jin) Chumpu]]></dc:creator>
            <pubDate>Sat, 23 Jan 2021 12:51:54 GMT</pubDate>
            <atom:updated>2024-03-07T07:22:05.333Z</atom:updated>
            <content:encoded><![CDATA[<h4>The Essential Mathematics you Need to Know</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3kHd1UxjajC4pO5I32S5wg.png" /></figure><h4>Data exists in our world. Machine Learning is a powerful technology for generating data meanings in the twenty-first century. Behind the magic lies a basic mathematical power that is guided step by step along the cutting-edge. As a result of establishing a strong foundation for Machine Learning Parthenon, we are able to comprehend any system under intuitive intelligent applications.</h4><h3>What is Machine Learning Theory ?</h3><p>Machine learning theory or Computational Learning Theory, brings up a merged mathematical fields of probability, statistics, and calculus applied with core computer science, which aims to understand principles of learning process trough algorithmic frameworks. Including the learning from data, Machine Learning aims be a perfect helper for solving human tasks faster, better, and easier ever before.</p><p>Let’s begin with a big picture of the foundations and four pillars of Machine Learning.</p><figure><img alt="Machine Learning Parthenon" src="https://cdn-images-1.medium.com/max/879/1*yqCCbHkT2IYkN5waPk5ynA.png" /><figcaption>The foundations and four pillars of Machine Learning (reference book: Mathematics for Machine Learning <a href="https://mml-book.github.io/book/mml-book.pdf">https://mml-book.github.io/book/mml-book.pdf</a>)</figcaption></figure><p>In this article, we will study together from the bottom up by going through the fundamentals of foundational topics. These subjects will be simply organized as shown below.</p><ul><li>Linear Algebra</li><li>Multivariable Calculus</li><li>Statistics and Probability</li></ul><h3>Linear Algebra</h3><blockquote><strong>Linear Algebra is the mathematics of the 21st century.</strong><br>Do you agree with that?</blockquote><p>Despite the fact that Linear Algebra is used throughout Machine Learning, this presents the fundamental ideas of future implementations.</p><h4>Vectors</h4><p>Data point is represented as a vector. Vector notation can write as vector <strong>a </strong>in blanket of 3 number in row here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wbYZi-xx_t_m20wDn2ubzQ.png" /></figure><pre># Import library<br>import numpy as np</pre><pre># Create a row vector using np.array<br>a = np.array([1,2,3])</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hxW5LS9axxLRggvGME_u6w.png" /></figure><p>A vector has <strong>magnitude (size)</strong> and <strong>direction</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0dfxrgNGD8j_jt9kO1nfEw.png" /></figure><pre># Magnitude of a vector<br>magnitude_a = np.linalg.norm(a)<br>print(&quot;Magnitude of vector a&quot;, magnitude_a)</pre><pre># &gt;&gt;&gt; Magnitude of vector a = 3.7416573867739413</pre><p><strong>A unit vector, </strong>a vector of length 1, is that vector divided by its magnitude.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hAsJJEnTuQ-D1RtScEp6Cg.png" /></figure><pre># find a unit vector of a<br>a_norm = a/magnitude_a</pre><pre>print(&quot;Unit vector = &quot;,  a_norm)<br>print(&quot;Norm of vector unit a =&quot;, np.linalg.norm(a_norm))</pre><pre># &gt;&gt;&gt; Unit vector =  [0.26726124 0.53452248 0.80178373]<br># &gt;&gt;&gt; Norm of vector unit a = 1.0</pre><h4>Vector Operations</h4><ol><li>Addition</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xAjFYbqfTv8Ths1BL6nL1Q.png" /></figure><pre># Define vector a and b<br>a = np.array([1,2,3])<br>b = np.array([3,2,1])</pre><pre># Addition<br>c = a + b<br>print(&quot;Result of vector a + b = &quot;, c)<br># &gt;&gt;&gt; Result of vector a + b =  [4 4 4]</pre><p>2. Multiplication</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sBk4--VXcTkh7Tm5WGAY5Q.png" /></figure><pre># Multiplication<br>m = 2 * a<br>print(&quot;Result of vector 2*a = &quot;, m)<br># &gt;&gt;&gt; Result of vector 2*a =  [2 4 6]</pre><p>3. Subtraction</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ssR6LdDy-sDwAZRBo1LHOA.png" /></figure><pre># Subtraction<br>s = a -b<br>print(&quot;Result of vector a - b = &quot;, s)<br># &gt;&gt;&gt; Result of vector a - b =  [-2  0  2]</pre><h4>Dot product</h4><p>The dot product is an operation that takes two equal-sized vectors and returns a single scalar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Dzsj9jfaIqNO_eB1H5pjQ.png" /></figure><pre># Define r and s vector<br>s = np.array([-1,2])<br>r = np.array([3,2])</pre><pre># 1. method using @<br># Dot product of r and s<br>r_dot_s = s @ r<br>print(&quot;Dot product of r and s using @ = &quot;, r_dot_s)<br># &gt;&gt;&gt; Dot product of r and s using @ =  1</pre><pre># 2. method using numpy.dot<br>r_dot_s = np.dot(s, r)<br>print(&quot;Dot product of r and s using np.dot = &quot;, r_dot_s)<br># &gt;&gt;&gt; Dot product of r and s using np.dot =  1</pre><p>Another way for calculating dot product is using Euclidean vector</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TMegE5purUe_VU8zlcxKxQ.png" /></figure><pre># Define r and s vector<br>s = np.array([-1,2])<br>r = np.array([3,2])</pre><pre># Calculate magnitude of vector<br>unit_s = np.linalg.norm(s)<br>unit_r = np.linalg.norm(r)<br>print(&quot;Unit vector of s = &quot;, unit_s)<br>print(&quot;Unit vector of r= &quot;, unit_r)<br># &gt;&gt;&gt; Unit vector of s =  2.23606797749979<br># &gt;&gt;&gt; Unit vector of r=  3.605551275463989</pre><pre># calculate dot product of s and r if theta = 45 degree<br>theta = 30<br>r_dot_s = unit_r * unit_s * np.cos(theta)<br>print(&quot;Dot product of r and s using geometric definition = &quot;, r_dot_s)<br># &gt;&gt;&gt; Dot product of r and s using geometric definition =  1.2436149470424598</pre><h4>Projection</h4><p>Projection is an operation that the two vectors try to see its shadow into other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EneSOx_GeCazdCUcYxaPCg.png" /></figure><pre># Define r and s vector <br>s = np.array([-1,2])<br>r = np.array([3,2])</pre><pre># Project vector s onto vector r<br>unit_r = np.linalg.norm(r)</pre><pre># Scalar projection<br>scalar_proj_of_s_on_r = (np.dot(s, r)/unit_r)<br>print(&quot;Vector projection of Vector s on Vector r is: &quot;, scalar_proj_of_s_on_r)</pre><pre># &gt;&gt;&gt; Scslar projection of Vector s on Vector r is:  0.2773500981126146</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*URGXSsv9NgtdR_qbEZQccg.png" /></figure><pre># Vector projection <br>vec_proj_of_s_on_r = (np.dot(s, r)/unit_r**2)*r<br>print(&quot;Vector Projection of Vector s on Vector r is: &quot;, vec_proj_of_s_on_r)<br># &gt;&gt;&gt; Vector Projection of Vector s on Vector r is:  [0.23076923 0.15384615]</pre><h4>Matrices</h4><p>Matrix is a form of many simultaneous equations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VldnwPqbeBtONHqDexupUw.png" /></figure><pre># Define matrix A<br>A = np.array([[2, 3], <br>             [10, 1]])</pre><pre># Substitute e1 and e2 by dot product<br>e1 = np.array([1,0])<br>e2 = np.array([0,1])</pre><pre>print(&quot;Substitute e1 = &quot;, np.dot(A, e1))<br>print(&quot;Substitute e2 = &quot;, np.dot(A, e2))<br># &gt;&gt;&gt; Substitute e1 =  [ 2 10]<br># &gt;&gt;&gt; Substitute e2 =  [3 1]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b6QKJ1JYLDMH7QGaNDC0-g.png" /></figure><pre># Therefore<br>tran_matrix = np.array([[1, 0], [0, 1]])<br><br>print(&quot;Result of transformation matrix with magnitude (3,2) = &quot;, A @ (magnitude @ tran_matrix))<br># &gt;&gt;&gt; Result of transformation matrix with magnitude (3,2) =  [12 32]</pre><h4>Determinant</h4><p>In 2x2 matrix, determinant can be easily determine an area of the space between a and d.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Uo_76DdjDmPI5GueRgrqQ.png" /></figure><pre><em># Create matrix</em><br>matrix = np.array([[1, 2, 3],<br>                   [2, 4, 6],<br>                   [3, 8, 9]])<br><br><em># Return determinant of matrix</em><br>print(&quot;Matrix determinant = &quot;, np.linalg.det(matrix))</pre><pre># &gt;&gt;&gt; Matrix determinant =  0.0</pre><p>If the determinant of matrix equal to 0, that mean the matrix is irreversible.</p><h4>Changing basis vector</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NMn-4AuhTxhCElbVSngFzQ.png" /></figure><pre># Find vector in my coordinate<br>b1 = np.array([3, 1])<br>b2 = np.array([1, 1])<br>vec_old = np.array([3/2, 1/2])<br>vec_new = np.array([b1, b2]).dot(vec_old)<br>print(vec_new)<br># &gt;&gt;&gt; [5. 2.]</pre><pre># Find back the bear&#39;s vector from current coordinate<br>b1 = np.array([3, 1])<br>b2 = np.array([1, 1])<br>vec_old = np.array([5, 2])<br>vec_new = np.linalg.inv(np.array([b1, b2])).dot(vec_old)<br>print(vec_new)<br># &gt;&gt;&gt; [1.5 0.5]</pre><h4>Finding Eigenvalues and Eigenvectors</h4><pre># Create matrix<br>matrix = np.array([[1, -1, 3],<br>                   [1, 1, 3],<br>                   [3, 8, 9]])<br><br># Calculate eigenvalues and eigenvectors<br>eigenvalues, eigenvectors = np.linalg.eig(matrix)<br>print(&quot;Eigenvalues&quot;, eigenvalues)<br>print(eigenvectors)</pre><pre># &gt;&gt;&gt; Eigenvalues [ 1.20764732e+01  3.49587014e-16 -1.07647322e+00]<br># &gt;&gt;&gt; Eigenvectors <br>[[-2.28348751e-01 -9.48683298e-01 -8.29408711e-01]<br> [-2.73671900e-01  8.65158497e-17 -2.90214216e-01]<br> [-9.34323573e-01  3.16227766e-01  4.77343586e-01]]</pre><p>Here are basic examples of Linear Algebra calculation with python code. The other topics will continue in the next article.</p><p><em>If you like my blog here, here is the way to </em><a href="https://www.buymeacoffee.com/romrawinjp"><em>buy me a coffee☕</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abc65114fa4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/super-ai-engineer/basic-mathematics-behind-machine-learning-with-code-linear-algebra-abc65114fa4">Basic Mathematics behind Machine Learning (with Code): Linear Algebra</a> was originally published in <a href="https://medium.com/super-ai-engineer">Super AI Engineer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>