<?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 Jonathan Hui on Medium]]></title>
        <description><![CDATA[Stories by Jonathan Hui on Medium]]></description>
        <link>https://medium.com/@jonathan-hui?source=rss-bd51f1a63813------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*c3Z3aOPBooxEX4tx4RkzLw.jpeg</url>
            <title>Stories by Jonathan Hui on Medium</title>
            <link>https://medium.com/@jonathan-hui?source=rss-bd51f1a63813------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 14 Nov 2026 03:37:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jonathan-hui/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[Ask not what AI can do for you — ask what you can do for AI]]></title>
            <link>https://jonathan-hui.medium.com/ask-not-what-ai-can-do-for-you-ask-what-you-can-do-for-ai-67e1a3d2ba0f?source=rss-bd51f1a63813------2</link>
            <guid isPermaLink="false">https://medium.com/p/67e1a3d2ba0f</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Jonathan Hui]]></dc:creator>
            <pubDate>Mon, 02 Nov 2026 15:34:02 GMT</pubDate>
            <atom:updated>2026-11-04T18:52:20.780Z</atom:updated>
            <content:encoded><![CDATA[<p>Remember JFK’s famous quote: “Ask not what your country can do for you — ask what you can do for your country.” A couple of years ago, I encouraged engineers to ask themselves: “What can AI do for you?” But if someone asked me that same question today, I’d say that question may be behind the times. Instead, I’d turn it around and say: “Ask not what AI can do for you — ask what you can do for AI.” Let me take you through the journey that led me to this answer, starting from the beginning.</p><p>I came across a meme like the one below on the internet. I don’t remember the exact details, so I created my own version. Looking at a résumé like the one below, take a couple of minutes to think about whom you would hire as your next software engineer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZvSblcj3CIxaQ7_Wv1n_3A.png" /><figcaption>Image by Author</figcaption></figure><p>Maybe I’m just cursed with thinking differently, but I’d pick the candidate on the left without a second thought.</p><p>Let me tell you a longer story to explain why. Back in 2024, I asked a few senior software engineers how their companies were using AI for coding. What was their company’s strategy? None of the companies really had a strategy. It wasn’t that they didn’t care about AI. They just hadn’t spent much time figuring out how to make it work for them. Some were simply repeating what they’d heard from others: “Sure, AI can generate code fast, but I end up spending more time debugging it. I can still do a better job myself.” In 2025, the answers to these questions have changed. Some junior engineers had decided to give AI a try. Funny enough, it was usually the junior engineers who were the first to jump in. One told me, “I implemented dark mode and layout changes for the entire application in minutes, something that would normally take me a few days or weeks.” Now that got the senior engineers’ attention.</p><p>It’s almost 2027. If your résumé still doesn’t show how you use AI tools in your workflow, you might be in serious trouble soon. At some point, I started wondering why so many senior engineers were still ignoring AI coding tools back in 2025. These were smart, experienced people, so why weren’t they paying more attention? Then I remembered Harvard professor Clayton Christensen and his famous book, <em>The Innovator’s Dilemma</em>. Suddenly, it all made sense.</p><p>When disruptive innovations first emerge, they may address underserved markets that established companies have failed to serve. These innovations offer compelling benefits that attract customers whose needs have not been adequately met. Yet incumbents tend to dismiss them as low-end products serving niche markets that pose little threat to their existing customer base. They believe these innovations lack the critical capabilities and user experience that their mainstream customers demand. As a result, incumbents focus on defending their market position by raising the bar even higher, continuing to do what they already do, only better. They believe that the best way to compete is to excel at their current strategy rather than fundamentally overhaul their strategic priorities in favor of an approach they believe has major flaws. The fundamental problem in this strategy is that these improvements often deliver diminishing returns in customer value. Meanwhile, disruptive innovations continue to improve, gradually moving upmarket and challenging established players from below. Eventually, they reach a point where they meet the requirements of mainstream customers. Combined with the compelling advantages they already offer, this gives customers a powerful reason to switch. By then, incumbents have lost their competitive edge, and it is too late for them to catch up with the fundamental paradigm shift. Unable to adapt or defend their markets, they are displaced entirely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bb4bYKvMbgTaxfhYWJyxEQ.png" /><figcaption>Image by Author</figcaption></figure><p>Think about Borders bookstore. Its leaders weren’t necessarily incompetent. They were running a business model that had worked extremely well for years. In the early days, shopping for books online was not yet considered a compelling alternative to the in-store experience for most consumers. Why would Borders drop everything to chase a niche market that didn’t even offer the experience its existing customers loved? After all, its loyal customers wanted to physically touch and flip through books and take their purchases home the same day. Borders wasn’t blind to the online opportunity. It had tried selling books online, but it fell into the classic trap of <em>The Innovator’s Dilemma. </em>The perceived flaws of online book shopping led them to believe that they could still better serve their customers through traditional bookstores. Rather than treating the emerging competition as a matter of life or death — or even as the only priority that mattered — Borders’ top priority remained what it knew best: more locations, bigger stores, and a better in-store experience. Its own online efforts struggled, and Borders eventually handed its online sales over to Amazon in 2001. We all know how that story ended. Borders went bankrupt in 2011, while Amazon went on to become one of the world’s largest companies.</p><p>If your résumé still describes how software development was traditionally done, you may be in trouble. All these tasks remain important, but they can increasingly be performed by AI rather than by you. I often buy fresh fish directly from fishing boats. One of the fishermen, with no prior coding experience, has already built a ordering app with full account management functionality entirely through vibe coding. When AI asked him whether he wanted to integrate the app with GitHub, he simply said, “Why not?”</p><p>I believe most engineers should already recognize this shift. The real question is: What actions are you taking to adapt to these changes? For senior engineers, instead of just focusing on getting even better at what you already do, ask yourself: What will your role (your target market) look like in 2027, and what are the life-or-death challenges you need to address to serve that market well? Back in 2025, I told engineers that if their companies weren’t giving them opportunities to work with AI-centric workflows, they should at least start a side project on their own. Companies tend to assign senior engineers work they’re already good at, while experimental projects often end up in the hands of junior engineers. Sometimes, senior engineers are too cautious to take bold steps. If you’re still focused on what AI agents cannot do for you today, you may be missing the bigger picture. You’re still trying to improve what you already do using the same old playbook, blinding yourself to what should be your highest priority. Soon, you may find yourself getting better and better at things the world no longer needs, while losing your ability to compete in the world that is emerging. The key issue is not awareness, but knowing what actions to take.</p><p>But does the general public realize what’s happening? Four years ago, I wrote an article expressing my frustration with high schools that were banning the use of AI. To me, the message they were sending students was basically: “Congratulations! We’re preparing you for your future career by making sure you don’t learn how to work the way your future employer will expect you to.” How does that make sense?</p><p>I get it. Many schools, including colleges, are struggling with students using AI to complete assignments and exams. But I think they’re asking the wrong questions. Instead of obsessing over how to stop students from using AI, shouldn’t they be asking how to redesign their courses to prepare students for a world where AI is part of how we work? For professors who ban the use of AI, I have one simple question: Do you expect the world to evolve around your course, or should your course evolve with the world? Every profession will eventually face the same uncomfortable questions and rethink their role. And if you don’t know the answers, or aren’t even trying to find them, you may be in trouble.</p><p>You might be thinking about how to do your current job better and faster with AI. But here’s another uncomfortable question: If AI can help you do your job better, isn’t it also possible that AI could eventually do your job entirely? Isn’t this a version of the dilemma described in <em>The Innovator’s Dilemma</em>? You’re focused on becoming a better version of yourself in your existing role and market, rather than asking what entirely new opportunities AI could create, what new markets might emerge, and what unique value you could bring to them. It’s like Borders believing it could offer customers a better bookstore experience than Amazon, without reconciling itself to the fact that the underlying paradigm would eventually kill its business.</p><p>That leads to the first question: “What can AI do for you?” For high schools and colleges, instead of worrying about whether AI can complete assignments quickly and easily, shouldn’t we be asking whether students can use AI to produce something better than either the student or AI could achieve alone? Personally, I’m not looking for ways AI can help me do things faster. That is boring. I’m looking for things I couldn’t do before.</p><p>Consider this for a moment. If I were a high school student today, what kinds of assignments would I want? I’d want collaborative projects where students work alongside AI. For example, I’d love to work with AI to explore how gene editing could potentially help treat cancer, a complex subject that most students at that age would struggle to understand on their own. I often wondered how much of the basic theory of relativity I could have figured out on my own if I had known what Einstein knew about electromagnetism. Back then, there were no teachers who could help me explore such questions. Fortunately, students today have AI to help them.</p><p>But there are some hard truths behind these ideas. Could AI eventually become the primary means of delivering knowledge, with teachers taking on more of a facilitator role? Remember JFK’s famous quote: “Ask not what your country can do for you — ask what you can do for your country.” A couple of years ago, I encouraged engineers to ask themselves: “What can AI do for you?” But if someone asked me that same question today, I’d say it’s outdated. Instead, I’d turn it around and say: “Ask not what AI can do for you — ask what you can do for AI.” The fundamental difference is between asking what AI can do to help you perform your job and asking what you can do to help AI accomplish its job better.</p><p>Look at what’s happened in mathematics over just the past few months. In September 2026, AI produced a proposed solution to the Navier–Stokes problem, one of the famous Millennium Prize Problems, each carrying a $1 million prize. This was a mathematical challenge that had puzzled some of the world’s best mathematicians for nearly 90 years. By October, AI researchers had released hundreds of manuscripts claiming solutions or major advances on more than 300 open mathematical problems. This is far more disruptive than AI taking over copywriting jobs. The demand for copywriting may still exist, but fewer humans will be needed to do the work. A breakthrough in mathematics is fundamentally different: it could eliminate a huge portion of the work altogether because the underlying problems have already been solved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I1Yo9C3PHa6dmziJan8vDA.png" /><figcaption>Five Stages of Grief (Composed by Author)</figcaption></figure><p>We always thought AI would help us wash the dishes and mop the floors, but instead, it may takes over our professional careers first. This irony reflects Moravec’s paradox, which suggests that high-level reasoning tasks, often considered difficult for humans, can be relatively easy for machines, while basic sensorimotor tasks, such as perception, movement, and physical coordination, can be extraordinarily difficult to automate.</p><p>When ChatGPT’s reasoning capabilities were first introduced, mathematicians began to recognize that a new era of AI-assisted mathematical reasoning was approaching. Many were fascinated by its progress, expecting AI to assist with proofs and discoveries rather than replace human mathematical insight. Today, however, as AI systems demonstrate increasingly advanced mathematical capabilities, reactions appear to have shifted toward anxiety, frustration, and even outrage, with some viewing these advances as unnecessary or uncalled for. Some mathematicians have even raised concerns about the pace of AI development, questioning whether progress should be slowed.</p><p>Once AI can solve mathematical problems more effectively than humans, the question will no longer be how AI can help mathematicians do their jobs better. Proving certain theorems may no longer require human involvement at all. Instead, the more important question becomes: How can humans remain in the loop and work alongside AI to achieve something neither could accomplish alone?</p><p>As AI models become increasingly specialized in specific fields, and if computers prove to be inherently better at reasoning than humans, these questions may no longer be limited to mathematicians. For instance, will AI merely help scientists identify promising targets for cancer treatment, or will it eventually formulate research strategies — generating hypotheses, designing experiments, and determining the next steps — while human scientists take on supporting roles? This picture may create another major paradigm shift in how we define the nature of our jobs.</p><p>Most mathematicians have not yet reached the fifth stage of grief: acceptance. And I think it’s fair to say that perhaps they shouldn’t. But I believe that eventually, we may begin to recognize which mathematical problems AI can already solve and turn our attention to entirely new questions and possibilities we haven’t even imagined exploring. Or perhaps the more important question is no longer how AI can help mathematicians prove theorems, but how humans can inject their intuition, insights, and creativity into AI’s problem-solving process, enabling us to discover something neither could achieve alone.</p><p>When I encouraged people in 2025 to ask, “What can AI do for you?” I didn’t have all the answers for engineers. I still don’t, especially as AI capabilities evolve with every major release. But one thing is certain: this transformation is happening. I also don’t know exactly what I can do for AI, but we should be willing to explore the possibilities. Some companies argue that AI makes them efficient enough to lay off half their workforce. I find this reasoning appalling. If AI enables us to produce so much more, why settle for the same output with fewer people? Is AI really to blame, or were these companies simply inefficient all along?</p><p>This transition will be tough, and we shouldn’t sugarcoat it. But major disruptions also create opportunities for those willing to explore new frontiers. As some readers know, I’m still working on my AI book series. With just two major sections left in one of the books, I’ve discovered that AI can now accomplish in 15 minutes what once took me hours, sometimes producing better results with the right guidance.</p><p>A friend recently asked what value I could still bring to the process. I even wondered whether AI agents could write most of a chapter. If so, how could my contribution make the combined result greater than the sum of its parts? This reinforced my belief that “What can you do for AI?” will soon become an increasingly important question.</p><p>Writing continues to inspire new ideas and insights, and I still believe I can contribute something valuable by working with AI. That’s why I’ll keep writing the book.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67e1a3d2ba0f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nvidia Blackwell GB200 NVL72 & Networking]]></title>
            <link>https://jonathan-hui.medium.com/nvidia-blackwell-gb200-nvl72-networking-e36aade6ced9?source=rss-bd51f1a63813------2</link>
            <guid isPermaLink="false">https://medium.com/p/e36aade6ced9</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Jonathan Hui]]></dc:creator>
            <pubDate>Tue, 10 Feb 2026 00:52:07 GMT</pubDate>
            <atom:updated>2026-02-10T00:52:07.305Z</atom:updated>
            <content:encoded><![CDATA[<p>One might think that winning the AI accelerator market requires designing the most powerful accelerators and memory systems. However, for AI models with trillions of parameters, this alone is not enough. Training such large models may require hundreds of thousands of GPUs.</p><p>Success depends on building a high-performance distributed system that scales efficiently and almost linearly with the increasing number of GPUs. To succeed, several factors are critical: how effectively GPUs are interconnected, and advancements in interconnect technologies that offer low latency and high bandwidth between GPUs and compute nodes. Just as GPUs are designed with domain-specific optimizations, networks must also follow an AI-first design. The design starts with the algorithms and workloads, rather than prioritizing the network itself first. Co-design between hardware and software engineers is crucial. Additionally, total cost of ownership (TCO) is a key consideration, encompassing power consumption, cooling requirements, and potential needs for new infrastructure, such as rack and data center redesigns. A full software ecosystem is equally crucial, ensuring seamless integration of machine learning frameworks, libraries, and tools to optimize both performance and scalability.</p><h3>Disclaimer</h3><p>Both the B300 and Vera Rubin platforms have been announced. As I am in the process of writing a book on deep learning, this article requires some updates and revisions. Fortunately, much of the core content remains valid, so I have decided to release it. In addition, there are several network topologies discussed here that are quite interesting but will not be covered in the book.</p><p>For readers who may be interested, the book has taken a significant amount of effort to write, and I have spent considerable time on topics that are truly worth studying. If you would like to be notified when it is released, please connect with me on <a href="https://www.linkedin.com/in/thejonathanhui/">LinkedIn</a>.</p><h3>NVLink &amp; NVLink Switch</h3><p>NVLink is a high-speed interconnect technology designed for direct GPU-to-GPU communication. It offers significantly higher communication bandwidth and lower latency compared to the traditional PCIe bus. The Blackwell architecture uses the fifth generation of NVLink, with 18 NVLink ports (connections) per GPU and each port providing 50 GB/s of bandwidth in both directions, resulting in a total bidirectional bandwidth of 1.8 TB/s (0.9 TBs for each direction). This enables communication speeds over 14 times faster than PCIe Gen5.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*trxPVMLhZXjFx-tU0wjdag.png" /><figcaption>NVLink (Image by Author)</figcaption></figure><p>NVLink uses point-to-point communication, which can lead to unnecessary separate connections. For example, in tensor parallelism, a model layer’s computation is split across multiple GPUs. Once a GPU completes its portion, it must send the results to all other GPUs. Because of NVLink’s point-to-point nature, a separate connection must be established with each GPU. In an 8-GPU system, this means a GPU must send the same data seven times, leading to inefficient bandwidth usage and increased latency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NP-PVeK9XOvkmrAz8OTMjA.png" /><figcaption>NVSwitch (Image by Author)</figcaption></figure><p>To address the point-to-point communication issue, switches are added between GPUs to eliminate unnecessary connections and provide dedicated communication pathways that are not impacted by other connections. Built on top of NVLink, NVLink Switches offer this solution, though at a higher system cost. These switches use a crossbar architecture to create a non-blocking topology, allowing any GPU to communicate with another without interference from other connections. This ensures that each GPU can connect to any other at full bandwidth, enabling simultaneous communication among all GPUs, regardless of the number of GPUs in the system. For instance, in tensor parallelism, each GPU processes its part of the computation and sends its partial result to a switch just once. The switch then broadcasts the result to all other GPUs in the system. In this process, Nvidia’s Collective Communications Library (NCCL) is used to optimize communication between GPUs, facilitating efficient data exchange and synchronization during distributed computing tasks.</p><h3>Nvidia GB200 NVL72</h3><p>The GB200 NVL72 is a reference design intended to accelerate AI and HPC workloads. It allows third parties, such as system integrators and data center providers, to build large-scale AI infrastructure based on Nvidia’s validated blueprint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sAJeagjxZtuH8bViAnnK8A.png" /><figcaption>GB200 NVL72 (Image by Author)</figcaption></figure><p>The GB200 NVL72 features a rack configuration with 18 compute trays (18 dual GB200 compute nodes), interconnected via 9 NVLink Switch Trays. Each rack in this system operates with a 120kW power load, significantly higher than the typical ~10kW per rack in a conventional data center. While this configuration offers the advantage of a minimal footprint, the substantial increase in power density may slow down the adoption of this form factor due to infrastructure upgrade requirements. The high power density also requires liquid cooling for the system, which helps reduce overall power consumption by lowering the demand on fans.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H_64Zn2CXC6NsrmsJwjfSQ.png" /><figcaption>Compute Tray &amp; NVLink Switch Tray (Image by Author)</figcaption></figure><p>Each compute tray is equipped with two GB200 Grace Blackwell Superchips, each containing two B200 GPUs and one Grace CPU, all connected through a 900GB/s NVLink chip-to-chip interconnect. NVL72 includes a total of 36 Grace CPUs and 72 Blackwell GPUs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*21G1Wc8sP5s_7nM25hgI-Q.png" /><figcaption>GB200 Superchip with NVLink Switch (Image by Author)</figcaption></figure><p>A single Grace CPU consists of 72 Arm Neoverse V2 cores and supports up to 480GB of LPDDR5X memory. The Blackwell-architecture GPU, featuring 208 billion transistors, are manufactured using TSMC’s custom-built 4NP process, a specialized 4-nanometer manufacturing technology. Due to constraints on die size, each GPU is composed of two dies connected by a 10 TB/s chip-to-chip link, creating a unified GPU with 192GB HBM3e memory and 8TB/s memory bandwidth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-UdPJFjXTXWUficKvj3WPg.png" /><figcaption>GB200 NVL72 (Image by Author)</figcaption></figure><p>Each GPU features 18 NVLink ports, and with 4 GPUs per node, this results in a total of 72 NVLink ports per node. To interconnect all the nodes in the GB200 NVL72 system, 9 NVLink Switch trays are required. Each tray houses 2 NVLink chips and offers a total of 144 NVLink ports, with each port capable of delivering 100 GB/s of bandwidth. Each B200 GPU will have a single connection with an NVLink Switch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OBFSnvCTzyHGuub4xAzD9Q.png" /><figcaption>GB200 NVL72 Compute Tray &amp; NVLink Switch Tray (Image by Author)</figcaption></figure><p>NVLink is an inter-chip communication technology that functions and operates much like a memory system. In a 72-GPU rack configuration, each GPU can directly access the memory of any other GPU as if it were accessing its own local memory. The NVLink Switch interconnects each GPU pair at 1.8 TB/s and supports full all-to-all communication across the system. With near-linear scalability, the rack functions like a single GPU, delivering 1.4 exaflops of AI performance and providing 30TB of high-speed memory accessible to all its components. The 4th generation NVLink Switch is the first rack-level switch chip capable of supporting up to 576 fully connected GPUs in a non-blocking communication fabric.</p><p>To host 576 GPUs, it may require using two racks for each set of 72 GPUs instead of just one. This setup enables the integration of additional switches for efficient GPU-to-GPU communication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_3X5_6M_m4qQPRqIqRdSWw.png" /><figcaption>72 GPUs per 2 Racks (Image by Author)</figcaption></figure><p>The diagram below illustrates a potential configuration in which each rack contains 9 NVLink switch trays and 18 compute trays, with each compute tray hosting a single GB200 Superchip rather than the dual-chip setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Llho10nwXBSE_N3WkmzYlQ.png" /><figcaption>576 GPUs with 16 Racks, 9 Switch Trays and 18 Compute Trays per Rack &amp; 1 GB200 per Compute Tray (Image by Author)</figcaption></figure><p>This arrangement frees up half of the ports in each NVLink Leaf Switch tray, allowing them to connect to the spine switches for inter-rack communication. NVLink Switch Tray 1 ports in the leaf switches connect to Plane 1 NVLink switches, Tray 2 ports connect to Plane 2, and so on. As a result, moving data between GPUs across different racks will require only two hops through NVLink switches. This configuration provides a higher CPU-to-GPU core ratio and potentially more memory per GPU, which can improve the performance of recommendation models that rely on massive embedding tables and require more CPU-driven operations.</p><p>The diagram below presents an alternative configuration, where each compute tray continues to host two GB200 Superchips, but the number of compute trays is reduced from 18 to 9 per rack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ldBEMFBw038TARU7AIsRYw.png" /><figcaption>576 GPUs with 16 Racks, 9 Switch Trays and 9 Compute Trays &amp; 2 GB200 per Compute Tray (Image by Author)</figcaption></figure><p>While Google’s TPUs use fiber optics to enhance inter-node communication, especially for higher data transfer rates over long distances, Nvidia employs a selective approach in the GB200 NVL72 system. This system densely interconnects nodes via a copper cable cartridge for leaf switch connections, which is significantly more power-efficient. However, for longer-distance communication, such as between leaf and spine switches, Nvidia relies on optical connections to maintain high bandwidth and low latency across the system.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e36aade6ced9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimization: Calculus of Variations]]></title>
            <link>https://jonathan-hui.medium.com/optimization-calculus-of-variations-8b90908c4508?source=rss-bd51f1a63813------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b90908c4508</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Jonathan Hui]]></dc:creator>
            <pubDate>Wed, 03 Jul 2024 18:30:53 GMT</pubDate>
            <atom:updated>2024-07-03T18:30:53.776Z</atom:updated>
            <content:encoded><![CDATA[<p>To find the optimal values of a function <em>f</em>, we solve for the points where its derivative <em>f</em>’ equals zero.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S6eDZjo2LKLv6Ontdru-ew.png" /><figcaption>Optimal Points of a Function (Image by Author)</figcaption></figure><p>The calculus of variations optimizes functionals, functions that take other functions as input. One application is finding the path of shortest travel time. Here, a path is a function <em>y</em> = <em>f</em>(<em>x</em>), and the travel time <em>T</em> is expressed in terms of <em>f</em>. The optimal path, denoted<em> f</em>*, is the function that minimizes <em>T</em> among all possible paths.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qV66hWWFvDLL_c5bmueJFw.png" /><figcaption>Shortest Path with Functionals (Image by Author)</figcaption></figure><p>Let’s investigate the fastest sailing route from NYC to Morocco, taking into account the impact of trade winds and ocean currents. For a tiny displacement <em>ds</em> along the path, the travel time <em>dt</em> is equal to</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ausoWmwBik-LQjsN940KIA.png" /></figure><p>Combining it with</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RfZSHzxSvpdDr2uTgzgShA.png" /></figure><p>To find the total travel tim, <em>T</em>, we integrate the infinitesimal time element <em>dt</em> along the entire path from <em>x</em>₁ (NYC) to <em>x</em>₂ (Morocco), giving us:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iSYj9reU00llNhd523fQ4Q.png" /></figure><p>The function <em>y</em> = <em>f</em>(<em>x</em>) represents a sailing path, and <em>T</em>(<em>f</em>) calculates the corresponding travel time. This makes <em>T</em> a functional — a function that takes another function as input and returns a scalar value (the travel time). Our goal is to find the stationary function <em>f </em>*(<em>x</em>) of this functional, representing the path with the shortest travel time. i.e. we find <em>y </em>= <em>f*</em>(<em>x</em>) such that a functional <em>I</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W42S3194fzRJZjJCBBEX9g.png" /></figure><p>is stationary with the boundary condition <em>y</em>₁= <em>f</em>(<em>x</em>₁) and <em>y</em>₂ = <em>f</em>(<em>x</em>₂).</p><h3>Announcement</h3><p>Although I haven’t published many articles in 2023 and 2024, these years have been incredibly busy for me. The rapid advancements in AI have inspired me to write a book on Generative AI, a project that has been both challenging and time-consuming. This article is part of a chapter on optimization. However, I cannot include every detail in the book, so I am providing additional information in this article.</p><p>While the book isn’t finished yet, you can stay updated on its progress by following me on Medium or connecting with me on <a href="https://www.linkedin.com/in/thejonathanhui/">LinkedIn</a>. I’ll share an announcement there as soon as it’s ready!</p><h3>Euler-Lagrange Equation</h3><p>Suppose <em>y</em>(<em>x</em>) makes <em>I</em> stationary with the boundary conditions satisfied. We introduce a function <em>η</em>(<em>x</em>). It is a completely random function except its boundary points are zero.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sspjzkdw6MGQcXuJIFlHDA.png" /></figure><p>We define another function ȳ that can represent any function except it has to fulfill the same boundary conditions of <em>y</em>(<em>x</em>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oO3AAlNpljz6gNRlBv2-rQ.png" /></figure><p>If <em>ε </em>= 0<em>, </em>both ȳ and <em>y</em>(<em>x</em>) refer to the same stationary function.</p><p>The first and second derivatives of ȳ w.r.t. <em>ε</em> are</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J6tPCMmeKISevt78k1L_2w.png" /></figure><p>We will need that later. Next, we want to find</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YWPhw4_xo8juhQvTl_Mh5Q.png" /></figure><p>R.H.S. is an integral over <em>x</em>. Therefore <em>I</em> is a function of <em>ε</em> as everything else that depends on <em>x</em> will be integrated over. We just turn this problem into optimizing a single variable <em>ε</em>, instead of a function. Therefore, we can apply the regular calculus to find the optimal ȳ by setting the derivative of <em>I</em> w.r.t. <em>ε </em>to zero. With <em>ε</em> to be zero, ȳ and <em>y</em>(<em>x</em>) refer to the same stationary function. Therefore, we set the derivative of <em>I</em> to be zero with <em>ε</em>=0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QlpeD4S6JmnmFyC-6DTlcA.png" /></figure><p>i.e.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iz4_SuagkSZKdQdhLN01Ow.png" /></figure><p>By applying integration by parts in the second term with <em>η</em>(<em>x</em>₁) = <em>η</em>(<em>x</em>₂) = 0, we get</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ExtuT3Io8JDvxMCrnTiQw.png" /></figure><p>Now combining the result, we get</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ftr7E2gH3kKkanyloYoSAA.png" /></figure><p>Since <em>η </em>is a relatively random function, for the integration to be zero, we need</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jwENsu2HyQFYw4u4wTeOtQ.png" /></figure><p>This is the condition for <em>y</em> = <em>f</em>(x) in making <em>F</em> stationary. And it is called the Euler-Lagrange equation.</p><h3>Shortest Path</h3><p>Let’s use the sailing route problem to demonstrate the Euler-Lagrange equation. We’ll simplify the problem and assume that all external factors, such as ocean currents and winds, do not affect the path, and that the sailing boat moves at a constant speed. In an optimization problem, any constant factor can be ignored. Therefore, the functional III simplifies to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pDOF-KaBkD-HLQ9IO3L-vg.png" /></figure><p>To find the shortest path, we apply the Euler-Lagrange equation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x_39LggwkuIN5D-NVNPLXw.png" /><figcaption>Shortest Path (Image by Author)</figcaption></figure><p>The shortest distance between two points is a straight line.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b90908c4508" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reproducing Kernel Hilbert Space for Machine Learning]]></title>
            <link>https://jonathan-hui.medium.com/reproducing-kernel-hilbert-space-for-machine-learning-8de67b6b5377?source=rss-bd51f1a63813------2</link>
            <guid isPermaLink="false">https://medium.com/p/8de67b6b5377</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Jonathan Hui]]></dc:creator>
            <pubDate>Wed, 26 Jun 2024 23:20:33 GMT</pubDate>
            <atom:updated>2024-06-30T16:16:12.514Z</atom:updated>
            <content:encoded><![CDATA[<h3>Kernel</h3><p>In machine learning (ML), kernel machines utilize linear classifiers, such as SVMs, to solve nonlinear problems. They achieve this by employing a kernel function, which implicitly maps data into a higher-dimensional space, making it linearly separable.</p><p>Let <em>X</em> be a non-empty set, and a kernel <em>k</em> is defined as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8GsT42Lt-fYCVplx.png" /></figure><p>Under this definition, a kernel function <em>k</em>: <em>X</em> x <em>X</em> → ℝ measures the similarity between data points <em>x</em> and <em>x’</em>. For <em>k</em> to be a valid kernel, it must satisfy the condition <em>k(x, x’) = </em>⟨φ<em>(x), </em>φ<em>(x’)</em>⟩, where φ is a mapping from the input space <em>X</em> to a feature space <em>H</em>, and ⟨・ ,・⟩ represents the inner product in the Hilbert space <em>H</em>. This means the kernel value is equivalent to the inner product of the data points’ representations in the feature space.</p><p>However, unlike many other ML algorithms that require explicit transformation of input data into feature vectors using a feature map, kernel methods directly compute similarity using a user-specified kernel function. Even though this kernel function implicitly operates in a high-dimensional, potentially infinite-dimensional feature space, the kernel trick allows us to avoid explicitly computing the feature representations. This technique helps us bypass the significant computational expense associated with such calculations. This implicit operation allows kernel methods to efficiently analyze complex data relationships and facilitate effective pattern recognition and analysis.</p><h3>Function Space</h3><p>In functional analysis, <em>f</em> (・) denotes a function itself, while <em>f(x)</em> represents the specific value that function takes at the input <em>x</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UxcXVbRN3KbGec8J.png" /></figure><p>Consider a function <em>f</em> that takes an input <em>x</em>, where <em>x</em> is a vector defined as (<em>x</em>₁, <em>x</em>₂).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hn0ep5nYOHdTiMgh.png" /></figure><p>The function <em>f</em> (・) is an element of a function space mapping ℝ² to ℝ. In this example, we can represent <em>f</em> (・) as ℝ³ within this function space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/0*Y5H_ioPIxC77zgxG.png" /></figure><p>Given the function</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*K-D_t7ezhaIBoQ7w.png" /></figure><p>The linear functional <em>f</em> can be represented as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2Y1AMvthjnsWPlHo.png" /></figure><p>In certain function spaces, such as those used in machine learning with kernel methods, functions can be written as linear combinations of the features 𝜙(𝑥). The evaluation of <em>f</em> at <em>x</em>, 𝑓(𝑥), is an inner product in the feature space:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*u4F_MAxeMsPEZn3d.png" /></figure><p>For example, <em>f</em> evaluated at <em>x</em> = (-1, 4) equals</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oYR6qX7pEZwi325q.png" /></figure><h3>Feature Space in Infinite Dimension</h3><p>This concept naturally extends to infinite-dimensional feature spaces. For instance, we can expand the exponential function <em>eˣ</em> using its Taylor series representation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*39uxsatwiBW4Yv5m.png" /></figure><p>and <em>e</em>³ becomes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*x9z1Lvv72CFK3rjO.png" /></figure><p>Here, the feature space is in an infinite dimension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*W9WZk-MHx_nEF0D1.png" /></figure><h3>Evaluation Functional</h3><p>Functionals map vectors to scalars. An evaluation functional <em>L</em> at <em>x </em>∈ <em>X</em> is defined as the map:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aCl8UP-DgS0ui606.png" /></figure><p>This definition broadens our perspective as <em>L</em> is a functional parameterized by <em>x</em> that takes a function <em>f</em> as input and produces a real number ℝ.</p><p>Linear functional is a functional that preserves the operations of vector addition and scalar multiplication, as illustrated below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xjHH4psE57bhmY9t.png" /></figure><h3>Dual Space</h3><p>The dual space of a vector space <em>V</em> is the set of all linear functionals on <em>V</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*naHk7SvO0dwIXJjl.png" /></figure><p>Consider the familiar 3D space, denoted as ℝ³, where each point is represented by a vector with three components (<em>x</em>, <em>y</em>, <em>z</em>). This is our original vector space <em>V</em>. A linear functional on ℝ³ is a linear map that takes a 3D vector as input and produces a single real number as output. For example, a linear functional could be defined as: <em>f</em>(<em>x</em>, <em>y</em>, <em>z</em>) = 2<em>x</em>+3<em>y</em> + 4<em>z</em>. The dual space of ℝ³, denoted as <em>V</em>*, is the set of all possible linear functionals on ℝ³. Each functional in this dual space can be uniquely represented by a 3D vector. For example, the functional <em>f</em>(<em>x</em>, <em>y</em>, <em>z</em>) = 2<em>x</em>+3<em>y</em> + 4<em>z</em> can be represented by the vector (2, 3, 4).</p><h3>Riesz Representation Theorem</h3><p>The Riesz Representation Theorem states that every continuous linear functional <em>L</em> on a Hilbert space can be represented as an inner product with a fixed element in <em>F</em>. Formally, for any continuous linear functional 𝐿 on a Hilbert space <em>F </em>’,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dZ_0xNYSAhFzveBf.png" /></figure><p>The Riesz Representation Theorem bridges the abstract world of linear functionals with the more familiar concept of inner products, allowing us to understand and manipulate linear functionals using the geometric intuition of inner products. In essence, the Riesz Representation Theorem states that for every continuous linear functional on a Hilbert space <em>H</em>, there exists a unique element within that same space <em>H</em> that fully characterizes the functional. This means the linear functional can be thought of as an inner product with a fixed “representative” vector. This establishes a fundamental connection between linear functionals and inner products in Hilbert spaces. In the context of Reproducing Kernel Hilbert Spaces (RKHS), this concept is extended to show that the evaluation of functions can be computed using inner products with kernel functions.</p><h3>Reproducing Kernel</h3><p>Combining the evaluation functional with the Riesz Representation Theorem, we obtain:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7A0xlAyIcCfmBK_t.png" /></figure><p>Any function <em>f</em> ∈ <em>F</em> evaluated at <em>x</em> can be represented as an inner product between <em>f</em> and a unique a unique functional <em>kₓ </em>∈ <em>F, </em>where <em>kₓ </em>can be written as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4XZ3MqhPc-6f3U6G.png" /></figure><p>Let’s replace <em>x</em> with <em>y</em>, we get</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*30dGdaXz6YVMPaVX.png" /></figure><p>Since <em>kₓ </em>∈ <em>F, </em>let’s replace <em>f</em> ∈ <em>F </em>with <em>kₓ </em>and we get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4eYfqFeDUWu3LvIO.png" /></figure><p>This essentially brings us back to the idea of a kernel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EUy5F_UAu6uJtfm9.png" /></figure><p>In summary, the evaluation functional <em>L</em>ₓ can be written with <em>k</em>( ⋅ , <em>x </em>) as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YJmJ4MDBMDhKIvSY.png" /></figure><p>It can be computed as the inner product of <em>f</em> with a kernel function in the Hilbert space 𝐻. The function 𝑘(⋅, 𝑥) or <em>kₓ</em> is called the <strong>reproducing kernel</strong>.</p><p>Hence,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gmzJ90woY_TEtSWe.png" /></figure><p>Here is the notation used, which all referring to the same object:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LVMU9Y2tRCPYpytc.png" /></figure><h3>Reproducing Kernel Hilbert Spaces (RKHS)</h3><p>A Reproducing Kernel Hilbert Space (RKHS) is a Hilbert space of functions in which evaluation at each point is a continuous linear functional. This means that for any function <em>f</em> in the space and any point 𝑥, there exists a kernel function <em>k</em> such that 𝑓(𝑥) = ⟨𝑓,𝑘(⋅, 𝑥)⟩. The kernel function 𝑘(⋅,𝑥), known as the reproducing kernel, acts as a bridge between the function and the feature space, allowing us to evaluate the function at specific points.</p><p>In essence, <em>f</em>(<em>x</em>) can be represented as the inner product of <em>f</em> with the reproducing kernel function <em>k</em>(⋅, <em>x</em>). The function <em>k</em>(⋅, <em>x</em>) is called the reproducing kernel. Conceptually, the evaluation function can be computed by the inner product of <em>f </em>and the feature space representation of <em>x</em>.</p><h3>Example: Approximating a Function using RKHS</h3><p>Suppose we have a set of data points and we want to approximate a function that fits these points using the Gaussian kernel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gPKbpoTdkELikjq1rW2_DA.png" /><figcaption>RKHS Example (Composed by Author)</figcaption></figure><p>The final steps involve solving for α and using it to compute <em>f</em>(<em>x</em>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4fVNVeIvWDc6hqs6OI5B7A.png" /><figcaption>Function Evaluation in RKHS (Composed by Author)</figcaption></figure><p>So, the approximate value of the function at <em>x</em> = 1.5 is <em>f</em>(1.5) ≈ 3.05.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8de67b6b5377" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RegNet]]></title>
            <link>https://jonathan-hui.medium.com/regnet-adb67ecb8ccd?source=rss-bd51f1a63813------2</link>
            <guid isPermaLink="false">https://medium.com/p/adb67ecb8ccd</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Jonathan Hui]]></dc:creator>
            <pubDate>Mon, 10 Jun 2024 21:41:02 GMT</pubDate>
            <atom:updated>2024-06-10T21:41:02.899Z</atom:updated>
            <content:encoded><![CDATA[<p>NAS-like methods explore a search space to find optimal models for specific tasks. In contrast, RegNets take a systematic approach by analyzing and refining a pre-defined architectural design space. Their primary goal is to identify general design guidelines for model parameters that lead to optimal performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eaPXmFiHhFQKFCe8Un_HHA.png" /><figcaption>RegNets v.s. NAS-like Solutions (Image by Author)</figcaption></figure><p>Both methods start with a general pre-defined architectural design. As suggested by the term ‘search space,’ NAS-like methods search this space, using educated guesses or trained policies, to find optimal models. In contrast, RegNets focus on identifying design guidelines that exhibit strong performance and generalization abilities across various contexts, including different hardware platforms and tasks. These guidelines are refined through an incremental manual process, narrowing the design space into an optimal design space that informs how to design model parameters. Sampling this space to locate the optimal model is more of a bonus than the primary objective.</p><p>RegNets introduce a design space called AnyNetX, as depicted below. Each network within this space features a standard architecture consisting of a stem, a body, and a head for generating final predictions, as illustrated in the left-most part of the diagram. By sampling models with specific variations of model parameters and evaluating their performance, RegNets uncover patterns and trends. Specifically, they select guidelines that not only lead to better performance but also suggest design simplifications when no performance loss is observed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7NUFU2IWQbJRZ4JzTv0eKg.png" /><figcaption>AnyNetX Design Space (Image by Author)</figcaption></figure><p>The body contains multiple processing stages, and each stage (<em>i</em>) consists of <em>dᵢ</em> blocks. The total number of blocks across all stages is denoted by <em>d</em>. All blocks utilize a 1×1 convolution to extract features across channels, followed by a group convolution, and finally, another 1×1 convolution. But for Block 1, a stride-2 group convolution is employed to reduce spatial resolution.</p><p>AnyNetX offers control over four essential parameters:</p><ol><li><strong>Model Depth </strong>(<em>d</em>).</li><li><strong>Channel Width</strong> (<em>w</em>₁, <em>w</em>₂, <em>w</em>₃, and <em>w</em>₄): Determines the width of channels for each stage.</li><li><strong>Bottleneck Ratio </strong>(<em>b</em>ᵢ): This modifies the channel width in the initial 1×1 convolution of every block.</li><li><strong>Group Width </strong>(<em>g</em>ᵢ): Specifies the group convolution width in each block.</li></ol><p>By analyzing the performance of sampled models across various configurations, the study proposes general guidelines to narrow down the design space further:</p><ul><li>Use a single bottleneck ratio (<em>b</em>ᵢ = <em>b</em>) value and a single group width (<em>g</em>ᵢ = <em>g</em>) value for all stages.</li><li>Increase the channel width <em>w</em>₁, <em>w</em>₂, <em>w</em>₃, and <em>w</em>₄ progressively.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8hkCSN9x4TBJJ_Zbon7MwQ.png" /></figure><ul><li>Gradually increase the number of layers (<em>dᵢ</em>) within each stage of the neural network, except for the final stage.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ayLuDPDckAd6BlWl7OFI6g.png" /><figcaption>An example for the network depth for each stage with d = 16</figcaption></figure><p>Another significant finding reveals a linear correlation between the channel width <em>u</em>ⱼ and the model depth index (denoted by <em>j</em>), with <em>w</em> representing the hyperparameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E_XEX4jC1iv8e5QRYhcuVA.png" /></figure><p>But the computed <em>u</em>ⱼ is a real number, and we need an integer for the channel width. Hence, we will apply a two-step process to quantize the value into an integer. First, we find sⱼ with the following progressive growth formula, with <em>w</em> representing the hyperparameters again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vXpQiyKbNdFYoAZEMa3lbA.png" /></figure><p>Next, we apply the quantization function below to determine the channel width <em>w</em>ⱼ for index <em>j</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R3QIHQVDDdAFFFLOV2ZYdA.png" /></figure><p>These guidelines reduce the design space into one referred to as RegNetX, a name derived from the paper’s objective to create a design space filled with simple, regular models.</p><p>After further refinement of the RegNetX design space, it reveals interesting findings that diverge from current network design practices. Remarkably, it challenges the widespread belief that greater model depth leads to better performance, revealing instead that the optimal models in RegNetX typically consist of around 20 blocks. Furthermore, best models in RegNetX achieve optimal performance by eliminating the bottleneck entirely through a bottleneck ratio of 1.0, a strategy that has been embraced by some other studies. Furthermore, the traditional practice doubles the channel width from one stage to another. However, the RegNetX study favors a value close to 2.5 for peak performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TveTZuCqP_xBvdkFaN-hCw.png" /><figcaption>Image by Author</figcaption></figure><p>The final analysis focuses on RegNetX models that have been enhanced with the Squeeze-and-Excitation (SE) operation. This enhancement results in the creation of a new design space known as RegNetY. The integration of the SE operation, which adaptively recalibrates channel-wise feature responses by explicitly modeling interdependencies between channels, significantly boosts the representational power of the network. Consequently, the RegNetY design space demonstrates notable performance gains compared to the original RegNetX models.</p><h3>Announcement</h3><p>Generative AI has been an exciting area of development in recent years, sparking my interest in writing a book on the topic. RegNets are fascinating models that I’ve invested considerable time in studying. However, they didn’t quite fit the book’s main focus. However, I believe they hold valuable insights that are worth exploring. Instead of discarding them, I’ve decided to share these insights through a series of articles on Medium.</p><p>While the book isn’t finished yet, you can follow its progress and be among the first to know when it’s complete by connecting with me on Medium or <a href="https://www.linkedin.com/in/thejonathanhui/">LinkedIn</a>. Stay tuned for the official launch announcement!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=adb67ecb8ccd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kernels for Machine Learning]]></title>
            <link>https://jonathan-hui.medium.com/kernels-for-machine-learning-3f206efa9418?source=rss-bd51f1a63813------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f206efa9418</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Jonathan Hui]]></dc:creator>
            <pubDate>Mon, 27 May 2024 22:33:58 GMT</pubDate>
            <atom:updated>2024-05-28T13:42:06.437Z</atom:updated>
            <content:encoded><![CDATA[<p>In many machine learning problems, input data is transformed into a higher-dimensional feature space using a non-linear mapping to make it easier to find patterns or separate classes. Subsequently, linear models can project this feature space into a one-dimensional space for classification. For example, in the left diagram below, the red and blue dots cannot be separated by a straight line in their original two-dimensional space. However, when transformed into a three-dimensional space using a non-linear function, a plane can successfully separate the two classes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fXYqOS-rySD9Z1KyJbULFg.png" /><figcaption>Projection onto Higher Dimensional Space (Image by Author)</figcaption></figure><h3>Motivation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LlAXJzA6DJOdm9iWIJTodA.png" /></figure><p>Kernel functions offer a principled approach to detecting nonlinear relationships using linear algorithms. This is achieved by implicitly mapping the original input data into a feature space where the data might become linearly separable. For example, with the mapping 𝜙(<em>x</em>) = <em>x</em>₁² + <em>x</em>₂², the red and blue dots in the diagram above are now linearly separable in this newly transformed feature space, as opposed to their original input space.</p><p>However, in real-world problems, the feature space is often high-dimensional to untangle complex data, and the mapping <em>ϕ</em> is usually unknown. However, we can use machine learning or deep learning techniques to model <em>ϕ</em>. Once modeled, a linear algorithm such as Support Vector Machines (SVM) can be applied to the feature space. In the example below, a 2D input can be transformed into a pre-assumed 9D feature space using a third-degree polynomial. Then, inferences are made with the linear model <em>θ</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8nrlAnzE-BEF83AA63ixSw.png" /></figure><p>However, in dealing with high-dimensional feature space, the transformation complexity becomes significant. In particular, 𝜙 can map to and often map to infinite-dimensional feature space. Computing an infinite number of components is infeasible. What makes kernel methods stand out is that it can handle high-dimensional and infinite features efficiently with the kernel trick.</p><h4>Kernel Trick</h4><p>Let’s demonstrate the method the hard way first, before introducing the kernel trick to make it more efficient. In kernel methods, we often utilize the similarity between an input data point and the training dataset to make predictions. A common approach involves calculating the inner product of two points after they have been transformed into a higher-dimensional feature space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*vQP7VqxZtCHp0UkGmMmjQg.png" /></figure><p>In the example below, φ(<em>x</em>) represents a mapping function that transforms an input vector <em>x</em> = (<em>x₁</em>, <em>x₂</em>) into a feature space defined by a second-degree polynomial:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SqsDvY_VRvf2Dx2BcuWm4A.png" /></figure><p>Given two data points <em>x </em>= (1, 2) and <em>y</em> = (3, 4), the inner product in the basis (1, <em>x</em>1​, <em>x</em>2​) is 12.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A76dzihtxXW91mW2qmtynw.png" /></figure><p>Let’s compute the inner product in the feature space. The result is 144.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-OuqWgSp5K8Yt3BvJwrxsw.png" /></figure><p>In this process, the feature mapping 𝜙 transforms the input vectors into a higher-dimensional space. Subsequently, the inner product reduces the result back to ℝ. Since the final result is a scalar in ℝ, we might question whether these transformations are necessary. In other words, can we find an equivalent function that directly computes the result without explicitly calculating 𝜙(x) and 𝜙(y)?</p><p>In our example, we observe that the final result (144) is simply the square of the inner product of the original input vectors (12² = 144). It can be shown through algebraic expansion that these two calculations are indeed equivalent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ex3d_5PALAE5xljs7CdEPQ.png" /></figure><p>In this example, the kernel function <em>k</em> is defined as the square of the inner product between the augmented vectors (1, <em>x₁</em>, <em>x₂</em>) and (1, <em>y₁</em>, <em>y₂</em>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*37kXKdKGHNGTqDcp4vPl-A.png" /></figure><p>This is the essence of the <strong>kernel trick</strong>: the inner product of two vectors in a high-dimensional (or even infinite-dimensional) feature space can be computed efficiently using a kernel function in the original input space, bypassing the need for explicit feature mapping. This efficiency becomes particularly significant in infinite-dimensional feature spaces, where direct computation of the inner product would be impossible, but the kernel trick remains feasible.</p><p>Can this kernel trick be generalized? Indeed, for any <em>ϕ</em>, there exists a corresponding kernel <em>k</em>. For example, to raise an input space to a higher-degree polynomial, the corresponding kernel is simply:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cari9RIWK0LhnNGJwJH9PQ.png" /></figure><p>However, our primary objective is not to explicitly find the feature space, which is generally unknown. Instead, we focus on the result, <em>k</em>(<em>x</em>, <em>y</em>), not the feature mapping 𝜙(x). In fact, we often design kernels directly without explicitly constructing or even knowing the corresponding feature space.</p><p>In fact, it is more intuitive to think in terms of kernels than feature spaces. For instance, if the similarity between neighboring points can be modeled with a Gaussian distribution, a Gaussian kernel would be a natural choice. As show later, this kernel corresponds to a feature space with infinite dimensions, theoretically allowing for arbitrarily complex decision boundaries.</p><blockquote>If we can find a kernel that effectively solves machine learning problems, that is sufficient for our purposes. Understanding the feature space is a bonus, but it is not necessary for kernel design.</blockquote><h3>Announcement</h3><p>Generative AI has been an exciting area of development in recent years, sparking my interest in writing a book on the topic. This project has been both immensely challenging and rewarding. During the writing process, I discovered many captivating subjects that didn’t quite fit the book’s main focus but still held valuable insights. These topics may be a bit raw due to time constraints, but I believe they’re worth exploring. Instead of discarding them, I’ve decided to share them through a series of articles on Medium.</p><p>While the book isn’t finished yet, you can follow its progress and be among the first to know when it’s complete by connecting with me on Medium or <a href="https://www.linkedin.com/in/thejonathanhui/">LinkedIn</a>. Stay tuned for the official launch announcement!</p><h3>Kernel</h3><p>Let&#39;s give an official definition for a kernel.</p><p><strong>Definition</strong>: Let <em>X</em> be a non-empty set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QaExVIhdJnmXhfmA8xz_bw.png" /></figure><p>For every valid kernel function, there exists at least one corresponding feature space where the kernel can be represented as an inner product of the feature space.</p><h3>Radial Basis Function Kernel (<strong>RBF kernel)</strong></h3><p>Just for better understanding, let’s examine the feature spaces associated with the RBF kerne, which is defined as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w1B4ciLRKHeXaOVJzKF8-A.png" /></figure><p>The RBF kernel implicitly maps data into an infinite-dimensional feature space. To analyze the RBF kernel, we can utilize the Taylor expansion of the exponential function. The Taylor expansions of exp(<em>x</em>) and exp(<em>x x</em>’) are:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zSYMl8oVEhjagY2cdDn__Q.png" /></figure><p>Using the last Taylor expansion, the RBF kernel becomes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uugsK_cNED4So5Z4Nm4E4Q.png" /></figure><p>The RBF kernel implicitly maps data into an infinite-dimensional feature space 𝜙 below. This infinite-dimensional nature allows the RBF kernel to model highly complex decision boundaries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*ZmWqv9jBR2XPbhoNuTFTVg.png" /></figure><h3>Positive Definite Functions</h3><p>Not all functions can be valid kernels. They must be positive semidefinite.</p><h4>Definition</h4><p>A function <em>k</em>: <em>X </em>× <em>X </em>→ R is positive semidefinite if, for any vectors <em>a</em> in in ℝⁿ and <em>xᵢ</em> in <em>X</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*URWzTsygMB1Ke6WEceZLVw.png" /></figure><p>it fulfills the condition:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BhgEIxeACQxCTXysnmOBwA.png" /></figure><p>In simpler terms, this means the function always yields a value greater than or equal to zero, regardless of the input values. If it equals zero only when 𝑎ᵢ =0 or <em>a</em>ⱼ= 0 , the function is called positive definite.</p><h4>Kernels are Positive Semidefinite</h4><p>A continuous or finite-domain function <em>k</em> can be represented as the inner product of feature mappings in a Hilbert space <em>H</em> if and only if <em>k</em> is a positive semi-definite function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DdHmOBQxz2obqQ1HMrlYlA.png" /></figure><p>As shown below, if a function <em>k</em> can be represented as an inner product in a feature space, then <em>k</em> is positive definite.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J3gPqZh5cajQ602NqQd6eA.png" /></figure><p>Furthermore, since the inner product is symmetric, any kernel function derived from the inner product must also be symmetric (<em>k</em>(<em>x</em>, <em>y</em>) = <em>k</em>(<em>y</em>, <em>x</em>)). This requirement for symmetry, combined with the requirement for positive definiteness, establishes a theoretical framework for constructing and validating new kernel functions.</p><h4>Kernel Matrix</h4><p>Or equivalently, for a function to be a valid kernel, the associated kernel matrix must be semipositive definite.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dJMw-KyrN7s_lIINhnoJ5A.png" /></figure><p><strong>Definition: </strong>A <em>n</em>×<em>n </em>matrix <em>K</em> is positive semidefinite if</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*y9BTWLmYcZ7cqWC-k27EdA.png" /></figure><h4>Mercer’s Theorem</h4><p>We show that kernel functions are positive semidefinite. Mercer’s theorem states the converse is also true: any positive semidefinite function can be represented as the inner product of vectors in a corresponding feature space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SQTgXlswmQTD9sm78710mQ.png" /></figure><h3>Ridge Regression</h3><p>In this section, we will use Ridge Regression to demonstrate how to perform inference with the kernel function. In linear regression, Ridge Regression minimizes the mean squared error of predictions while also incorporating an 𝐿2 regularization term to prevent overfitting. The prediction for a data point <em>x</em> is equal to <em>θ</em>ᵀ<em>x</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k5Tp4H40uOYO2D4sgs3FLA.png" /></figure><p>To find the optimal <em>θ</em>, we set the gradient of the objective function with respect to <em>θ</em> to zero and solve for <em>θ</em>. This yields the following closed-form solution:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KwkgcEW0gSOZh9VTO6iJNw.png" /></figure><p>We can express <em>θ</em> in the form of <em>X</em>ᵀ <em>α</em>, where <em>α</em> is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3daOBoCR1e6tfkQkag7trA.png" /></figure><p><em>G</em> is called the Gram matrix, which is computed as <em>XX</em>ᵀ and is therefore symmetric.</p><p>Given a new input <em>x</em>, a prediction can be made using <em>f</em>(<em>x</em>) = <em>θ</em>ᵀ<em>x = </em>⟨<em>θ, x</em> ⟩.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yWZ3KNZI9j2l59GBckowSQ.png" /></figure><p>This solution can be recognized as a linear combination of the inner products between the training data points and the new example 𝑥.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EvpKMyNgEmoEd0-kwdbHng.png" /></figure><p>The coefficients <em>α</em> are derived from the Gram matrix <em>G</em>. This implies that we do not directly model the parameters <em>θ.</em> Instead, we utilize the training data itself to make predictions. This approach is a defining characteristic of non-parametric machine learning models.</p><p>Finally, we can make one more improvement: instead of using <em>x</em> as the input, we use its feature space representation <em>ϕ</em>(<em>x</em>). This applies to both the inner product and the Gram matrix. Here, the matrix <em>G</em> is also referred to as the Kernel Matrix.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DOV0dqzrzUXA_Zhf1OvEZg.png" /></figure><p>The new prediction will be a linear combination of the inner products between the features of the training data points and the features of the new example <em>x</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JX-xYqoOeD8rW3RXGZ1STA.png" /></figure><h3>Kernel Design</h3><p>We can combine kernels to design new ones. For example, adding two valid kernels together or multiplying a kernel by a positive scalar results in another valid kernel. Furthermore, multiplying two valid kernels together also forms a new valid kernel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kmktyp_MDuJ6Mp722YpbIQ.png" /></figure><p>Here is a list of common kernels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NUND2loq-EiFQiLf12z22A.png" /></figure><p>Let’s prove that the Gaussian kernel is a valid kernel by expressing it as the product of three exponential functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l0qVW32Zb03INv7eBqR0pQ.png" /></figure><p>According to the rule</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ll9_5iT8138QikOYQXVVgw.png" /></figure><p>the first two terms forms a kernel</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9LWuH9D-FhrI-je-sBYX3Q.png" /></figure><p>The third term is also a valid kernel. To see this, we note that the inner term is itself a kernel, as it is formed by the product of two functions, <em>f</em>(<em>x</em>) and <em>f</em>(<em>y</em>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vI-hCYSb2p7aPKLupM1JOg.png" /></figure><p>Using the Taylor series expansion, we can express the exponential function within the Gaussian kernel <em>k</em>₁ as an infinite sum of polynomial terms. Since both the sum and product of valid kernels are also valid kernels, we can conclude that the third term is indeed a valid kernel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fc9dyKJInB00A-JoPWvXRA.png" /></figure><p>By the product rule again,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0c1YX2UrXfeS0-yIyipFAw.png" /></figure><p>we can prove Gaussian kernel is a kernel.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f206efa9418" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vector Space, Normed Space & Hilbert Space (Machine Learning)]]></title>
            <link>https://jonathan-hui.medium.com/vector-space-normed-space-hilbert-space-machine-learning-b43e5d0ac9d3?source=rss-bd51f1a63813------2</link>
            <guid isPermaLink="false">https://medium.com/p/b43e5d0ac9d3</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[aritificial-intelligence]]></category>
            <dc:creator><![CDATA[Jonathan Hui]]></dc:creator>
            <pubDate>Mon, 20 May 2024 20:20:03 GMT</pubDate>
            <atom:updated>2024-05-21T15:43:02.020Z</atom:updated>
            <content:encoded><![CDATA[<p>Euclidean space, the familiar geometry of our everyday world, provides a useful framework for understanding basic geometric concepts like angles and distances between points, lines, and planes. But in machine learning (ML), where data can be abstract, we need to venture beyond these familiar boundaries. To tackle the diverse challenges in ML, we turn to more abstract mathematical spaces that offer a richer framework for understanding and manipulating data.</p><p>Feature spaces, where each data point is represented as a vector, are crucial for algorithms to identify patterns and make predictions. Metric spaces equip these feature spaces with a distance function, allowing for measuring similarity between data points. Hilbert spaces, a specific type of metric space with additional properties like completeness and an inner product, are particularly useful for kernel-based methods such as SVM.</p><p>Their role is less prominent in deep learning, where complex non-linear models often rely more on empirical experimentation and intuition-driven design. However, this article seeks to demystify the mathematical terminology prevalent in research papers that utilize mathematical spaces, making the concepts more accessible and less intimidating for readers.</p><h3>Prerequisite</h3><p>This article assumes familiarity with the basic terms outlined in the previous article titled “<a href="https://medium.com/@jonathan-hui/the-study-of-mathematical-spaces-machine-learnin-d5b576640f8e">The Study of Mathematical Spaces (Machine Learning)</a>”.</p><h3>Metric Space</h3><p>While the concept of distance between two points is familiar, the power of metric spaces lies in extending this concept to less intuitive mathematical objects, allowing us to apply the properties and operations of metric spaces in broader contexts.</p><p>To refresh our understanding, a metric space, denoted ⟨<em>M</em>, <em>d</em>⟩, is essentially a set <em>M</em> along with a well-defined distance function (metric) <em>d</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x5on7N8EbYbY92IZz0MYzw.png" /></figure><p>The metric <em>d</em> is a function that formalizes the notion of distance between elements of the set <em>M</em>. L1 and L2 distances are some popular examples for the metric in ML.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qNuhmERXn6mS11DHQYlktQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PLh9dcaRkqw4-JmgWPk9_A.png" /></figure><p>To qualify as a metric function, three simple conditions must be satisfied.</p><ul><li><strong>Non-negativity</strong>: 𝑑(𝑥,𝑦)≥0<em>.</em></li><li><strong>Symmetry</strong>: The distance is the same in both directions.</li><li><strong>Triangle Inequality</strong>: The direct route is the shortest.</li></ul><p>This level of abstraction offers considerable flexibility in defining a metric. Consequently, it grants substantial freedom to design metrics tailored to specific mathematical objects and problems. The goal is to find a metric that proves beneficial in solving your particular challenges. A notable example is the Wasserstein metric, which quantifies the similarity between two probability distributions and has gained popularity as a loss function in Generative Adversarial Networks (GANs).</p><h4>Complete Metric Spaces</h4><p>Completeness is a fundamental property of metric spaces. It means that every Cauchy sequence (a sequence where the terms get arbitrarily close together as they progress) converges to a limit that exists within the space. Formally, a metric space <em>M</em> is complete if every Cauchy sequence in <em>M</em> converges to a point that is also in <em>M</em>. This implies that <em>M</em> doesn’t have any “holes” or “missing points.”</p><p>Completeness is crucial in various mathematical fields because it provides a foundation for analyzing limits and continuity. In machine learning, optimization algorithms like gradient descent rely on convergence properties. Theoretically, if the underlying space is complete, we can be confident that the algorithm will converge to a solution within the space, ensuring the results are meaningful and reliable.</p><h4>Examples</h4><p>Consider the sequence</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h9WN9PCZAcYnUohYU9W8CA.png" /></figure><p>All elements in this sequence are real numbers inside the interval (0,1). But the limit, 1, is not in the interval (0, 1), and therefore the metric space ⟨<em>X</em>, <em>d</em>⟩ for <em>X </em>= (1, 0) with the usual metric 𝑑(𝑥, 𝑦) = |𝑥−𝑦| is not complete. To address this problem, we can expand <em>X</em> to [0, 1], making the metric space complete.</p><p>To assess the completeness of a space, we first need to define a metric. The set of rational numbers equipped with the standard Euclidean metric is not complete. This is because a sequence of rational numbers can converge to an irrational number, which is not part of the rational number set. For example, even we can construct a Cauchy sequence of rational numbers ℚ that converges to the square root of 2. √2 is missing from ℚ.</p><h3>Vector Spaces (Linear Space)</h3><p>Vector spaces not only offer a natural structure to organize data points and features but also underpin linear models, such as linear regression and logistic regression, in many ML algorithms. Additionally, they facilitate the linear transformations central to model optimization. Their impact extends to kernel methods and natural language processing, where they enable the capture of semantic relationships through word embeddings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JG2QqIzyYx3PxCFqKeC8kw.png" /></figure><p>Vector spaces, also called linear spaces, provides a structure for manipulating objects called vectors. These vectors can be added together and multiplied (scaled) by numbers called scalars. Mathematically, a vector space over a field 𝐹 (commonly the real numbers ℝ or the complex numbers ℂ) is a set 𝑉 equipped with two operations: vector addition and scalar multiplication. The set 𝑉 and the operations must satisfy the following axioms, which hold for all elements 𝑢, 𝑣, <em>w</em> in <em>V</em> and all scalars 𝑎, 𝑏 in <em>F</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4z2Aj4DoZFCWbuoPwIPKDw.png" /></figure><p>These operations are closed under <em>V</em>. The addition and the multiplication results remain under the same vector space. Vectors in a general vector space are abstract mathematical objects. They are not limited to the two-dimensional arrows used to represent physical quantities like force or velocity. The concept of a vector is much broader and can encompass many different types of objects.</p><h4>Example</h4><p>Polynomials, like 3<em>x</em> + 4<em>x</em>², <em>x</em> + 2<em>x</em>² + 0.5<em>x</em>⁵, and 5<em>x</em>², form a vector space <em>V</em> over the real numbers. We can add polynomials together and multiply them by real numbers (scalars), and the result will always be another polynomial within the same vector space <em>V</em>. For example, if we add (3<em>x</em> + 4<em>x</em>²) and (<em>x</em> + 2<em>x</em>² + 0.5<em>x</em>⁵), the result is 4<em>x</em> + 6<em>x</em>² + 0.5<em>x</em>⁵, which is also a polynomial in <em>V</em>. Therefore, functions can form a vector space, and each element in 𝑉 is simply a function.</p><h3>Normed Space &amp; Banach Space</h3><p>A normed space is a vector space equipped with a norm, which measures the length or magnitude of its vectors. A Banach space is a complete normed space.</p><h4>Norm</h4><p>The norm of a vector <em>v</em> is written as ‖<em>v</em>‖. It is a function that assigns to each vector in a vector space <em>V</em> a non-negative real number (including zero), representing its length, magnitude, or size. The norm generalizes the familiar notion of length in Euclidean space to more abstract vector spaces.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VqoCBoJFWDXMSgSFplqdCQ.png" /></figure><p>A normed vector space is a vector space defined over the field of real or complex numbers (𝔽 ∈ {ℝ, ℂ}). The norm maps each vector to a scalar in the field 𝔽.</p><p>Any definition of ‖ · ‖ is called a norm if it satisfies the following properties: positive definiteness, absolute homogeneity, and the triangle inequality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KyBZCnZVf4rIeejfBqYoQg.png" /></figure><p>These three rules also imply a norm is greater or equal to 0. This is the reason why we omit it from the norm axioms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oKNifK_Ze_5P8xZpTWlbEw.png" /></figure><p>Here are the common definitions for norms in ML.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vDMQSWZxYUfZ7K5bDQVEyw.png" /></figure><h4>Normed Space (Normed Vector Space / Normed Linear Space)</h4><p>⟨ <em>X</em>, ‖ · ‖ ⟩ forms a normed space. Here are two examples in the normed space: the first one uses an absolute value norm while the second one uses a <em>p</em>-norm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nVPrm9WY1Oh8H8FEghcKTQ.png" /></figure><p>It’s important to note that a normed space is defined by its norm. The behavior of the space, including concepts like convergence and distance, depends on the specific norm being used. Different norms can lead to different conclusions about the properties of the space.</p><p>Every normed space inherently possesses a metric induced by its norm. This allows norms to quantify both lengths of individual vectors and distances between vectors within the space. A normed space can simply use the norm to define its metric.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*62MbA3I4NeqM-sByPWXzXg.png" /></figure><p>Normed spaces are commonly used to quantify the similarity between data points, assess the quality of model predictions, and design optimization algorithms. For example, the L2 norm is frequently used to measure the error between predicted and true values in regression tasks, while the L1 norm promotes sparsity in feature selection.</p><h4>Banach Spaces</h4><p>A Banach space is a complete normed space (<em>X</em>, ‖ · ‖).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RIO9xJzVxXE5bSY6alH9jQ.png" /></figure><h3>Hilbert Space</h3><p>Hilbert spaces, as a specific type of complete normed vector space with additional structure, offer several advantages for ML applications:</p><p><strong>Inner Product:</strong> The defining feature of a Hilbert space is its inner product, which generalizes the dot product in Euclidean space. This inner product allows for the calculation of angles and projections, enabling techniques such as:</p><ul><li>Principal Component Analysis (PCA): Finding directions of maximal variance in data.</li><li>Support Vector Machines (SVM): Finding optimal hyperplanes for classification.</li></ul><p><strong>Orthogonality:</strong> Inner products facilitate the concept of orthogonality, which is crucial for:</p><ul><li>Fourier Transforms: Decomposing signals into orthogonal frequency components.</li><li>Function Approximation: Representing functions as linear combinations of orthogonal basis functions.</li></ul><p><strong>Completeness:</strong> Hilbert spaces are complete, meaning that every Cauchy sequence converges within the space. This is important for:</p><ul><li>Optimization: Guaranteeing the existence of solutions to optimization problems.</li><li>Function Spaces: Many function spaces used in ML (e.g., spaces of square-integrable functions) are naturally Hilbert spaces.</li></ul><p><strong>Duality:</strong> The Riesz representation theorem establishes a powerful duality between Hilbert spaces and their continuous dual spaces (spaces of linear functionals). This is exploited in:</p><ul><li>Kernel Methods: Optimizing the computation of similarity between two points projected in high-dimensional space using properties of the inner product space.</li><li>Reproducing Kernel Hilbert Spaces (RKHS): A type of Hilbert space that provides a framework for kernel-based learning algorithms.</li></ul><h4>Inner product</h4><p>The dot product is an example of an inner product, but the concept of an inner product is more abstract. An inner product is a binary operation on a vector space that satisfies the following axioms for all vectors <em>x</em>, <em>y</em>, <em>z</em> in the space and all scalars <em>a</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bFyAZvuSHnsN7zlZII05ig.png" /></figure><h4>Inner Product Space &amp; Hilbert Space</h4><p>A Hilbert space is endowed with an inner product and is complete. If the space is not complete, it is referred to as an inner product space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4DgfXH1A6tbwhNKliL9z2Q.png" /></figure><p>The inner product establishes a framework for abstract geometric concepts such as length, distance, and angle within a vector space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l4S76473avmuLqnUH3SG4w.png" /></figure><p>In every inner product space, we can derive a norm induced by the inner product:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O-Jmag4lonahBqt4e-011Q.png" /></figure><p>This norm allows us to define the distance between two vectors:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PWoCYujg7W-ujh1YaSN_JA.png" /></figure><p>Therefore, a Hilbert space is also a Banach space and a normed space. Furthermore, we can determine the angle between two vectors <em>x</em> and <em>y</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fxw6IblvR-cYDYrGc6ghng.png" /></figure><p>These definitions of norm, distance, and angle establish the geometric structure of inner product spaces.</p><p>Both the set of real numbers (ℝ) and the set of 𝑛-dimensional real vectors (ℝ<em>ⁿ</em>) can form Hilbert spaces. In these cases, the inner product is typically defined as the dot product.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QgHwUFQg0NerRBpMHm_SxA.png" /><figcaption>Hilbert Space with Dot Product</figcaption></figure><p>For Hilbert spaces consisting of functions, the inner product is often defined as an integral involving the product of the functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wluqtfr4E4Qa7-7DPL-odA.png" /></figure><h4>Cauchy–Schwarz inequality</h4><p>The Cauchy-Schwarz inequality states that for all vectors <em>x</em> and <em>y</em> in an inner product space:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*aEntHGXNumxg_rN3slUR1g.png" /></figure><p>Equality holds if and only if <em>x</em> and <em>y</em> are linearly dependent, meaning that one vector is a scalar multiple of the other.</p><h4>Orthogonality</h4><p>When the inner product of two vectors <em>x</em> and <em>y</em> is zero, they are said to be orthogonal, denoted as <em>x</em> ⊥ <em>y</em>. Orthogonal vectors are linearly independent, meaning neither can be expressed as a scalar multiple of the other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*hLqIbljDqpwRDRU4MFjY9A.png" /></figure><p>Similarly, functions <em>f</em> and <em>g</em> are orthogonal if their inner product is zero. A classic example is the pair of trigonometric functions sin(<em>x</em>) and cos(<em>x</em>), which are orthogonal over the interval [0, 2π]. In the broader context of vector spaces, any vector can be uniquely represented as a linear combination of vectors from an orthonormal basis. Notably, in function spaces, these basis vectors can themselves be functions.</p><p>Subsets of a vector space <em>X</em> are considered independent if no element in one subset can be expressed as a linear combination of elements from the other subset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s4KRoWBHw_0hi2YWUPIw_g.png" /></figure><h4>Use of Hilbert Space</h4><p>One notable application of Hilbert spaces in ML is the Reproducing Kernel Hilbert Space (RKHS). RKHS is a specialized type of Hilbert space that plays a crucial role in kernel-based learning algorithms, leveraging the inner product structure for efficient computation and representation of functions.</p><p>The key advantage of RKHS is its ability to implicitly map data points into high-dimensional feature spaces, where similarities between them can be more easily found. Explicitly performing this mapping would be computationally expensive or even impossible in cases of infinite-dimensional feature spaces. However, the defining property of an RKHS, the reproducing property, combined with the kernel trick, enables efficient computation of these similarities using the kernel function without explicitly representing the data in the high-dimensional space. This is possible because the ultimate goal is often to compute scalar similarity values in the real numbers (ℝ), rather than the high-dimensional features themselves.</p><h3>𝓁ᵖ Space</h3><p>The concept of infinity can be daunting in computer science. However, in ML, where algorithms often project data into high-dimensional spaces to uncover hidden patterns, it’s natural to consider extending this to infinite dimensions. While infinite-dimensional spaces might seem impractical, the key isn’t the number of dimensions, but whether we can efficiently compute relevant properties within those spaces. For example, if the sum of an infinite series or the limit of a sequence within an infinite-dimensional space is finite and computable, then infinite dimensionality can be a powerful tool for enhancing the expressiveness of ML models. This capability opens the door to studying and designing infinite-dimensional sequences.</p><p>Elements in a mathematical space can be sequences. The ℓᵖ space is a set of infinite sequences where the <em>p</em>-th power of the absolute values of the terms is summable and finite. It is defined as the set of all infinite sequences <em>x</em> = (<em>x</em>₁, <em>x</em>₂, <em>x</em>₃, …) for which the infinite series formed by the <em>p</em>-th power of the absolute values of the elements converges. More formally, it is defined as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z83_SUWLZjLQTw8or7c26Q.png" /></figure><p>It is a normed space when endowed with the <em>p</em>-norm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ry8px_wSjNTSH9pgnqvUuA.png" /></figure><p>To guarantee completeness, every Cauchy sequence in a space must converge to a limit within that space. In an ℓᵖ space, this condition is satisfied as the infinite series ∑|<em>x</em>ᵢ|ᵖ converges for each sequence in the space. Therefore, ℓᵖ spaces qualify as Banach spaces, which are complete normed vector spaces.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*7E6mY-McJOUc00YzVgYBkA.png" /><figcaption>Banach Spaces (Complete Normed Space)</figcaption></figure><h4>Example Sequence in ℓ²</h4><p>Consider the following sequence as an example of an element in the ℓ² space:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7-JgxT7fAft2P2im5FtYfg.png" /></figure><h4>Inner Product for ℓ² Space</h4><p>The inner product in ℓ² can be defined as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JhbfsFlfa0abSb0XFXS8FQ.png" /></figure><p>Given the property below, the definition indeed represents an inner product in ℓ² space, fulfilling all necessary criteria. This will also serve as a good example to demonstrate how to prove that a function is an inner product.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GwSbehLAuk-PMYDbdhxGaw.png" /></figure><h4>ℓ² pace &amp; Hilbert Space</h4><p>The ℓ² space, often described as the space of square-summable sequences, is a prominent example of a Hilbert space, a type of complete inner product space. In ML, the ℓ² space, which is the space of square-summable sequences, is often used in the context of regularization techniques to prevent overfitting in models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lWZ155M08LrttGQLldRTxg.png" /></figure><h4>∞-norm</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*2piHmDou2b7biTr0PVc8-Q.png" /></figure><p>When <em>p</em> = ∞, the corresponding norm is called the infinity norm (or supremum norm). Since there are infinitely many components in the sequence, finding a particular element as the maximum is not possible, so the infinity norm is computed using the supremum, which is the smallest value that is greater than or equal to all elements in the sequence.</p><h3>Lᵖ Space</h3><p>Lᵖ spaces are a specific type of function space defined for functions from a measurable space (often a subset of ℝⁿ) to ℝ (or ℂ). A measurable space extends the concept of size and volume to more abstract spaces. Infinite-dimensional spaces, like function spaces, allow us to model data as functions rather than just finite points. This concept is familiar to engineering students, who use Fourier transforms to represent data. In this context, the input is represented with periodic sinusoidal functions.</p><p>The functions in Lᵖ spaces are required to be Lebesgue integrable, meaning the integral of the absolute value of the function raised to the power of <em>p</em> is finite. This ensures the completeness of the L<em>ᵖ</em> space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xbV0aiXeLo87tBVWrKA9Cw.png" /></figure><p>It is a normed vector space when endowed with the <em>p</em>-norm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*dJ1Xkbsk8xJz8SvVtgurSw.png" /></figure><p>The Gaussian function is in <em>L</em>² space. The Gaussian function 𝑓(𝑥) defined on the real line ℝ and specifically considered over an interval, say [−𝑎, 𝑎], is given by:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x6FhPMispkAS0NOtctydfQ.png" /></figure><p>Its square is integrable. The integral is finite for any finite <em>a</em>, because the exponential function rapidly decays to zero as 𝑥 moves away from zero, making the area under the curve finite. Indeed, the Gaussian function is in L² even over the entire real line (from -∞ to ∞).</p><h4>Inner Product for Lᵖ Space</h4><p>The inner product can be defined as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*MeGx2o91Y79N0z8MPUz34g.png" /></figure><p>creating a Hilbert space.</p><h3>Continuous Function Space</h3><p>The continuous function space <em>C</em>[<em>a</em>, <em>b</em>] is defined as the set of all real-valued functions that are continuous on the closed interval [a, b]. In mathematical notation, this is expressed as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NI11QnyNQMpWb6-LHxk8JA.png" /></figure><p>Let’s explore some visual examples of continuous functions within this space:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*quj63IWoLIPkPhQYFpAzsQ.png" /></figure><h4>Norm</h4><p>The corresponding p-norm is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DyWmFwJGuRajbCelO8KAqg.png" /></figure><p>And the natural norm is defined as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*Wrz_9tSAx4kb-EVfJR5fLg.png" /></figure><p>The metric <em>d</em>(<em>u</em>, <em>v</em>) below is a supremum between <em>u</em>(<em>x</em>) and <em>v</em>(<em>x</em>). (<em>C</em>, <em>d</em>) forms a complete metric space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FD1Wbus-nh7c8bj4qSwY-w.png" /></figure><h4>Inner Product</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0K2IfDCIEAj3e2EUwRVk-w.png" /></figure><p>forms an inner product space.</p><h3>Examples of Hilbert Spaces</h3><p>Here is an recap of three possible Hilbert spaces, each defined by its unique set of elements and corresponding inner product: Euclidean space equipped with the dot product, ℓ² space characterized by the ℓ² norm, and the space of continuous functions on the interval [0,1].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5xR-t0cKa4L-LcneiOaTHg.png" /></figure><h3>Isomorphism</h3><p>Isomorphism is a structure-preserving mapping between two spaces. In the context of vector spaces, this preservation specifically refers to linearity, meaning that the operations of vector addition and scalar multiplication are maintained under the mapping.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dD2K1G6izQ-xiqRVOKrn9Q.png" /></figure><p>In a Banach space, an isomorphism preserves the norm following the mapping. That is,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bvsrdNUoQW8pOTVlfsyL2g.png" /></figure><p>This is also referred to as an isometric isomorphism, where the distance is preserved before and after the mapping.</p><p>For Hilbert spaces <em>X</em> and <em>Y</em>, and the mapping <em>M</em>: <em>X</em> → <em>Y</em>, isomorphism means that <em>M</em> is a bijective (one-to-one and onto) linear map that preserves the inner product, i.e.,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QjvInrZvlM_o00i8FlYfDA.png" /></figure><h3>Recap</h3><p>Here is an overview of the relationships among some of the spaces we’ve studied. The arrows indicate the “is a” relationship. A normed vector space is inherently a metric space because the norm induces a metric, which quantifies the distance between vectors. Without a defined topology, a vector space by itself does not automatically meet the criteria required to be considered a topological space, as it lacks the concepts of closeness, connectivity or distance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vnGmRWdsxC0_YdhssE0Ukw.png" /><figcaption><a href="https://en.wikipedia.org/wiki/Space_(mathematics)">Source</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b43e5d0ac9d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Study of Mathematical Spaces (Machine Learning)]]></title>
            <link>https://jonathan-hui.medium.com/the-study-of-mathematical-spaces-machine-learnin-d5b576640f8e?source=rss-bd51f1a63813------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5b576640f8e</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Jonathan Hui]]></dc:creator>
            <pubDate>Wed, 15 May 2024 20:34:33 GMT</pubDate>
            <atom:updated>2024-05-20T20:28:46.096Z</atom:updated>
            <content:encoded><![CDATA[<p>The terminology of mathematical spaces in AI research papers can be intimidating. Fortunately, understanding these concepts isn’t always crucial to grasping the core AI ideas. However, some readers may still feel unsatisfied when they can’t fully grasp the researchers’ intended message. This article will first explain some key terms, then explore the mathematical spaces most relevant in machine learning (ML). The field of mathematical spaces is vast, but this article aims to provide a foundational understanding within the context of machine learning, while also catering to those interested in delving deeper into the subject.</p><p>Mathematical spaces exhibit a hierarchical structure, reminiscent of object-oriented design. At the top of this hierarchy reside the most abstract spaces, such as topological spaces, which establish fundamental concepts like continuity and convergence. As we move down the hierarchy, spaces become more specialized, acquiring additional structures and properties that tailor them for specific applications.</p><h3>Fields</h3><p>Let’s begin by discussing fields, a type of mathematical space. Both real numbers and complex numbers form fields. While basic, this concept provides a quick overview and introduces some of the associated terms.</p><p>A field ⟨<em>F</em>, +, ·⟩ consists of a set <em>F</em> equipped with two binary operations (operations that take two elements to produce a third element):</p><ul><li><strong>Addition</strong> (+)</li><li><strong>Multiplication</strong> (·)</li></ul><p>The set of real numbers ℝ forms a field which contains all real numbers. The operations of addition (+) and multiplication (·) are defined in the usual way for real numbers. However, to qualify as a field, these operations on the elements of the field are required to adhere to the following axioms (basic rules):</p><p>For all <em>a</em>, <em>b</em>, <em>c</em> ∈ <em>F</em>:</p><p>1. Closure under addition and multiplication: <em>a</em> + <em>b</em> ∈ <em>F</em>, <em>a</em> · <em>b</em> ∈ <em>F</em>.</p><p>2. Associativity of addition and multiplication:</p><ul><li>(<em>a</em> + <em>b</em>) + <em>c</em> = <em>a</em> + (<em>b</em> + <em>c</em>), (<em>a</em> · <em>b</em>) · <em>c</em> = <em>a</em> · (<em>b</em> · <em>c</em>)</li></ul><p>3. Commutativity of addition and multiplication:</p><ul><li><em>a</em> + <em>b</em> = <em>b</em> + <em>a, a</em> · <em>b</em> = <em>b</em> · <em>a</em></li></ul><p>4. Existence of additive and multiplicative identities:</p><ul><li>There exists an element 0 ∈ <em>F</em> such that <em>a</em> + 0 = <em>a</em> = 0 + <em>a</em> for all <em>a</em> ∈ <em>F</em>.</li><li>There exists an element 1 ∈ <em>F</em> (where 0 ≠ 1) such that <em>a</em> · 1 = <em>a</em> = 1 · <em>a</em> for all <em>a</em> ∈ F.</li></ul><p>5. Existence of additive and multiplicative inverses:</p><ul><li>For every <em>a</em> ∈ <em>F</em>, there exists an element -<em>a</em> ∈ <em>F</em> such that <em>a</em> + (-<em>a</em>) = 0 = (-<em>a</em>) + <em>a</em>.</li><li>For every <em>a</em> ∈ <em>F</em> where <em>a</em> ≠ 0, there exists an element <em>a</em>⁻¹ ∈ <em>F</em> such that <em>a</em> · <em>a</em>⁻¹ = 1 = <em>a</em>⁻¹ · <em>a</em>.</li></ul><p>7. Distributivity of multiplication over addition:</p><ul><li><em>a</em> · (<em>b</em> + <em>c</em>) = (<em>a</em> · <em>b</em>) + (<em>a</em> · <em>c</em>)</li></ul><p>A field is closed under addition, and multiplication. This means that performing these operations on elements within the field will always produce another element within the same field.</p><p>In quantum mechanics, the complex field ℂ (consisting of complex numbers) is essential for describing quantum phenomena. Rational numbers form the rational field ℚ, while integers do not form a field. This is because most integers (except for 1) do not have multiplicative inverses that are also integers, violating the field axiom requiring the existence of multiplicative inverses for all nonzero elements.</p><h4>Ordered Fields</h4><p>An ordered field is a field equipped with a order relation (≤). The rational numbers (ℚ) and real numbers (ℝ) are examples of ordered fields.</p><h3>Announcement</h3><p>Although I haven’t published many articles in 2023 and 2024, these years have been incredibly busy for me. The rapid advancements in AI have inspired me to write a book on Generative AI, a project that has been incredibly challenging and time-consuming. During the writing process, numerous interesting topics emerged that were either too tedious or not directly relevant to the core focus of the book. These topics may be a bit rough around the edges due to time constraints, but I still believe they offer insights as a reference. Rather than discarding them, I’ve decided to share them through a series of articles on Medium.</p><p>While the book isn’t finished yet, you can stay updated on its progress by following me on Medium or connecting with me on <a href="https://www.linkedin.com/in/thejonathanhui/">LinkedIn</a>. I’ll share an announcement there as soon as it’s ready!</p><h3>Space</h3><p>The notion of space in mathematics is abstract yet profoundly powerful. It starts with a set — a collection of objects usually called points or elements. But a set alone isn’t very interesting. The magic happens when we add different structures to the set, giving the points meaning and connections. This process of enhancing sets with various structures gives rise to a wide array of mathematical spaces, each possessing its own unique properties, and practical applications.</p><p>Space is a set that can be endowed with structures:</p><ul><li><strong>Algebraic Structure:</strong> It defines operations (like addition or multiplication) and rules (axioms) on the points within a space.</li><li><strong>Relations:</strong> These specify the relationships between elements. For instance, in an ordered set, a relation determines whether one element is less than or greater than another.</li><li><strong>Metrics (Distance Functions):</strong> These provide a numerical method to measure the distance or closeness between points in a space, enabling the study of concepts like convergence, compactness and continuity.</li><li><strong>Topology:</strong> This defines a more general notion of closeness without necessarily relying on numerical distances.</li></ul><h3>Metric Space</h3><p>Metric spaces, endowed with a distance function known as a metric, are often the first step in understanding mathematical spaces. The definition of a space is often written within brackets ⟨ ⟩ or parentheses ( ) to specify the name of the set and the particular structure applied to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-l-2pOzueOb1SkzDHshXuQ.png" /></figure><p><em>M</em> represents the underlying set of a metric space, which can consist of numbers, functions, sequences, or other mathematical objects. When the context is clear, we may also refer to the entire metric space as <em>M</em>. A metric <em>d</em> is a function that assigns a non-negative real number to every pair of elements, introducing the concept of “distance” between them. This structure allows for the analysis of distances and also enables the discussion of convergence and continuity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PLh9dcaRkqw4-JmgWPk9_A.png" /><figcaption>Metric Space (Image by Author)</figcaption></figure><p>Common metrics include the Manhattan distance and the Euclidean (L2) distance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9a_u5a7I64cU7TqLMcc6Jg.png" /></figure><p>However, a metric function must meet the following conditions for all <em>x</em>, <em>y</em>, and <em>z</em> in <em>M</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*16OL1GPLwgUsiFrwPKCQyw.png" /></figure><p>When we set 𝑧 = 𝑥, they lead to the conclusion that 𝑑(𝑥 , 𝑦) is non-negative.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9ZIHi1FrQx4uwIcKsIVJxQ.png" /></figure><p>Hence, these three properties are equivalent to the properties below.</p><ul><li><strong>Non-negativity</strong>: 𝑑(𝑥,𝑦)≥0<em>.</em></li><li><strong>Symmetry</strong>: The distance is the same in both directions.</li><li><strong>Triangle Inequality</strong>: The direct route is the shortest.</li></ul><p>The broad definition of a metric allows for broad applicability and consistent manipulation of fundamental concepts. For example, the Wasserstein loss, used in generative AI for more efficient training, satisfies the criteria of a metric function. This allows us to apply the properties of a metric space to probability distributions without the need to create a new mathematical framework.</p><h3>Sequence</h3><p>Sequences provide a foundational tool for studying concepts like convergence and limits. In abstract mathematical spaces, the familiar notion of a sequence as an ordered list of numbers is too limited. We need to re-establish this concept to accommodate other mathematical objects, such as functions, while preserving the essential idea of an ordered progression.</p><p>Let’s explore the concepts of convergence and limits within the context of metric spaces.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wb-cdJSgogsLsoXGom-znw.png" /></figure><p>A sequence in <em>X</em> is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cotZdznClcTpYkEiL_yt6w.png" /></figure><p><em>X</em> is a mathematical space.</p><h4>Convergency &amp; Limit in Metric Space</h4><p>In the context of metric spaces, a sequence is said to be convergent if the terms of the sequence approach a specific limit as the sequence progresses indefinitely. More formally, a sequence in a metric space 𝑋 converges to a limit 𝐿∈𝑋 if, for every positive number <em>ϵ</em> (no matter how small), there exists a natural number <em>N</em> such that for all 𝑛≥𝑁, the distance between the sequence​ and <em>L</em> is less than <em>ϵ</em>. This can be expressed mathematically as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j8jt7Rg54-2dyyqGNN4qcw.png" /></figure><p>A sequence in a metric space converges if it approaches a specific limit that is part of the space <em>X</em>, meaning the sequence will have a limit <em>L</em>∈<em>X</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sy29Os0pChtkgZ1U32jOCg.png" /></figure><p>This approach, however, relies on knowing the limit beforehand, which is not always the case. To address this issue, mathematicians have developed the concept of Cauchy sequences.</p><h3>Cauchy Sequence</h3><p>A Cauchy sequence is defined as a sequence where the elements become arbitrarily close to each other as the sequence progresses. For a sequence to qualify as a Cauchy sequence, for any given positive distance <em>ϵ</em>, there exists a point in the sequence beyond which the distance between any two elements is always less than <em>ϵ</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UiMWVN2DMsPi0eDjgfesTg.png" /></figure><p>Definition: For every positive real number <em>ϵ</em> (no matter how small it is), it exists a value <em>N</em> (a natural number, 1, 2, 3, …) where 𝑚,𝑛 ≥ 𝑁 and</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K658Yazuo69Xzs7iirue8w.png" /></figure><h4>Examples</h4><p>Let’s examine a sequence in ℝ: 3, 3.1, 3.14, 3.141, …. This sequence successively adds one decimal place to the approximation of <em>π</em>. In this example, we use the usual metric 𝑑(𝑥,𝑦)=∣𝑥−𝑦∣. For 𝑚&lt;𝑛, the difference between the <em>m</em>-th and <em>n</em>-th terms becomes progressively smaller than:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YLT4EIeT7QCA9LLdL7tRJQ.png" /></figure><p>Hence, for any positive number <em>ε</em>, there exists an <em>N</em> such that for all <em>m</em> and <em>n</em> greater than <em>N</em>, the difference between the <em>m</em>th and <em>n</em>th elements is less than <em>ε</em>.</p><h3>Complete</h3><p>A convergent sequence is always a Cauchy sequence. However, not all Cauchy sequences converge. Take, for example, a Cauchy sequence consisting entirely of rational numbers from the set ℚ. Every term in this sequence is a rational number.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WLl_azJzLwgK9aPHD72sIg.png" /></figure><p>If the sequence has a limit <em>x</em>, then</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*CLzBmC0qM6jtcH_PtnpTHQ.png" /></figure><p>However, no rational number can satisfy this condition. There is no limit within ℚ for this sequence, meaning it does not converge. To make the sequence complete, we can extend the space to include ℝ.</p><p>A metric space is said to be <strong>complete</strong> if every Cauchy sequence in that space converges to a limit that is also within the space, ensuring that no sequence “escapes” the space as it converges.</p><p>Working with incomplete metric spaces presents challenges. We might construct a sequence of approximate solutions, using an iterative method or a numerical method. As the sequence progresses, the approximate solutions become increasingly close to one another, forming a Cauchy sequence in the metric space. Ideally, we would want these approximations to converge to a limit, and then demonstrate that this limit is indeed a solution. However, this approach is only guaranteed to work if the underlying metric space is complete. Otherwise, we might need to extend the space.</p><h3>Domain &amp; Image</h3><p>The domain of a function is the set of all possible input values for which the function is defined. It essentially tells you what you can input into the function. On the other hand, the image of a function (codomain) refers to the set of all output values that the function can produce when applied to every element in its domain.</p><h3>Continuity</h3><p>Limits and continuity are fundamental building blocks in differential calculus. Cauchy sequences provide a way to define and analyze limits in the broader context of metric spaces. Let’s discuss the idea of continuity for functions between metric spaces.</p><p>A function <em>f</em> from one metric space <em>X</em> to another metric space <em>Y</em> is said to be continuous at a point 𝑥₀ in <em>X</em> if, for every <em>ϵ</em>&gt;0, there exists a <em>δ</em>&gt;0 such that for all <em>x</em> in <em>X</em> where the distance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sPt4gdKg92G8hoPTSTGdDQ.png" /></figure><p>This definition ensures that small changes in the input around 𝑥₀ result in small changes in the output around 𝑓(𝑥₀).</p><p>Continuity in deep learning is crucial for ensuring smooth changes in model outputs as inputs vary, which helps in stable training. It allows for the use of gradient-based optimization techniques, like backpropagation, essential for training neural networks effectively. Continuity also helps in generalization, preventing abrupt changes in predictions, leading to more reliable and interpretable models.</p><h3>Countable</h3><p>Dealing with infinite possibilities is challenging. Countability in a mathematical space primarily seeks to ensure a manageable and well-behaved structure. Countability conditions facilitate simplifications in analysis and topology, such as the existence of countable bases and the ability to approximate elements with finite sets.</p><p>A set is considered countable if its elements can be put into a one-to-one correspondence with the natural numbers (1, 2, 3, …). This means you can list the elements of the set in a sequence. Formally, a set is countable if there exists an injective function <em>f</em> : <em>F</em> → ℕ (natural number) that every element in <em>F</em> can map to a unique element in ℕ.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dmkoGO0s9K8IYsV3Xo4M5Q.png" /></figure><p>However, these sets can have infinitely many elements, as long as they can still be listed sequentially, like the set of even numbers, the set of integers or the set of rational numbers. In contrast, the set of real numbers between 0 and 1 is uncountable. These sets are larger than the set of natural numbers and cannot be put into a one-to-one correspondence with them.</p><h3>Dense</h3><p>Let ⟨𝑋, 𝑑⟩ be a metric space. A set 𝑌⊆𝑋 is dense in 𝑋 if, for every element 𝑥∈𝑋, there exists an element 𝑦∈𝑌 such that <em>d</em>(<em>x</em>, <em>y</em>) &lt; <em>ϵ</em> for every 𝜖&gt;0. Informally, this means that for any element outside of 𝑌, we can find an element within 𝑌 that is arbitrarily close to it. An example of a dense subset in ℝ is the set of rational numbers ℚ. To illustrate this, consider the decimal expansion of a real number:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*qZEPR_gS71kpsjztH5ayRQ.png" /></figure><p>While each individual element in the sequence is rational, the sequence itself converges to a real number. This demonstrates that any real number can be arbitrarily approximated by a rational number.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ImjXhib_arXElTooU1AgQ.png" /></figure><h3>Separable</h3><p>By definition, a metric space <em>X</em> is called separable if there is a countable set <em>Y</em> ⊆ <em>X </em>such that the closure of <em>Y</em> (the set of all points in <em>X</em> that are either in <em>Y</em> or arbitrarily close to points in <em>Y</em>) is <em>X</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JubYznbkseOKMPOPw65Z5g.png" /></figure><p>Intuitively, if a space is separable, every point of <em>X</em> can be approximated arbitrarily closely by points in the countable dense subset <em>Y</em>. This means that properties proven for <em>Y</em> can often be extended to the whole space <em>X</em> through this approximation. Separability is frequently a necessary condition for certain important theorems to hold. This property can simplify analysis and lead to more powerful implications for the entire space.</p><p>While the direct application of countable dense subsets to complex deep learning models can be challenging, their existence simplifies the justification and analysis of various techniques, such as dimensionality reduction, kernel design, approximation, and data representation.</p><h3>Isomorphisms</h3><p>An isomorphism is a structure-preserving mapping between two structures, which is both injective and reversible through an inverse mapping. An <strong>injective</strong> map (or one-to-one mapping) ensures that distinct elements are mapped to distinct elements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_k8Avyx0Wjl8ZXWwyHlvXw.png" /><figcaption>F →G</figcaption></figure><p>Surjective mappings ensure that every element in the target set <em>G</em> is mapped to by at least one element from the domain set <em>F</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SyVgzngF54mJU4Jo-8Ptkw.png" /><figcaption>F →G</figcaption></figure><p>If a mapping is both injective (one-to-one) and surjective (onto), it is classified as a bijection. This means that every element of the domain is mapped to exactly one element of the image set, and every element of the image set is the image of exactly one element from the domain, establishing a perfect one-to-one correspondence between all elements of the domain and image sets.</p><p>Isomorphisms, while not directly visible in the implementation of deep learning algorithms, play a crucial role in the underlying mathematical framework. They ensure the preservation of essential structural relationships between different mathematical spaces, which is fundamental for understanding how data transformations within neural networks affect inherent information.For instance, linear transformations in neural networks strive to preserve relationships between data points. Isomorphisms is crucial in representation learning, where the goal is to capture meaningful patterns while discarding irrelevant details. However, non-linear functions like ReLU, while essential for learning complex patterns, can potentially lead to some information loss due to their non-invertibility.</p><h4>Preservation</h4><p>Preservation preserves operations. In the case of fields, it preserves addition and scalar multiplication. Specifically:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RmWtoKNkTxrHJexnFbm7gA.png" /></figure><p>Let 𝜙 be a map from 𝐹 to <em>G</em>. In the context of a field, if 𝜙 obeys all the rules above, the map 𝜙 is an isomorphism.</p><p>An isometry between two metric spaces is a function that preserves distances. Specifically, if (𝑋, 𝑑𝑋) and (𝑌, 𝑑𝑌) are two metric spaces, a function 𝑓:𝑋→𝑌 is called an isometry if for all 𝑥,𝑥′∈𝑋, the following holds:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eJeRlt1rV9Ee8_SXYiaTXg.png" /></figure><p>This means that the distance between any two points in 𝑋 is the same as the distance between their images in 𝑌, as measured in their respective metrics.</p><h3>Open Sets &amp; Closed Sets in Metric Spaces</h3><p>Open and closed sets are the fundamental building blocks of mathematical spaces, providing the essential framework for developing more complex topological concepts. For instance, they are essential for defining convergence and continuity.</p><p>Open sets are sets that don’t include their boundaries, while closed sets contain all their boundary points. To aid in visualization and understanding, we will begin our discussion by exploring open and closed sets within the more familiar framework of metric spaces.</p><p>Let’s examine a subset <em>A</em> ⊆ <em>X</em>, with an element <em>x </em>∈ <em>A</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8R4HHv9ZuthS_iRZ6fBgyg.png" /><figcaption>Open Ball B (Image by Author)</figcaption></figure><p>We can construct an open ball 𝐵 centered at 𝑥 with a radius smaller than <em>ϵ</em>. This ball 𝐵 consists of all the elements:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ny7wJzRygKBadjUvHcsSww.png" /></figure><p>Essentially, <em>B</em> includes <em>x</em> and its neighbors within a radius of <em>ϵ</em>. Visually, these neighbors of <em>x</em> might all lie within <em>A</em>, or some could extend beyond it.</p><p><strong>Open Set &amp; Boundary Points</strong></p><p>A set <em>A</em> is considered open if, for every element <em>x</em> within <em>A</em>, there exists a sufficiently small radius <em>ϵ</em> such that all elements of the open ball <em>B</em> centered at <em>x</em> with this radius are contained entirely within <em>A</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q3yI_NYXvX83ikF4qNwhlA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V-c4FhZMJ5CoMd1vGr1Wsw.png" /><figcaption>Open Set (Image by Author)</figcaption></figure><p>A boundary point of <em>A</em> is a point in <em>X</em> such that every open ball centered at that point contains elements both from <em>A</em> and from the complement of <em>A</em> (i.e., the set of points in <em>X</em> that are not in <em>A</em>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e9hPDpdxGrI-MvQ0fUmkcw.png" /><figcaption>Boundary Point (Image by Author)</figcaption></figure><p>A boundary point <em>x</em> is formally defined as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I0E-mMnYwG9Yf1YJLwG7JA.png" /></figure><p>where <em>A</em>ᶜ<em> </em>is the complement of <em>A. </em>The set of all boundary points of 𝐴 is denoted as <em>δA</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HLmpDazmJkw_Ipgq9XrVKg.png" /></figure><p>An open set does not contain any of its boundary points.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GMwJDyrP8mZXCtfT0OYIKw.png" /><figcaption>An open interval and an open circle</figcaption></figure><p>That is,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9qq-InmkSiuFxt7zfz9-Vw.png" /></figure><h4>Closed Set &amp; Closure</h4><p>The definition of a closed set is simply its complement is open.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_0vbnNh2PM9L66tAoguIdQ.png" /></figure><p>i.e.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*23qHU74TK1s6he2f3zLvFw.png" /></figure><p>From another angle, a closed set contains all the boundary points.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NHjEPyyODoA_bD3LNeMU7g.png" /></figure><p>The closure of a set <em>A</em> is formed by combining A with its boundary points. In the case of the rational numbers (ℚ) within the real numbers (ℝ), the closure of ℚ is the entire set of real numbers (ℝ).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bl_g-ErEr_J1dDpR7kVwmg.png" /></figure><p>If the closure of <em>A</em> is the same as <em>A</em>, <em>A</em> is a closed set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SnAhNULkIZOOoZfW2YPiVw.png" /></figure><p>Both the empty set ∅ and the entire set <em>X</em> are considered both open and closed.</p><h4>Example</h4><p>Consider the open interval 𝐴 = (3, 6) on the real number line ℝ.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6EkJQgWfC5RbPFHdVStYhA.png" /></figure><p><em>A</em> is an open set. For any <em>x</em> in <em>A</em>, we can identify open balls centered at <em>x</em> such that all elements within these balls are contained in <em>A</em>. For example, we could choose ε to be half the distance from <em>x</em> to the nearest boundary point of <em>A</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5qhui_hRKR7hlx4_4976XQ.png" /></figure><p>Let’s explore a more challenging example with subsets <em>A</em> and <em>C</em> included in <em>X</em>. Are <em>A</em> and <em>C</em> open or closed?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RvVCSL7fkRxVcdF9r4NUZg.png" /></figure><p>The element “0” and elements greater than “3” are not boundary points of <em>A</em> because they do not belong to the set <em>X</em> itself. The element “3” is also not a boundary point of <em>A</em>. No open balls centered at “3” contain elements outside of 𝐴 that are also within 𝑋.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rbZDIRTLTb2qk_X5EbLoaA.png" /></figure><p>This example highlights a crucial point: determining whether a set is open or closed requires considering both the set’s definition <em>A</em> and the definition of the underlying space <em>X</em>, which together determine the set’s boundary points. In this case, the definitions result in the surprising outcome that <em>A</em> has an empty set of boundary points. This leads to the conclusion that <em>A</em> is both closed and open. Thus, it’s important to note that open and closed sets are not always mutually exclusive categories. Indeed, a set that is both open and closed is referred to as a clopen set.</p><p>For the subset <em>C</em>, the element 2 is a boundary point. The closure of <em>C</em> is equal to <em>C</em> itself, which indicates that <em>C</em> is a closed set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xi7ocsGUpJb5GxCORborfg.png" /></figure><h3>Continuous Functions</h3><p>Many concepts in topology can be defined using either open sets or closed sets. Consider two metric spaces 𝐴 and 𝐶, with a mapping function 𝑓:𝐴→𝐶. Informally, the function 𝑓 is continuous at a point 𝑎∈𝐴 if for every open ball around 𝑓(𝑎) in 𝐶, there exists a corresponding open ball around <em>a</em> in <em>A</em> such that the image under <em>f</em> of this latter ball is contained within the open ball around 𝑓(𝑎).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fyv-0tEk8yY_1A2pKkAO5w.png" /></figure><p>Formally, a function <em>f</em> is continuous at a point 𝑎 if, for every 𝜖&gt;0, there exists a 𝛿&gt; such that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vQ82-RVMutn-iOv214rL-w.png" /></figure><p>This means the image of the open ball of radius 𝛿 around 𝑎 is contained within the open ball of radius <em>ϵ</em> around 𝑓(𝑎), ensuring that small changes in the domain near <em>a</em> lead to small changes in the image at <em>f</em>(<em>a</em>).</p><p>A function <em>f</em> is continuous on its entire domain <em>A</em> if it is continuous at every point within <em>A</em>. However, in the example below, <em>f</em> is not continuous at the point 𝑎.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fBKbsHfd58PRnloyj-h1wQ.png" /></figure><h4>Sequential Continuity</h4><p>A function 𝑇 is sequentially continuous at a point <em>x̃</em> ∈ <em>X</em> if, for any sequence (𝑥𝑛) converging to <em>x̃</em>, the sequence 𝑇(𝑥𝑛) converges to 𝑇(<em>x̃</em>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aBQOS2mZSZ8UHSTE6HpObg.png" /></figure><p>In metric spaces, continuity and sequential continuity are equivalent.</p><h3>Compactness</h3><p>The concept of finiteness can be tricky when dealing with spaces containing infinite-dimensional elements, like functions or infinite sequences. Compactness generalizes the notion of a set being ‘closed and bounded’ in Euclidean space to such spaces. (In Euclidean space, a set is closed if it contains all its limit points, and bounded if it can be contained within a ball of finite radius.) Even if a set contains infinite-dimensional elements, compactness gives it a certain ‘finiteness’ property.</p><p>Compactness is a crucial concept in many areas of mathematics for several reasons. Firstly, it often simplifies proofs and arguments by reducing infinite scenarios to finite ones, making complex problems more manageable. Secondly, it ensures that a continuous function on a compact set always has a highest and lowest value, which is a key idea in the Extreme Value Theorem. Lastly, every sequence in compact spaces possesses a subsequence that converges. This property is important in analysis, as it guarantees the existence of limits in a wide range of scenarios.</p><p>A topological space 𝑋 is called compact if every open cover of 𝑋 has a finite subcover. Let’s define open cover and finite subcover:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hoCKtP8AkOWefbu0bEtpgg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y4rVTkNrePEe4Z1V_p0e-w.png" /><figcaption>Open Cover and Finite Subcover (Image by Author)</figcaption></figure><p>A finite subcover is a smaller collection of open sets, selected from an initial open cover, that still covers the entire set. Compactness is a topological property that ensures that, for any open cover of a set, there always exists a finite subcover. In other words, no matter how you try to cover a compact space with open sets, you can always find a finite number of them that do the job. In retrospect, problems can be analyzed locally using a finite number of open sets, and the results can then be aggregated.</p><h3>Topological Space</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vnGmRWdsxC0_YdhssE0Ukw.png" /><figcaption><a href="https://en.wikipedia.org/wiki/Space_(mathematics)">Source</a></figcaption></figure><p>A topological space is a very general type of mathematical space that provides a framework for defining concepts like convergence, continuity, and compactness. It formally defines the notion of neighborhoods around points within a set, serving as a fundamental foundation for more advanced mathematical theories. It establishes essential but basic structures, which on their own have limited practical utility. Typically, additional structure and refinement are necessary to tailor a space for practical applications.</p><p>Unlike metric spaces, which rely on a distance function to define closeness, topological spaces are built upon the concept of open sets. This means that topological spaces don’t possess a notion of distance between points, offering a less structured framework than metric spaces. Instead, they focus on the concept of neighboring points.</p><p>Topological spaces consists of two main components:</p><ol><li><strong>A set of points <em>X</em>:</strong> This can be any collection of objects, such as numbers, shapes, or even more abstract entities.</li><li><strong>A topology <em>τ</em>:</strong> This is a collection of subsets of the set of points, called <strong>open sets</strong> that satisfy certain properties.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6B44Z5kOpazsiowpDefuHA.png" /></figure><p>The open sets 𝜏 must satisfy the following axioms:</p><ol><li>The empty set ∅ and the entire set <em>X</em> itself are included in <em>τ</em>. This axiom ensures that there are at least two open sets in any topology, the minimum needed.</li><li>The union of any collection of open sets in a topological space 𝜏 also belongs to 𝜏, meaning the resulting union is itself an open set.</li><li>The intersection of any finite number of open sets in a topological space 𝜏 also belongs to 𝜏, meaning the resulting intersection is itself an open set.</li></ol><p>A subset <em>A</em> of <em>X</em> is closed if and only if its complement, <em>A</em>ᶜ = <em>X</em> \ <em>A</em>, is open.</p><p>For a given set 𝑋={1,2,3,4}, the topology on 𝑋 can range from the simplest to the most complex depending on the number of subsets included as open sets. The simplest possible topology on any set is the trivial topology. For the set 𝑋, this topology would include only the minimal required subsets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d8X-3jDMgSxP8Gg_UgCsyw.png" /></figure><p>The most complex topology on any set is the discrete topology, where every possible subset of 𝑋 is considered an open set:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pgmOGgLew7M08mN7nkHjnQ.png" /></figure><p>Many real-world problems involve spaces where only certain kinds of subsets are relevant or meaningful for analysis. Intermediate topologies strike a balance between too little structure (trivial topology) and too much granularity (discrete topology), making them particularly suited for detailed yet manageable analysis in both theoretical and applied mathematics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7-wsOEhKxnXSEPykU8YRbQ.png" /></figure><p>Given a topological space <em>X</em> and a point <em>p</em> in <em>X</em>, a neighborhood of <em>p</em> is a subset <em>V</em> of <em>X</em> that contains an open set <em>U</em> such that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mrZedzIF8EOC4fVEnVtc-A.png" /></figure><p>Every open set is a neighborhood of each of its points. (Note that <em>V</em> itself is not required to be an open set.)</p><p>With the definition of a neighborhood, the definitions for convergence, continuity, and compactness in a topological space are as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ecoo6aK6vvbqcF46NTmchw.png" /></figure><h4>Topological Isomorphism</h4><p>Topology focuses on the idea of neighborhoods. While metric spaces include the concept of distance, topological spaces, being more general and abstract, do not. In topology, a teacup and a donut are considered homeomorphic, meaning they are topologically equivalent. The two shapes can be continuously deformed into each other without cutting or gluing. We can gradually deform the cup, widening its handle to form the donut’s ring. This deformation, while changing the distance between points, preserves the essential neighboring relationships that are the focus of topology. However, a teacup cannot be transformed into a bowl, as this would require punching a hole and disrupting the established neighboring relationships.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M_WqW6QekQal86PKdpSHEg.png" /><figcaption>Topological Isomorphism (Image by Author)</figcaption></figure><p>A topological isomorphism, also known as a homeomorphism, is a continuous function between two topological spaces that preserves the topological structure. It’s a bijection, meaning it’s both one-to-one (injective) and onto (surjective), and both the function and its inverse are also continuous. If such a function exists, the two spaces are said to be homeomorphic, or topologically equivalent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sWxlLlaWssM2ve9PqFEyew.png" /></figure><p>The concept of homeomorphism is fundamental in topology because it allows mathematicians to classify and study spaces based on their intrinsic topological properties rather than their specific geometric shapes. This abstraction helps in understanding and solving complex problems across different areas of mathematics and science.</p><h4>Bases of Open Sets</h4><p>In topology, open sets are fundamental to understanding the structure of topological spaces. However, explicitly defining all open sets can be cumbersome. The concept of a basis offers a solution. A basis for a topological space is a smaller collection of open sets with a special property: every open set in the topology can be formed by taking unions of sets from the basis. Essentially, the basis acts as a set of building blocks from which all other open sets can be constructed. A basis for a topology is a collection of open sets that can be used to generate all other open sets in the space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wtnxz6vZJguAPY1dMdp9aw.png" /></figure><h4>Example: Standard Topology on the Real Line ℝ</h4><p>The standard topology on the real line ℝ is the topology generated by the collection of all open intervals in the real line. It is generated by a basis consisting of all open intervals (<em>a</em>, <em>b</em>) where <em>a</em>&lt;<em>b</em> and 𝑎,𝑏∈ℝ. This means that any open set in this topology can be formed by taking the union of (possibly infinitely many) open intervals.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*osK1k6kbXZcL85bb4anAJQ.png" /></figure><h3>Next</h3><p><a href="https://jonathan-hui.medium.com/vector-space-normed-space-hilbert-space-machine-learning-b43e5d0ac9d3">Vector Space, Normed Space &amp; Hilbert Space (Machine Learning)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5b576640f8e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NLP Series]]></title>
            <link>https://jonathan-hui.medium.com/nlp-series-2c9613876542?source=rss-bd51f1a63813------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c9613876542</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Jonathan Hui]]></dc:creator>
            <pubDate>Wed, 29 Mar 2023 03:47:51 GMT</pubDate>
            <atom:updated>2023-03-29T03:47:51.009Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lMUehHDVuXIMKyP4f66Hyw.png" /></figure><p><strong>NLP</strong></p><ul><li><a href="https://medium.com/@jonathan_hui/nlp-word-embedding-glove-5e7f523999f6">NLP — Word Embedding &amp; GloVe</a></li><li><a href="https://medium.com/@jonathan_hui/nlp-bert-transformer-7f0ac397f524">NLP — BERT &amp; Transformer</a></li><li><a href="https://medium.com/@jonathan_hui/how-to-scale-the-bert-training-with-nvidia-gpus-c1575e8eaf71">How to scale the BERT Training with Nvidia GPUs?</a></li><li><a href="https://jonathan-hui.medium.com/what-is-new-in-gpt-4-0-ba9779bf7f68">What is new with GPT-4?</a></li><li><a href="https://jonathan-hui.medium.com/how-much-do-i-like-chatgpt-3d8a3216e137">How much do I like ChatGPT?</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c9613876542" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is new with GPT-4?]]></title>
            <link>https://jonathan-hui.medium.com/what-is-new-in-gpt-4-0-ba9779bf7f68?source=rss-bd51f1a63813------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba9779bf7f68</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Jonathan Hui]]></dc:creator>
            <pubDate>Wed, 15 Mar 2023 08:18:37 GMT</pubDate>
            <atom:updated>2023-03-21T04:46:38.507Z</atom:updated>
            <content:encoded><![CDATA[<p>On March 14th, GPT-4 was released. It gave us some insight into its progress toward achieving superhuman proficiency. Nonetheless, you may feel let down by the lack of technical information on the GPT-4 model, such as the speculated model size. In fact, AI companies have become increasingly secretive about their models. OpenAI cited safety and competition as reasons for their refusal to answer those questions. When compared with ChatGPT, GPT-4 is smarter and safer. It is probable that the new model is more complex and/or sophisticated. And many improvements were accomplished through RLHF training with a more refined dataset. Thanks to this, OpenAI was able to mitigate potential risks, reduce misinformation and surpass the capabilities of ChatGPT.</p><h4>Can GPT outperform humans?</h4><p>OpenAI GPT 4.0 achieves a score in the top 10% of test takers on a simulated bar exam, which marks a notable improvement from GPT 3.5 which scored in the lower 10%. The standardized test results below were achieved by GPT 4.0 without undergoing any particular training for these exams. Even though it may not be sufficient for admission to Ivy League schools, the progress made since the release of ChatGPT (a version of GPT 3.5) within just a few months is remarkable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0KDd05Mq1KimPHx-kXuztw.png" /><figcaption><a href="https://openai.com/research/gpt-4">Source</a></figcaption></figure><p>Its internal adversarial factuality evaluations indicate that GPT-4 outperforms GPT 3.5 by 40%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4DCEliUVx1N9Gdp4sr9QLw.png" /><figcaption><a href="https://openai.com/research/gpt-4">Source</a></figcaption></figure><p>However, OpenAI asserts that while GPT 4.0 demonstrates human-level performance on various professional and academic benchmarks, it is less competent than humans in many real-world scenarios. In my own test, it refuses to answer certain toxic questions first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zNk0juxz1qbkDnUBd0FJyw.png" /></figure><p>But by tricking the system, I am still able to deceive it into providing responses. However, as demonstrated later, this becomes significantly more difficult or improbable for more sensitive questions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hSYbTGZxOtFZc4Ezrucamw.png" /></figure><p>It is easy to comprehend the variation in GPT performance between standardized tests and real-life scenarios. Standardized tests are designed with precision to eliminate any ambiguity. The intent of the inquirer is apparent. Conversely, in real-life situations, it is not always easy to grasp the questioner’s intent. GPT 4.0 still struggles to identify sarcasm and negative intentions in some situations. It tends to act quickly and struggles to pose further follow-up questions. Its main goal is not to provide proof for its claims. Nevertheless, it wouldn’t surprise me if GPT achieves superhuman performance for the benchmarks mentioned within the next 6 to 18 months. But it will require further advancements in managing fraud, intention, sentiment, and context for real-life scenarios.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3_EDUF9aR-fhnqfsL4sI6g.png" /><figcaption><a href="https://openai.com/product/gpt-4">Source</a></figcaption></figure><p>GPT 4 can take in and generate up to roughly 25K words. As a result, the system is capable of processing significantly larger articles and documents. However, I believe that there is still room to better understand and accurately capture contextual information in the dialogs of a conversation.</p><h4>Multimodal model</h4><p>GPT is capable of handling multiple modalities, including text and images. An example of this is seen in the “Be My Eyes” app, where users can send images and texts to an AI-powered Virtual Volunteer. The virtual volunteer can quickly address any questions related to the image and provide immediate visual assistance for a wide range of tasks, for instance in the areas of visual impairment and translation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JA-i5zpgJV-na2-Mm16DIQ.png" /><figcaption><a href="https://www.bemyeyes.com/blog/introducing-be-my-eyes-virtual-volunteer">Source</a></figcaption></figure><p>Here are some more instances of OpenAI’s demonstrations, specifically showcasing its intelligence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_usaIcCUEzaAg8_btx9nQw.png" /><figcaption><a href="https://openai.com/research/gpt-4">Source</a></figcaption></figure><p>OpenAI also exemplifies how to explicate a research paper. It has the ability to analyze and comprehend intricate ideas presented in academic articles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Zj0AjcNUHNrzx4G62pQmA.png" /></figure><h4>Steerability</h4><p>OpenAI utilizes a combination of internal and external expertise, as well as public opinion, to develop a set of rules for assessing the responses generated by its models. For instance, it provides guidelines to instruct professionals on how to write, review, and rank responses, which are then used to enhance the models through supervised and reinforcement training.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1OjJeq50SFj0fnjLNx6Wvg.png" /><figcaption><a href="https://openai.com/blog/how-should-ai-systems-behave">Source</a></figcaption></figure><p>Despite this, OpenAI holds the viewpoint that AI should be customizable by individual users while remaining within the limits set by society. Consequently, the responses generated by OpenAI are adaptable and can be personalized based on specific preferences, specified as “system” below. GPT-4 can offer context, limitations, and instructions on how to address queries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BaCmAk0LiqWTDTlILl1Fqg.png" /></figure><p>This can be exemplified through the integration of the Bing interface with GPT.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hEILCmHcNiMWihzLt0bylw.png" /></figure><p>Today, Greg Brockman, Co-Founder and President of OpenAI, provided a further demonstration of this concept. He presented a context for how GPT should respond to his tax question on the left side, and on the right side, he shared a 16-page US IRS tax code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GiOuxCquqzWHXFCxYx4CjQ.png" /><figcaption><a href="https://www.youtube.com/watch?v=outcGtbnMuQ">Source</a></figcaption></figure><p>After following the arduous IRS instructions, GPT was able to calculate and elucidate his family’s standard deduction correctly. If you have dealt with the US IRS tax code before, you will promptly recognize that even straightforward questions require a genius to decipher the answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YVlViKxueH4FjD1vdx5y0Q.png" /><figcaption><a href="https://www.youtube.com/watch?v=outcGtbnMuQ">Source</a></figcaption></figure><h4>Risk Mitigation</h4><p>From the outset of its training process, GPT-4 is designed with a stronger emphasis on alignment and safety.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CuUzp_7HOFNfYPQHmdkCXA.png" /><figcaption><a href="https://cdn.openai.com/papers/gpt-4-system-card.pdf">Source</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fqSVu9_wIAQA-CHiJOCz2w.png" /><figcaption><a href="https://cdn.openai.com/papers/gpt-4-system-card.pdf">Source</a></figcaption></figure><p>The accuracy and safety of the model have been enhanced through RLHF training, in particular, to address adversarial usage, unwanted content, and privacy concerns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lYzA6hZlnnGr0fRoF-mIsQ.png" /><figcaption><a href="https://openai.com/blog/chatgpt">Source</a></figcaption></figure><p>Despite RLHF already being implemented in ChatGPT, GPT-4 is further refined through the careful selection and filtering of pretraining data, expert evaluations, and feedback, enhancements to the model’s safety features, and ongoing monitoring and enforcement. OpenAI reports that training RLHF with the new data has resulted in a reduction of harmful outputs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gnk-afEyVMSP1imqqpqt2g.png" /><figcaption><a href="https://openai.com/research/gpt-4">Source</a></figcaption></figure><p>To illustrate, additional data from domain experts were incorporated to enhance GPT-4’s ability to reject requests relating to the synthesis of hazardous chemicals. In my tests, GPT-4 consistently declines all my attempts to elicit information about breaching TSA security, regardless of how I attempt to deceive it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*14jg9tgVJsTOnUj2JEoa9g.png" /></figure><p>To mitigate the risk of generating harmful outputs, GPT-4 employs reward signals during its RLHF training, teaching the model to decline requests for such content. A GPT-4 zero-shot classifier provides the reward signal by assessing the safety boundaries and completion style of safety-related prompts. In order to prevent the model from rejecting valid requests, a diverse dataset is gathered from multiple sources, and the safety reward signal is applied to both allowed and disallowed categories.</p><h4>More Creative and Powerful</h4><p>Thanks to its extensive general knowledge and advanced problem-solving capabilities, GPT-4 can tackle challenging issues with increased precision.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wxW4BDmfrtAcKxCA69Yd_Q.png" /><figcaption><a href="https://openai.com/product/gpt-4">Source</a></figcaption></figure><p>Brockman also exhibited the remarkable capabilities of GPT 4.0 by asking it to summarize an article about GPT in one sentence, while also requiring every word in the sentence to start with the letter “g”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LtPkRJcsAewOxCNJxWH7Iw.png" /><figcaption><a href="https://www.youtube.com/watch?v=outcGtbnMuQ">Source</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba9779bf7f68" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>