<?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 Lawrence Quesada on Medium]]></title>
        <description><![CDATA[Stories by Lawrence Quesada on Medium]]></description>
        <link>https://medium.com/@thelawrenceq?source=rss-28e9ea2202b7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZZ_KDiqUR6VKMkkREmHjMw.jpeg</url>
            <title>Stories by Lawrence Quesada on Medium</title>
            <link>https://medium.com/@thelawrenceq?source=rss-28e9ea2202b7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 12:15:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thelawrenceq/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[Ransomeware isn’t just for big companies | We learned the hard way.]]></title>
            <link>https://thelawrenceq.medium.com/ransomeware-isnt-just-for-big-companies-we-learned-the-hard-way-fc415c18fa47?source=rss-28e9ea2202b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc415c18fa47</guid>
            <category><![CDATA[ransomware]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[infrastructure]]></category>
            <category><![CDATA[it]]></category>
            <dc:creator><![CDATA[Lawrence Quesada]]></dc:creator>
            <pubDate>Sat, 21 Jun 2025 22:26:02 GMT</pubDate>
            <atom:updated>2025-06-21T22:33:12.186Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fy8Go3-Un8duiZ3pU-Qbvw.png" /></figure><p>Being in IT for several years, I’ve been fortunate never to have been involved in a major cyberattack. I had read about them, heard stories, but never experienced one firsthand. About a month ago, while working with a new client, I was suddenly thrust into responding to a ransomware attack. The ransomware came from a group called <strong>QILIN</strong> — the same group responsible for the attack on several UK hospitals in June 2024.</p><p>Though extremely challenging, it also provided an opportunity to learn about these attacks. Here are a few takeaways for anyone working in IT, Security and Leadership.</p><p>We often talk about <strong>assumptions</strong> when designing cybersecurity strategies — until reality hits. Assuming a small or medium-sized company won’t be targeted is a common, but dangerous, misconception. Always assume the worst.</p><p><strong>Investigate</strong> first. After seeing the attack, I responded immediately and began restoring the infrastructure from backup. A more thorough investigation should have come first. Jumping into full restoration without understanding the scope can waste time and worsen the impact.</p><p><strong>Backups are not enough.</strong> TWe were fortunate to have backups, but that alone wasn’t enough. Restoring and getting systems fully operational is equally critical. Whether local or cloud-based, backups must be separate, accessible, and uncorrupted. Ransomware groups also target backups. Remote storage offers added protection.</p><p><strong>Lateral Movement.</strong> Initially, we assumed a simple restore would solve the issue. But even after restoration, systems were sluggish and unstable. We discovered that not only was the domain controller compromised — almost every connected workstation and endpoint was affected. The compromise was <strong>network-wide</strong>.</p><p><strong>Ransom-note</strong>. True to its name, a ransom note was left on every compromised workstation, detailing how to contact the attackers.</p><p><strong>Virtual Machines are NOT immune</strong>. We were already transitioning from VMware to Proxmox. After the attack, we attempted to restore the VMs — only to find that the <strong>.vmdk</strong> files had been encrypted. Without a backup, the only recovery path would be via a decryptor — which isn’t yet available. Interestingly, our Proxmox VM disks were unaffected. VMware, being more common, is often a larger target.</p><p><strong>Prepare for a Network-wide rebuild.</strong> In the worst-case scenario, a full rebuild may be necessary. To ensure no malicious remnants remain, formatting every workstation and restoring from clean backups may be the only option.</p><p><strong>What we did</strong></p><p>While these are key lessons learned, our response continued with the following</p><p><strong>Stay calm and respond accordingly.</strong> There’s always a solution. If your team is prepared, you can respond effectively and methodically <strong>No Payment</strong>. Though we lost some data and time, we chose <strong>not</strong> to contact or pay the attackers. About two weeks later, our bank notified us that our company had been listed on the dark web. They also warned us not to pay, due to the risk of violating sanctions. Not reaching out or negotiating was the right move.</p><p>Even cloud storage like OneDrive needs to be backed up. Having <strong>redundant, secure backups</strong> and the ability to restore quickly is essential.</p><p>Basic antivirus isn’t enough. We implemented <strong>SentinelOne</strong>, a next-gen solution that gives more visibility and insights into user and network activity</p><p>Even small businesses need a formal cybersecurity policy. It doesn’t have to be long — but it must be followed. During our investigation, we found several <strong>former employees still had active accounts</strong> — from RDP, Active Directory, and firewall access. <strong>Offboarding is just as important as onboarding.</strong></p><p><strong>Firewalls and Remote Access Best Practices</strong>. We found several PCs accessible via <strong>direct RDP</strong> — configured through the ISP router instead of the firewall. Worse, it was exposed via the public IP — not the firewall IP. Ransomware groups commonly exploit open RDP ports. <strong>Disable direct RDP and require VPN access instead.</strong> Users should connect via VPN and then use local IP addresses to access internal systems.</p><p>🛡 <strong>Final Thoughts</strong></p><p>Cyberattacks (Ransomware) incident are not just technical in nature — they’re stress tests for our systems, our teams, and our assumptions. While the experience was extremely challenging, it also brought clarity and priority of what is important: preparation, resilience, and continuous improvement.</p><p><strong>And one final step that should never be overlooked:</strong></p><p>👉 <em>Report the incident to the appropriate agencies.</em></p><p>Doing so helps others stay protected, supports ongoing investigations, and may even help identify decryptors in the future. A great resource is <a href="https://www.nomoreransom.org/">https://www.nomoreransom.org/</a>, which offers support, reporting tools, and decryption guidance for known ransomware strains.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc415c18fa47" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cloud First, Insights Later]]></title>
            <link>https://thelawrenceq.medium.com/cloud-first-insights-later-5f74a7223eff?source=rss-28e9ea2202b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f74a7223eff</guid>
            <category><![CDATA[machine-learning-ai]]></category>
            <category><![CDATA[it-infrastructure]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[cloud-services]]></category>
            <dc:creator><![CDATA[Lawrence Quesada]]></dc:creator>
            <pubDate>Tue, 27 Feb 2024 18:02:04 GMT</pubDate>
            <atom:updated>2024-02-27T18:02:04.500Z</atom:updated>
            <content:encoded><![CDATA[<p>My Reasons Why I’m Prioritizing Cloud over Data Science.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V9UveXLi0T70Pw-nvuns-w.jpeg" /></figure><p>Not too long ago, I embarked on a journey in the exciting Data Science and Machine Learning field. As someone who worked on IT Infrastructure, it would have been a total shift from deploying Windows Servers, Virtual Machines, and various endpoints to Data Gathering, EDA (exploratory data analysis), and running experiments.</p><p>With the onset of COVID-19, I began to take on Data Science, and we encountered several infrastructure challenges. We started to move from being on-premise to remote work. It was also a time wherein I found that I had more time to level by going into Data Science. A notable project I began working on was a gender image translation; I decided to use a GAN (generative adversarial network) that would help me accomplish the task. With limited capabilities and resources, I tried to run the model. I encountered several issues to the point that running it from on-premise resources with limitations was impossible. Upgrading to faster processors that could handle this capability would have cost more than I first anticipated.</p><p>Working on this project, made me realize the need for an AI infrastructure for companies developing all these applications and use cases. This is where cloud services such as AWS (Amazon Web Services), Microsoft Azure, or Google Cloud come in. Because of my experience, I believe that transitioning from a systems background to building cloud infrastructure is more straightforward than moving into data science.</p><p>Here are some reasons why I’m staying with cloud computing rather than moving into AI.</p><p><strong>The need for infrastructure.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uTx12zH31sSm2bpd9rO6eg.jpeg" /></figure><p>Cloud services are not just about Identity Management or Virtual Machines; they have an incredible amount of affordable AI and Machine learning services suck as SageMaker, Rekognition, and Polly. Microsoft Azure also has compute resources, Computer Vision, Azure Machine Learning, and AI Services. There are over 200 services available on each of these platforms their platform.</p><p>These services eliminate the need to acquire on-premise machines. The need to correctly use these services as part of a company’s AI infrastructure is critical. Learning to deploy these models is crucial so the team can properly use them.</p><p><strong>Scalability and elasticity</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bD3zC2W5nYlNqvJIvTsgBg.jpeg" /></figure><p>Cloud services have grown partly because of their lower cost and quick deployment. In addition, their scalability and elasticity have made them more robust, and this is why more organizations are opting to move part or all of their infrastructure to the cloud. These concepts allow you to use only the resources you need on demand. Flexible computational requirements are crucial for machine learning, which can also vary depending on the project or dataset. Adding or subtracting compute power can be accomplished quickly without complicated setups or coordination.</p><p><strong>Who would support all these Data Science, AI, and Machine Learning projects?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9PMx6W6BA_iXjOq3wqh3Ag.jpeg" /></figure><p>From infrastructure planning to deployment, the need for talent capable of supporting Data Science using cloud computing platforms has grown significantly. In addition to Data Science, cloud computing has been one of the more popular online courses on platforms such as Udemy. By prioritizing the cloud over AI, one can position oneself as a valuable asset capable of bridging the gap between innovation and implementation within organizations.</p><p><strong>High Demand</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kHJ4WtN5qn7GBYqHvBT26w.jpeg" /></figure><p>The need for talent and cloud services has been growing. In my recent job interviews, they have either plans to transition to the cloud, have already begun to transition, or want to move more services to the cloud. Some estimates project that the digital transformation into the cloud could generate more than $1 Trillion in worldwide revenue.</p><p>With businesses leveraging cloud-based solutions to streamline, enhance scalability, and drive innovation, the demand is there. AI and Machine Learning solutions are also becoming more prevalent. As the need for computing power increases, it only makes sense to host and scale these applications in the cloud.</p><p><strong>Impact and Contribution</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tN8oq9DZFw0-R2ykAr4ixA.jpeg" /></figure><p>There will always be continuous innovation in both categories, in the cloud and in data. Integrating cloud-based AI solutions into an organization’s IT strategy can provide an efficient way to provide solutions.</p><p>My decision to stay with cloud computing rather than Data Science and understanding of how I can support the continuous evolution of Data for organizations. Cloud computing is critical in enabling AI and machine learning solutions to be researched, processed, and deployed. Shifting from traditional on-premise to cloud-based solutions is done not just because of popularity but also as an approach to seeing how organizations continue to transform and innovate using these solutions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f74a7223eff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sacred Scripts]]></title>
            <link>https://thelawrenceq.medium.com/sacred-scripts-46dc01fbd021?source=rss-28e9ea2202b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/46dc01fbd021</guid>
            <category><![CDATA[pilgrimage]]></category>
            <category><![CDATA[santiago-de-compostela]]></category>
            <category><![CDATA[camino-de-santiago]]></category>
            <dc:creator><![CDATA[Lawrence Quesada]]></dc:creator>
            <pubDate>Sun, 17 Dec 2023 22:27:56 GMT</pubDate>
            <atom:updated>2023-12-17T22:27:56.633Z</atom:updated>
            <content:encoded><![CDATA[<h4>Decoding the English Translations of Camino de Santiago’s Certificates</h4><h3>Introduction</h3><p>It’s been over a month since I completed the Camino de Santiago. I have yet to understand the meaning of the certificates. The completion is quite an achievement anyone who has completed the journey can be proud of. By understanding the translation of these texts, we aim to bridge linguistic gaps, making the pilgrimage experience more accessible while preserving the authenticity of the original Latin text.</p><p>Embarking on the meaning and translation of the Camino de Santiago’s certificates for a non-Latin speaker. It is essential to let you know the tools employed in this linguistic journey. An Artificial Intelligence (A.I.) translation tool and a text image scanner facilitated the translations and text extractions from the original Latin documents. While these aids have been significant in understanding the language and historical texts, it is also critical to acknowledge their limits.</p><h3>The Completion Certificate</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/0*R1iN92Wc4mGVVozR.png" /></figure><h3>English Translation of the Completion Certificate:</h3><p>“Apizulum of this <a href="https://en.wikipedia.org/wiki/Codex_Calixtinus">Codex Calixtinus</a>, the keeper of the seal of the Holy Apostolic and Metropolitan Church of Compostela, Alzarius, custodian of Saint James the Apostle, to all the faithful and pilgrims from all over the world, with the affection of devotion or for the sake of a vow, who come to the thresholds of SAINT JAMES, Our Apostle, Patron and Guardian of Spain, he issues authentic letters of visitation. He makes it known to all and singular those inspecting these presents:</p><p>Mr. Laurentium Tanglao Quesada has devoutly visited this most sacred temple, having completed the journey by foot or on horseback after the last one hundred thousand meters, or by wheel after two hundred, for the sake of piety. In witness of which, these present letters, fortified with the seal of the same Holy Church, are conferred upon him.</p><p>On the 50th day of October in the year 2023</p><ul><li>SEAL APOSTIMIAA José Fernández Lago Dean of the S.A.M.E. Cathedral of Compostela”</li></ul><h3>The Distance Certificate</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hj44n3HH5PA5bO2z.jpg" /></figure><p>English Translation of the Distance Certificate:</p><p>“All the days and nights, as if in one continuous celebration, are dedicated with joy to the honor of the Lord and the apostles. The doors of the same basilica are closed both day and night, and it is in no way allowed to have darkness in it (cf. Rev 21:25), because it shines with the splendid light of candles and lamps as bright as midday. (<a href="https://en.wikipedia.org/wiki/Codex_Calixtinus">Calixtinian Codex</a>)</p><p>The Chapter of the Holy Apostolic Metropolitan Cathedral of Santiago de Compostela, located in the western region of Spain, informs all those who see this certification of visitation letter that Lawrence Tanglao Quesada has visited the Basilica where, from time immemorial, Christians venerate the body of the Blessed Apostle Santiago. On this occasion, the Chapter, prompted by duty and charity, joyfully greets the pilgrim in the name of the Lord and, through the intercession of the Apostle, requests that the Father deign to grant him the spiritual riches of the pilgrimage, as well as material blessings. May Santiago bless him and be blessed.</p><p>Given in Compostela, Destination of the Way of Santiago, on the 30th day of October in the year 2023. After covering 315 km, which began on October 15, through the path of the French Way ACOR COUROSTELA Jose Fernandez Lago Dean of the S.A.M.E. Cathedral of Compostela.”</p><h3>Conclusion</h3><p>It has been a pleasure to share my exploration into the translation of the Latin text. As a reminder, using Artificial Intelligence translation tools facilitated the translations presented here. The original Latin texts were extracted using a text image scanner. While these tools have enabled us to understand the translation, it may be vague. It’s important to acknowledge the limitations of these tools in capturing the subtleties and cultural intricacies inherent in such documents. The Romans still use Latina as the language of the Catholic Church. Native-speaker nuisances may be challenging to come by. I also invite experts in Latin to contribute their insights that collaborative efforts refine and deepen our understanding of the Camino de Santiago’s certificates. Buen Camino.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46dc01fbd021" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[7 Symbols along the Camino de Santiago]]></title>
            <link>https://thelawrenceq.medium.com/7-symbols-along-the-camino-de-santiago-998c999ad8f8?source=rss-28e9ea2202b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/998c999ad8f8</guid>
            <category><![CDATA[santiago-de-compostela]]></category>
            <category><![CDATA[travel]]></category>
            <category><![CDATA[spain]]></category>
            <category><![CDATA[camino-de-santiago]]></category>
            <dc:creator><![CDATA[Lawrence Quesada]]></dc:creator>
            <pubDate>Thu, 21 Sep 2023 17:02:48 GMT</pubDate>
            <atom:updated>2023-09-21T17:02:48.547Z</atom:updated>
            <content:encoded><![CDATA[<h4>Camino de Santiago</h4><p>Symbols and meaning along the way</p><h3>Introduction</h3><p>The Camino de Santiago is a unique journey, giving you a pilgrimage experience. It is a journey, not a destination. Though it ends in the historic city of Santiago de Compostela, the Camino has been a destination of solace, self-reflection, and transformation. This historic city in the Galicia region, Northwest of Spain, is famous for its ancient pilgrimage routes, architecture, and rich history. This is one of the experiences wherein it is truly the journey that counts.</p><p>Throughout this experience, you will encounter several symbols and items that embody the Camino de Santiago. This blog post will introduce you to the different symbols you will encounter.</p><h3>1. The Yellow Arrow (Flecha Amarilla)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/0*nab7bdfVLEjslr9J.jpeg" /></figure><p>The first symbol, the Yellow Arrow is a very important symbol of the Camino. It’s importance cannot be understated as these directional arrows guide the pilgrims trying to reach Santiago de Compostela. They can be found painted on trees, roads, stones, buildings, and other surfaces along the route, and they are often accompanied by the words “Camino de Santiago” or the Scallop Shell to ensure pilgrims do not get lost. Some of these yellow arrows have a unique, distinguishable shape and are always associated with the Camino.</p><h3>2. The Stone Marker</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/0*00RWJGOo4FU50Jt7.jpeg" /></figure><p>The Stone Marker is a symbol that marks the distance left to Santiago de Compostela. Often made of stone, it marks the number of kilometers left to reach Santiago de Compostela. Ancient markers will not contain distance but the symbol of the scallop shell and the yellow arrow. These markers can be found quite often along the entire route, giving guidance and confidence to the pilgrim that they are on the right path. It reminds them how far they have come and how close they are.</p><p>Each marker, a testament to the journey: ‘Every step taken is a step closer to your destiny, and every distance conquered is a testament to your inner strength.’</p><h3>3. The Scallop Shell (La Vieira)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/0*xg8BdyYnQYPkNxxe.jpeg" /></figure><p>The Scallop Shell (La Vieira) is the most iconic symbol of the Camino de Santiago. The shell is often found along the route and is worn by pilgrims to symbolize their journey. It is also used as a directional marker, as the grooves in the shell all converge at a single point, representing the different routes leading to Santiago de Compostela. Whenever you see statues of the twelve apostles at churches, you would easily see Saint James with the shell imprinted on him.</p><p>The shell symbolizes new beginnings as the pilgrims shed their old selves and find a new purpose along the journey.</p><p>The scallop shell can be found abundantly throughout the region. Legend has at least two versions of how the scallop shell became associated with the Camino de Santiago and Saint James.</p><ul><li>After the death of Saint James (one of Jesus’ 12 apostles), his followers brought his body back to Spain via ship. Thinking that his body may have been lost at sea, it washed ashore covered in scallop shells protecting his body.</li><li>Another version tells the story of a wedding. At the wedding, the bride, together with their horse, gets pulled to sea. They survived and returned to shore, protected from the shells.</li></ul><p>Aside from its origin, the shell is also a tool. It is used to drink water or wine. Playa del Orzán beach has them all around.</p><p>The Camino de Santiago is a journey to the west, thus to the end of the world. During Roman times, they believed that Finisterre and Muxía (further west of Santiago de Compostela) were where the world ended. The symbol of the shell is also an assurance that you are still on the right path.</p><p>It is a beacon of transformation that no matter how uncertain the path is, it leads us closer to discovering the essence of our true selves.”</p><h3>4. The Cross of Saint James (Cruz de Santiago):</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/0*EfNvIsmOxrqvXfOI.jpeg" /></figure><p>The Cross of Saint James (Cruz de Santiago) is a symbol that represents Saint James and the Camino de Santiago. Depicted in red, it also represents a sword, with each end of the cross depicted by a fleur-de-lis, a common symbol for knights during that medieval period. The most common understanding is that the cross symbolizes the Christian faith, and the sword defends the faith.</p><p>It is most commonly seen imprinted in the scallop shell. Along the route, the Santiago cross is seen at churches, cathedrals, monasteries, and other Christian religious sites.</p><p>For the dedicated individuals, the Santiago cross evokes tales of devotion, with the reminder, that the Camino is not merely a route but it is a pilgrimage, echoing centuries of dedication to Saint James.”</p><h3>5. The Pilgrims Passport (Credencial del Peregrino):</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cFqW0GIKYbkg_6gzMUYZ5w@2x.jpeg" /></figure><p>The Pilgrim’s Passport (Credencial del Peregrino) or sometimes called the Credential, is as important as it sounds. It is part of the Pilgrim’s journey along the Camino de Santiago. This credential serves as the documented track of the pilgrim’s progress. A testament to their enduring human spirit.</p><p>In addition to holding this credential, they present it to be stamped at various points, including cafes, churches, hostels, and other places of Interest. You can also get a stamp at the post office and some designated stations of the Guardia Civil.</p><p>This credential, also allows you to use Albergue’s or other facilities open to pilgrims along the way. And for those whose journey concludes at the Cathedral of Santiago de Compostela, the Passport is presented as it serves as evidence of that journey, as it transforms — from a key to a keepsake, memories of places visited, lessons learned, and the human spirit that keeps us ever-moving forward.”</p><p>For others, they would continue for another 100km (67 miles) towards the end of the world at Finisterre or Muxía and receive another Compostela.</p><h3>6. The Backpack</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/0*L6Wivwq40KbJyj8g.jpeg" /></figure><p>“Imagine the courage it took to embark on treacherous journeys in the past. Today, the safety we often take for granted is symbolized by the backpack we wear — a representation of our burdens, hopes, and dreams. As we journey forward, we carry with us the lessons of the past, wrapped in the promise of tomorrow. Upon reaching our destination, we find the strength to release all we’ve carried, realizing the weight was never just about survival, but about discovering our true selves. The modern pilgrim, distinguishable by their backpack, is a testament to the enduring human spirit, ever-prepared and always forging ahead.”</p><h3>7. The Walking Stick</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/0*Pu1xXPjNmhWzkVYp.jpeg" /></figure><p>From the ancient form to modern versions, the walking stick has been a steady and safe companion to pilgrims on their journey to Santiago de Compostela. Like the backpack, you would identify the individual as a pilgrim once seen.</p><p>The stick is an essential tool to make the journey more manageable. It distributes the impact and pressure to avoid pain or injury.</p><p>This humble piece of wood also represents strength, support, and resilience. Each step reminds us that we are guided and not alone as pilgrims lean into the stick, as it symbolizes the balance of ourselves and the world around us. The Camino teaches us that sometimes we lead; at other times, we lean, let others lead, and also follow those we lead.”</p><h3>Conclusion</h3><p>It is my hope that you enjoyed reading some important symbols of the Camino de Santiago. As you walk the Camino, there will be lots more symbols than what is listed here.</p><p>These symbols carry centuries of tradition and stories from pilgrims who have walked the same path. They provide a window to your Camino, your experience, and your Story. In every step and every symbol, lies a lesson, and a chance to discover a part of ourselves we would not have thought ourselves capable of. We are more capable than we believe, and I hope the Camino can help us find it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=998c999ad8f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Camino de Santiago 2023 Route]]></title>
            <link>https://thelawrenceq.medium.com/my-camino-de-santiago-2023-route-9cf067a04afe?source=rss-28e9ea2202b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/9cf067a04afe</guid>
            <category><![CDATA[spain]]></category>
            <category><![CDATA[santiago-de-compostela]]></category>
            <category><![CDATA[camino-francés]]></category>
            <category><![CDATA[camino-de-santiago]]></category>
            <category><![CDATA[travel]]></category>
            <dc:creator><![CDATA[Lawrence Quesada]]></dc:creator>
            <pubDate>Fri, 15 Sep 2023 17:01:58 GMT</pubDate>
            <atom:updated>2023-09-15T17:01:58.393Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4XenEZq8Lg5eN23OeCuPVw.png" /></figure><h4>Travel and Camino de Santiago</h4><p>From Leon to Santiago de Compostela, 300+ kilometers</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fec3eNa1w4CI%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dec3eNa1w4CI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fec3eNa1w4CI%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4226a18c8df71d74ea754e8ba4fb8849/href">https://medium.com/media/4226a18c8df71d74ea754e8ba4fb8849/href</a></iframe><h3>Introduction</h3><p>The following is my planned transformative journey spanning 300 kilometers (200 miles) along the Camino de Santiago. My journey begins in the city of Leon; from there, I will encounter medieval bridges, churches, and other wonders. I will also encounter works by Antoni Gaudí’s Episcopal Palace and the Castle of the Knights Templar.</p><p>This pilgrimage culminates at the Cathedral of Santiago de Compostela, in which the relics of St. James are believed to be housed. This journey will be of spiritual reflection, exploration, and immersion.</p><h3>Day 1 — Leon to Hospital de Orbigo — 35.6 km (22.12 miles)</h3><p>Places of Interests:</p><ul><li>Puente de Paso Honroso: This medieval bridge is located in the heart of Hospital de Orbigo, One of Spain’s finest examples of Romanesque architecture. Unique for its design and intricate details, stunning views of the surrounding countryside.</li><li>Church of San Juan: Dating back to the 12th century and is known for its Romanesque architecture and intricate details. It is a popular stop for pilgrims on the Camino de Santiago.</li></ul><h3>Day 2 — Hospital de Orbigo to Astorga — 15.7 km (9.8 miles)</h3><p>Places of Interests:</p><ul><li>Episcopal Palace of Astorga: This palace was designed by Antoni Gaudí and is known for its architecture and beautiful gardens.</li><li>Astorga Cathedral: This beautiful gothic cathedral is located in the heart of Astorga.</li><li>Museo Romano de Astorga: This museum is dedicated to the Roman history in the region. It tells the story of the Astorga during Roman times and its people.</li><li>Ayuntamiento de Astorga: This historic town hall dates back to the 17th century and is known for its beautiful interior and architecture.</li></ul><h3>Day 3 — Astorga to Foncebadon — 26 km (16.1 miles)</h3><p>Places of Interests:</p><ul><li>Ruins of the Hospital de San Juan de Foncebadón: built in the 12th century to provide medical care to pilgrims traveling on the Camino de Santiago. Foncebadón was an important stop on the pilgrimage route, and the hospital was a vital resource for pilgrims who needed medical attention.</li><li>Chapel of Santa Maria: is a sacred place of worship that has been an essential part of the community for many years. Visitors to the chapel are greeted by stunning architecture and beautiful stained glass windows that depict scenes from the Bible.</li></ul><h3>Day 4 — Fondebadon to Ponferrada — 25.8 km (16 miles)</h3><p>Places of Interests:</p><ul><li>The Castle of the Knights Templar: A fortress from the 12th century and considered one of the best-preserved castles in Spain.</li><li>Basílica de Nuestra Señora de la Encina: Dating back to the 16th century, This beautiful church is known for its unique architecture and is located in the city’s historic center.</li><li>Las Médulas: This World Heritage Site is located just outside Ponferrada and is known for its natural beauty. Once a Roman gold mine with spectacular rock formations and hiking trails.</li></ul><h3>Day 5 — Ponferrada to Villafranca del Biezo — 22.3 km (13.9 miles)</h3><p>Places of Interests:</p><ul><li>Church of St. James (Santiago) the apostle: Dating back to the 13th century and is a popular stop for pilgrims on the Camino de Santiago.</li><li>Palace of the Marquisses of Villafranca: This castle is a stunning example of Renaissance architecture. It now houses the town hall and a cultural center.</li><li>Puerta del Perdón: Also known as the Door of Forgiveness, is part of the Church of Santiago and is said to offer forgiveness to pilgrims who pass through it.</li><li>Museo del Bierzo: This museum is dedicated to the history and culture of the Bierzo region. It contains a collection of items and tells the story of its people.</li></ul><h3>Day 6 — Villafranca del Bierzo to La Faba — 23.2 km (14.4 miles)</h3><p>Places of Interests:</p><ul><li>Church of San Juan: Dating back to the 16th century, it is known for its architecture and intricacy.</li><li>Cruz de Ferro: This famous landmark is a tall wooden cross on a hilltop near La Faba. It is a stopping point for pilgrims on the Camino de Santiago, who leave small stones or other objects at its base to symbolizetheir journey.</li><li>Monte Irago: This mountain is located just outside of La Faba and offers views of the surrounding countryside.</li></ul><h3>Day 7 — La Faba to Alto de Poio — 17.5 km (13.9 miles)</h3><p>Places of Interests:</p><ul><li>Iglesia de San Julián: This beautiful church dates back to the 17th century and is known for its stunning architecture and intricate details.</li><li>Cruz de Ferro: This famous landmark is a tall wooden cross on a hilltop near La Faba. It is a stopping point for pilgrims on the Camino de Santiago, who leave small stones or other objects at its base to symbolize theirjourney.</li></ul><h3>Day 8 — Alto de Poio to Calvor — 29.5 km (18.3 miles)</h3><p>Places of Interests:</p><ul><li>Monastery of Santa María de Ferreira de Pallares: This ancient monastery dates back to the Middle Ages and is considered one of Galicia’s finest examples of Romanesque architecture.</li><li>Church of San Miguel de Calvor: This beautiful church is known for its stunning architecture and intricate details. It is a popular stop for pilgrims on the Camino de Santiago.</li><li>Castelo de Calvor: Also known as the Castle of the Counts of Lemos, is an example of stunning medieval architecture.</li></ul><h3>Day 9 — Calvor to Ferreiros — 18.4 km (11.4 miles)</h3><p>Places of Interests:</p><ul><li>Church of Santa María: Dating back to the 12th century, it is known for its Romanesque architecture. Another popular stop for pilgrims on the Camino de Santiago.</li><li>Castro de Castromaior: An ancient hillfort located outside of Ferreiros and considered one of Galicia’s most important archaeological sites. It dates back to the Iron Age.</li><li>Pazo de Ferreiros: This historic manor dates back to the 17th century and is known for its architecture and beautiful gardens. It is now a popular for weddings and special events.</li></ul><h3>Day 10 — Ferreiros to Hospital de la Cruz — 20.6 km (12.8 miles)</h3><p>Places of Interests:</p><ul><li>Church of Santiago: This beautiful church dates back to the 12th century and is known for its stunning architecture and intricate details.</li><li>Monastery of San Salvador de Vilar de Donas: This ancient monastery dates back to the Middle Ages and is considered one of Galicia’s finest examples of Romanesque architecture. It is located outside of Hospital de la Cruz.</li><li>Castro de Viladonga: Dating back to the Iron Age, this ancient hillfort is located just outside Hospital de la Cruz and is considered one of Galicia’s most important archaeological sites.</li></ul><h3>Day 11 — Hospital de la Cruz to Palas de Rei — 16.3 km (10.1 miles)</h3><p>Places of Interests:</p><ul><li>Church of San Tirso: This beautiful church dates back to the 12th century and is known for its stunning Romanesque architecture and intricate details.</li><li>Pazo de Ulloa: This historic manor house dates back to the 16th century and is known for its stunning architecture and beautiful gardens. Another popular destination for weddings and special events.</li><li>Castle of Pambre: This medieval castle is located just outside of Palas de Rei and is considered one of the best-preserved castles of its kind in Galicia.</li><li>Museo Etnográfico Casa do Escudeiro: This museum is dedicated to the history and culture of the Galician people.</li></ul><h3>Day 12 — Palas de Rei to Melide — 19.9 km (12.4 miles)</h3><p>Places of Interests:</p><ul><li>Church of Santa María de Melide: This beautiful church dates back to the 12th century and is known for its stunning Romanesque architecture and intricate details.</li><li>Capilla de San Roque: This small chapel is located just outside of Melide and is dedicated to Saint Roch, a famous saint among pilgrims. A peaceful place to stop and reflect on the journey.</li><li>Museo Terra de Melide: This museum is dedicated to the history and culture of the Melide region.</li><li>Pazo de Lestrove: This historic manor house is located just outside of Melide and is known for its stunning architecture and beautiful gardens.</li></ul><h3>Day 13 — Melida to Arzua — 17.2 km (10.7 miles)</h3><p>Places of Interests:</p><ul><li>Church of Santiago: This beautiful church dates back to the 12th century and is known for its Romanesque architecture.</li><li>Pazo de Brandeso: This historic manor house dates back to the 16th century and is known for its stunning architecture and beautiful gardens.</li><li>Pazo de Santa Cruz de Ribadulla: This historic manor house is located just outside of Arzua and is known for its stunning architecture and beautiful gardens.</li><li>Casa Museo Alvaro Cunqueiro: This museum is dedicated to Alvaro Cunqueiro, one of Galicia’s most famous writers.</li><li>Monastery of Santa María de Oseira: This ancient monastery is located just outside of Arzua and is considered one of the finest examples of Romanesque architecture in Galicia.</li></ul><h3>Day 14 — Arzua to Salceda — 15.3 km (9.5 miles)</h3><p>Places of Interests:</p><ul><li>Church of San Paio: This beautiful church dates back to the 12th century and is known for its stunning Romanesque architecture and intricate details.</li><li>Parque eólico de Monte do Faro: This wind farm is located just outside of Salceda and offers stunning views of the surrounding countryside.</li><li>Museo da Madeira: This museum is dedicated to the Galicia region’s history and culture of woodcraft.</li><li>Pazo de Xaz: This historic manor house is located just outside of Salceda and is known for its stunning architecture and beautiful gardens.</li></ul><h3>Day 15 — Salceda to Lavacolla — 18.6 km (11.6 miles)</h3><p>Places of Interests:</p><ul><li>Iglesia de Santiago de Lavacolla: This beautiful church is located just outside of Santiago de Compostela and is known for its stunning Romanesque architecture.</li><li>Monte do Gozo: This hill, located just outside of Lavacolla, offers stunning views of Santiago de Compostela and the surrounding countryside.</li><li>Pazo de Xelmírez: This historic manor house is located just outside of Lavacolla and is known for its stunning architecture and beautiful gardens.</li></ul><h3>Day 16 — Lavacolla to Santiago de Compostela — 11.2 km (7 miles)</h3><p>Places of Interests:</p><ul><li>The Santiago de Compostela Cathedral: This beautiful cathedral is the final destination of the Camino de Santiago pilgrimage. It houses the shrine of St. James the Apostle and is a must-visit destination in the city.</li><li>The Monastery of San Martin Pinario: This ancient monastery dates back to the Middle Ages and is considered one of Galicia’s finest examples of Baroque architecture.</li><li>The Mercado de Abastos: This market is located in the heart of Santiago de Compostela and offers a wide variety of fresh produce, meats, cheeses, and other local specialties. Here you can shop for souvenirs or grab a bite to eat.</li><li>The Parque de la Alameda: This beautiful park is located in the heart of the city.</li><li>The University of Santiago de Compostela: This university dates back to the 16th century. A great place to visit if interested in academia.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9cf067a04afe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why I’m once again going to walk the Camino de Santiago (The way of Saint James): Disconnect to…]]></title>
            <link>https://thelawrenceq.medium.com/why-im-once-again-going-to-walk-the-camino-de-santiago-the-way-of-saint-james-disconnect-to-1c2db83053e1?source=rss-28e9ea2202b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c2db83053e1</guid>
            <category><![CDATA[buen-camino]]></category>
            <category><![CDATA[pilgrimage]]></category>
            <category><![CDATA[santiago-de-compostela]]></category>
            <category><![CDATA[travel]]></category>
            <category><![CDATA[camino-de-santiago]]></category>
            <dc:creator><![CDATA[Lawrence Quesada]]></dc:creator>
            <pubDate>Fri, 08 Sep 2023 15:02:38 GMT</pubDate>
            <atom:updated>2023-09-08T15:02:38.255Z</atom:updated>
            <content:encoded><![CDATA[<h4>Camino de Santiago</h4><h3>Why I’m once again going to walk the Camino de Santiago (The way of Saint James): Disconnect to Connect</h3><p>Finding your way on the Camino</p><p>I feel fortunate and blessed to have another opportunity to walk the Camino de Santiago. As I plan to challenge myself significantly, I will complete a 300+ kilometer (190-mile) walk from Leon to Santiago de Compostela. It is my hope this journey will continue to serve as an inspiration for others to do the same and to be better.</p><p>To its core, the Camino de Santiago is a journey of transformation. It is a chance to contemplate, meditate and think without any distractions. This is a journey to disconnect in order to connect. Many will attest, including myself, what the Camino can do for you. Be inspired by how the Camino guides you. It is an experience that must be taken firsthand. Though we have different reasons for doing it, we all have our own Camino.</p><p>Remember, you will also be challenged physically, mentally, and emotionally. Because of these, the opportunity to connect more with yourself, nature, and others will arise. But remember to plan, be inspired, and let go of your fear and worry. It is a chance to step out and discover who you are and what you are truly capable of.</p><p><strong>What to expect</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-ZoPk2lkiM5oYa6M.jpeg" /></figure><p>When I did my first Camino, I was told that some of the things I would be doing would be walking 20+ miles a day, walking in the rocks, mud, and uneven pavements, not knowing where I will be spending the night, walking in the rain, in the darkness, carrying a 17-pound backpack every day and perhaps encounter several blisters.</p><p>I also gained new perspectives and learned from others why they are doing it. The journey’s physical, spiritual, and emotional aspects did make me stronger, eliminate things that were not good for me, and embrace things that made me better.</p><p>After all this, will you do it again??</p><p>The short answer is YES!! Without a doubt.</p><p><strong>Why do the Camino again?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*k7srTryPEOLT-aJJ.jpeg" /></figure><p>The physical challenges are only part of the Camino; walking the Camino de Santiago will once again challenge me and give me clarity and direction. Gain skills I can use to succeed. I look forward to what there is to gain, insights, and perspectives as I meet other fellow pilgrims on the same path. I will challenge myself, push my limits, and discover my full capabilities. Each Camino is unique, with a different reason each time.</p><p><strong>What is your Camino?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/0*wnVn-WDgy-4QovUF.jpeg" /></figure><p>Everyone has their own Camino. It is a personal journey that is different for every individual. Some do it to contemplate, others for religious reasons, some for personal growth, and others for the challenge. Others are looking for a transformation.</p><p>I do it not only for all these reasons but to think clearly if I am going in the right direction. To be a better leader and person. To learn more humility. We often take things for granted, as everything is always ready for us. What if we do not know where we will shelter? What food will we be having? It takes away all the safety nets we have been accustomed to. By doing this, we learn, we survive, and we thrive.</p><p>Whatever your reason, the Camino will provide you with the opportunity to disconnect from your daily life and connect with yourself, your surroundings, and others. It will transform and leave you with memories and lessons that you can use daily.</p><p><strong>Conclusion</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/0*iEtuEEgkxWnXcABA.jpeg" /></figure><p>If you seek to connect more with others and the world around you, do something that can transform you and be prepared for the physical and mental challenges the Camino de Santiago has prepared for you.</p><p>It is a personal journey to gain new insights and perspectives as you meet other pilgrims on the same path and discover your full capabilities. Challenge yourself, Embark on a journey, the Camino de Santiago awaits you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c2db83053e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top SQL Queries You Should Know: Using the Pokémon Dataset]]></title>
            <link>https://thelawrenceq.medium.com/top-sql-queries-you-should-know-using-the-pok%C3%A9mon-dataset-ba76840dbc37?source=rss-28e9ea2202b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba76840dbc37</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[dataset]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[pokemon]]></category>
            <dc:creator><![CDATA[Lawrence Quesada]]></dc:creator>
            <pubDate>Fri, 01 Sep 2023 15:02:28 GMT</pubDate>
            <atom:updated>2023-09-01T16:26:20.873Z</atom:updated>
            <content:encoded><![CDATA[<h4>Technology / SQL</h4><h4>20 SQL Queries beginners to advanced users should know + Exporting to CSV</h4><h3>Introduction</h3><p>Getting your head around SQL’s core queries, be it as a newcomer or with years of experience, isn’t just good — it’s essential. We’ve got this list of 20 queries, some for those just starting out and others for those who’ve had years of experience. It’s not just textbook concepts; these are the real-world foundations in actual setups, from Microsoft SQL to PostgreSQL. They show the full spectrum of what SQL can do. The more advanced you get, you’ll find that these aren’t just about getting things done but doing them correctly. At the end of the day, it’s about getting that mix of confidence and sharpness to face any database curveball.</p><h3>The Pokémon Database</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*Ca8eCbWACnsSA5pk.jpg" /></figure><p>In this example, we will be having a bit of fun, so we will use the Pokémon database to showcase SQL queries. The Pokémon database has information on the different types of Pokémon, levels, and other information. Yes, Pikachu is in here. We will use the other SQL queries listed below. The queries listed below will be used to extract and manipulate data. As funny as it is, it will give you a bit of a fun and engaging way to learn SQL. Also, remember, you will be able to apply these skills in real-world databases.</p><p>You may also download the entire database with two tables from it’s source via Kaggle <a href="https://www.kaggle.com/datasets/lrcusack/pokemontrainers">HERE:</a></p><p>CSV Files are shared through my <a href="https://github.com/ltq477/Pokemon_Dataset">GitHub page:</a></p><h3>Top 10 SQL Queries Beginners Users Should Know</h3><ol><li><strong>SELECT</strong> statement: Retrieve data from a table.</li></ol><p>The SELECT statement is used to retrieve data from a table. It is the most basic and commonly used SQL query.</p><p><strong>Example:</strong> Retrieve all the data from the “pokemon” table.</p><pre>SELECT * <br>FROM pokemon;</pre><p>2. <strong>WHERE</strong> clause: Filter data based on specific criteria.</p><p>WHERE clause is used to filter data based on specific criteria. It allows you to retrieve data that meets specific conditions.</p><p><strong>Example:</strong> Retrieve all the “pokemon” that belong to the “trainer” with “id” 1</p><pre>SELECT * <br>FROM pokemon <br>WHERE trainerID = 1;</pre><p>3. <strong>ORDER BY</strong> clause: Sort data based on specific criteria.</p><p>ORDER BY clause is used to sort data based on specific criteria. It allows you to retrieve data in a specific order.</p><p><strong>Example:</strong> Retrieve all the “pokemon” and order them by their “level” in descending order.</p><pre>SELECT * <br>FROM pokemon <br>ORDER BY level DESC;</pre><p>4. <strong>LIMIT</strong> clause: Limit the number of rows returned by a query.</p><ol><li>LIMIT clause is used to limit the number of rows returned by a query. It allows you to retrieve a specific number of rows.</li><li>Example: Retrieve the top 5 “pokemon” with the highest “level”.</li></ol><pre>SELECT * <br>FROM pokemon <br>ORDER BY level <br>DESC LIMIT 5;</pre><p>5. <strong>COUNT </strong>function: Count the number of rows returned by a query.</p><p>COUNT function is used to count the number of rows returned by a query. It allows you to retrieve the number of rows that meet specific criteria.</p><p><strong>Example:</strong> Count the number of “pokemon” that belong to the “trainer” with “id” 1.</p><pre>SELECT COUNT(*) <br>FROM pokemon <br>WHERE trainerID = 1;</pre><p>6. <strong>SUM </strong>function: Calculate the sum of a column.</p><p>SUM function is used to calculate the sum of a column. It allows you to retrieve the total value of a column.</p><p><strong>Example:</strong> Calculate the total “level” of all the “pokemon” that belong to the “trainer” with “id” 1.</p><pre>SELECT SUM(level) <br>FROM pokemon <br>WHERE trainerID = 1;</pre><p><strong>7. AVG</strong> function: Calculate the average of a column.</p><p>AVG function is used to calculate the average of a column. It allows you to retrieve the average value of a column.</p><p><strong>Example:</strong> Calculate the average “level” of all the “pokemon” that belong to the “trainer” with “id” 1.</p><pre>SELECT AVG(level) <br>FROM pokemon <br>WHERE trainerID = 1;</pre><p>8. <strong>GROUP BY</strong> clause: Group rows based on specific criteria.</p><p>GROUP BY clause is used to group rows based on specific criteria. It allows you to retrieve data grouped by a specific column.</p><p><strong>Example:</strong> Group the “pokemon” by their “type” and count the number of “pokemon” in each group.</p><pre>SELECT type1, COUNT(*) <br>FROM pokemon <br>GROUP BY type1;</pre><p>9. <strong>JOIN</strong> clause: Combine data from multiple tables.</p><p>JOIN clause is used to combine data from multiple tables. It allows you to retrieve data that is spread across multiple tables.</p><p><strong>Example:</strong> Retrieve all the “pokemon” and their corresponding “trainer” information.</p><pre>SELECT * <br>FROM pokemon <br>JOIN trainer <br>ON pokemon.trainerID = trainer.id;</pre><p>10. <strong>DISTINCT</strong> clause: Retrieve unique values from a column.</p><p>DISTINCT clause is used to retrieve unique values from a column. It allows you to retrieve only the distinct values of a column.</p><p>Example: Retrieve all the unique “types” of “pokemon”.</p><pre>SELECT DISTINCT type1 <br>FROM pokemon;</pre><h3>Top 10 SQL Queries Advanced Users Should Know</h3><ol><li>Subqueries: Use a query inside another query.</li></ol><p>Subqueries are queries that are used inside another query. They are useful for retrieving data that meets specific criteria.</p><p><strong>Example:</strong> Retrieve all the “pokemon” that belong to the “trainer” with the highest number of “pokemon”.</p><pre>SELECT * FROM pokemon <br>WHERE trainerID = (SELECT trainerID FROM trainer_pokemon GROUP BY trainerID <br>ORDER BY COUNT(*) <br>DESC LIMIT 1);</pre><p>2. <strong>UNION </strong>operator: Combine the results of two or more SELECT statements.</p><p>UNION operator is used to combine the results of two or more SELECT statements. It allows you to retrieve data from multiple tables.</p><p><strong>Example: </strong>Retrieve all the “pokemon” that belong to the “trainer” with “id” 1 and all the “pokemon” with the “type1” “Water”.</p><pre>SELECT * <br>FROM pokemon <br>WHERE trainerID = 1 UNION SELECT * FROM pokemon WHERE type1 = &#39;Water&#39;;</pre><p>3. <strong>EXCEPT</strong> operator: Retrieve records from the first query that are not present in the second query.</p><p>EXCEPT operator is used to retrieve records from the first query that are not present in the second query. It allows you to compare data between two tables.</p><p><strong>Example:</strong> Retrieve all the “pokemon” that belong to the “trainer” with “id” 1 but do not belong to the “trainer” with “id” 2.</p><pre>SELECT * FROM pokemon <br>WHERE trainerID = 1 EXCEPT SELECT * FROM pokemon WHERE trainerID = 2;</pre><p>4. <strong>INTERSECT </strong>operator: Retrieve records that are common to both queries.</p><p>INTERSECT operator is used to retrieve records that are common to both queries. It allows you to compare data between two tables.</p><p><strong>Example:</strong> Retrieve all the “pokemon” that belong to both the “trainer” with “id” 1 and the “trainer” with “id” 2.</p><pre>SELECT * FROM pokemon WHERE trainerID = 1 <br>INTERSECT SELECT * FROM pokemon WHERE trainerID = 2;</pre><p>5. <strong>HAVING </strong>clause: Filter data based on aggregate function values.</p><p>HAVING clause is used to filter data based on aggregate function values. It allows you to retrieve data that meets specific criteria.</p><p><strong>Example:</strong> Retrieve all the “trainer” that have more than 5 “pokemon”.</p><pre>SELECT trainerID <br>FROM trainer_pokemon <br>GROUP BY trainerID <br>HAVING COUNT(*) &gt; 5;</pre><p>6. <strong>IN</strong> operator: Check if a value matches any value in a list or a subquery.</p><p>IN operator is used to check if a value matches any value in a list or a subquery. It allows you to retrieve data that meets specific criteria.</p><p><strong>Example:</strong> Retrieve all the “pokemon” that belong to the “trainer” with “id” 1 or 2.</p><pre>SELECT * FROM pokemon <br>WHERE trainerID <br>IN (1,2);</pre><p>7. <strong>EXISTS</strong> operator: Check if a subquery returns any rows.</p><p>EXISTS operator is used to check if a subquery returns any rows. It allows you to retrieve data that meets specific criteria.</p><p><strong>Example:</strong> Retrieve all the “trainer” that have at least one “pokemon”.</p><pre>SELECT * <br>FROM trainer <br>WHERE EXISTS (SELECT * FROM trainer_pokemon WHERE trainer.id = trainer_pokemon.trainerID);</pre><p>8. <strong>CASE</strong> statement: Perform conditional logic in a query.</p><p>CASE statement is used to perform conditional logic in a query. It allows you to retrieve data that meets specific criteria.</p><p><strong>Example:</strong> Retrieve the “type” of all the “pokemon” and classify them as either “Common” or “Rare” based on their “level”.</p><pre>SELECT type1, <br>CASE WHEN level &lt; 50 <br>THEN &#39;Common&#39; ELSE &#39;Rare&#39; <br>END AS rarity <br>FROM pokemon;</pre><p>9. <strong>INDEXES</strong>: Optimize database performance by creating indexes.</p><p>INDEXES are used to optimize database performance by creating indexes. It allows you to retrieve data faster.</p><p><strong>Example:</strong> Create an index on the “trainerID” column in the “trainer_pokemon” table.</p><pre>CREATE INDEX idx_trainerID ON trainer_pokemon (trainerID);</pre><p>10. <strong>STORED PROCEDURES:</strong> Create a reusable set of SQL statements that can be executed multiple times.</p><p>STORED PROCEDURES are used to create a reusable set of SQL statements that can be executed multiple times. It allows you to retrieve data faster.</p><p><strong>Example:</strong> Create a stored procedure that retrieves all the “pokemon” that belong to a specific “trainer” based on their “id”.</p><pre>CREATE PROCEDURE get_trainer_pokemon (IN trainerID INT) <br>BEGIN SELECT * FROM pokemon WHERE trainerID = trainerID; END</pre><h3>BONUS: Exporting Query Results to CSV</h3><p>Exporting query results to CSV is very common. The CSV format is popular because it is simple, lightweight, and easily imported into other applications like Excel or Google Sheets. Here, we will discuss how to export query results to CSV using the PostgreSQL COPY command.</p><p>To export query results to CSV, you can use the following command:</p><pre>COPY (SELECT * FROM pokemon) TO &#39;pokemon_and_trainer.csv&#39; WITH CSV HEADER;</pre><p>The command will copy the results of the SELECT statement to a CSV file at the specific file path. The WITH CSV HEADER option will include the column headers in the CSV file.</p><p>Here’s a breakdown of the command:</p><ul><li>COPY: This is the PostgreSQL command for copying data between a table and a file.</li><li>(SELECT * FROM pokemon): This is the SELECT statement that retrieves the data you want to export. Replace pokemon with the name of the table you want to export.</li><li>TO &#39;pokemon_and_trainer.csv&#39;: This specifies the file path where you want to save the CSV file. Replace pokemon_and_trainer.csv with the path where you want to save the CSV file.</li><li>WITH CSV HEADER: This option specifies that the output should be in CSV format and that the first line should contain the column headers.</li></ul><p>After running this command, a new CSV file containing the data from your query will be generated at the specified file path.</p><p>PostgreSQL COPY command requires the user running the command to have write access to the file system where the CSV file will be saved. Necessary permission is needed in case you begin to encounter any errors. Ensure you have the necessary permissions to write to the specified file path.</p><p>Exporting query results to CSV can be accomplished with just a few lines of code. Whether you’re working with large datasets or just need to share data with colleagues, the CSV format provides a flexible and portable way to store and distribute data.</p><p>Did I miss anything? Please let me know</p><p>Have fun continuing to learn SQL!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba76840dbc37" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Data Process: A Beginner’s Guide]]></title>
            <link>https://thelawrenceq.medium.com/the-data-process-a-beginners-guide-aee753dd4f03?source=rss-28e9ea2202b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/aee753dd4f03</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[step-by-step-guide]]></category>
            <dc:creator><![CDATA[Lawrence Quesada]]></dc:creator>
            <pubDate>Sat, 26 Aug 2023 17:19:02 GMT</pubDate>
            <atom:updated>2023-08-26T17:19:02.960Z</atom:updated>
            <content:encoded><![CDATA[<h4>Technology / Data</h4><h4>A Step-by-Step Guide to Data Analysis for Beginners</h4><h3>Introduction</h3><p>Data analysis can be as complex or as manageable as you make it. However, it is primarily complicated for beginners due to the complex processes and mathematical concepts involved. Even worse, explanations often include all these concepts without first explaining why they are necessary. With proper guidance, anyone can begin their journey to becoming more familiar with data, whether they are a Data Analyst, a Data Scientist, or Data Enthusiast.</p><p>Data Analysis is broken down into steps that anyone can follow. If you’re a beginner or just looking to improve your skills, this guide provides a foundation approach to getting started in the field of data.</p><p>Frustrated with the lack of explanations when I first began. I hope this guide will take you through the critical steps of understanding data. This begins with defining the problem to telling the story of your findings.</p><h3>The Steps</h3><p><strong>I.</strong> <strong>Define the Problem: What do I need to solve?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z02R2VHgSnlP1HSrlVnq5Q.jpeg" /></figure><p>Like in any solution, we seek answers to a question/problem. What are the questions you are trying to answer? One of the most critical steps, as with many great thinkers. It sets the direction for the project, provides an objective, and ensures that the resulting analyses are relevant and impactful.</p><p><strong>II. Collection of Data: Where do I get my data?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*EvdnqG7r8SgR-IaU.jpg" /></figure><p>The collection of data should be relevant to that to which you are trying to find answers. Data collection can be accomplished through different sources, such as existing databases within a company and publicly available data. Data is now everything. With enormous resources available, it is more accessible than ever. Some datasets you can use to practice with can be found here.</p><p>Resources:</p><ul><li>SQL servers and data from your company</li><li><a href="https://archive.ics.uci.edu/">UC Irvine Data Repository</a></li><li><a href="https://www.kaggle.com/search?q=datasets">Kaggle</a></li><li><a href="https://research.google/resources/datasets/">Google Research</a></li><li><a href="https://aws.amazon.com/opendata/?wwps-cards.sort-by=item.additionalFields.sortDate&amp;wwps-cards.sort-order=desc">Amazon Public Datasets</a></li><li><a href="http://data.gov/">Data.gov</a> (US government open data)</li></ul><p><strong>III. Exploratory Data Analysis (EDA): What kind of data do I have?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zwCHe7_SNrnyDvVO.png" /></figure><p>Exploratory Data Analysis, or EDA, is visually representing the current state of data. We have the ability to have a better understanding of the data if presented through visual representations, relationships, and statistics. This will also help us uncover characteristics and patterns we would have otherwise not thought of.</p><p>Before complex modeling and algorithms, EDA is used to gain an intuitive understanding of the dataset. Some findings can identify outliers, distribution trends, and relationships between features(columns). Visualization methods for creating charts, such as histograms, scatter plots, and heat maps, will add more weight to your findings.</p><p>A hypothesis is formed using exploratory data analysis (EDA), which helps develop models and tests. Providing direction for the data cleansing and transformation procedures also helps with the next phase. Making educated judgments on how to handle any concerns may be achieved by spotting data discrepancies or missing numbers.</p><p>EDA involves more than just understanding data; it also means making sure that the following analytical techniques are accurate.</p><p><strong>IV. Data Cleaning (Data Preparation): Having reliable data</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gJ2shCdOF5QoSslu.png" /></figure><p>Data cleaning also referred to as data preparation, is the next. This step is to confirm that the data is reliable.</p><p>Errors and inconsistencies, such as missing or blank values in datasets, can lead to misleading results and errors in judgment. Inconsistencies can include duplicate values, non-standard format, typos, and inaccuracies. “Numbers” are listed as their “name.” Some amusing and misleading information, such as writing “Mickey Mouse” under the name field. Addressing these imperfections, data cleaning enhances the quality and reliability of the dataset.</p><p>Data Cleaning also involves transforming variables, creating new features(columns), or scaling data suitable for a specific analytical technique. Thorough data cleaning can significantly improve the performance and accuracy of models.</p><p>Without this, data can be considered inaccurate and not suitable.</p><p>V<strong>. Analyze Data (Create charts, infographics, models): Insightful decision-making</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sLPg1ZGSfGX4ggUd.png" /></figure><p>The Heart of Insightful Decision-Making, after data has been cleaned, analyzing the data is the next important step.</p><p>The raw data is improved and changed into clean and proper data from which you may extract meaningful insights and conclusions. Applying inferential statistics to make predictions or draw conclusions depends on the objectives.</p><p>Other techniques like classification, regression, clustering, and machine learning can further uncover insights, patterns, trends, and relationships.</p><p>Visualization tools, like bar charts, heat maps, and line graphs, play a crucial role by presenting analytical results intuitively and understandably.</p><p>One of the main differences between a Data Analyst and a Scientist. The Data Scientists use more models and conduct a variety of algorithms and experiments on the Data.</p><p>Data analysis is iterative; it’s common to revisit the data preparation phase if anomalies are discovered or the data needs further refinement for analysis. The culmination of data analysis should always align with the original research questions or business objectives. Proper visualization allows businesses and other organizations to make informed decisions, predict future trends, and understand inherent occurrences when done correctly. A proper understanding of data stands out between raw information and actionable knowledge.</p><p><strong>VI. Tell your Story (Present your findings): Conveying Insights with Narrative Power</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*f2zjA6YmmF3v8VA8.png" /></figure><p>Once data analysis has unearthed valuable insights, the following essential phase is presenting these findings, often achieved through data storytelling. Data storytelling goes beyond just showcasing numbers; it’s about weaving a compelling narrative that makes the data resonate with its audience. A successful data story will always start with a clear focus, homing in on the most critical insights uncovered during the analysis phase. Utilizing visualization tools like charts, graphs, and infographics aids in illustrating complex data points, making them more digestible and memorable. The choice of visuals should always serve the story, emphasizing key messages and facilitating understanding. Moreover, a narrative structure with a beginning, middle, and end can guide the audience through the data journey, illuminating the significance of the insights derived. Context is crucial; findings are often enriched by situating them within broader industry trends, historical data, or market benchmarks. Equally important is addressing potential implications, solutions, or actions that stem from the findings. Data storytelling is about presenting facts and engaging, persuading, and inspiring the audience to take informed actions.</p><p><strong>Conclusion</strong></p><p>It is my hope that I have provided meaningful insight. As you begin your data journey, whether it be in Business intelligence or wanting a role as a Data Analyst, Scientist, Engineer, or QA, you have gained an understanding of the data process and that compelling data storytelling ensures that the hard work you have done to gain significant insights doesn’t just end up as forgotten, but is used as a catalyst for meaningful change. Have fun and enjoy the world of Data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aee753dd4f03" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the Camino de Santiago: The Walk of Saint James]]></title>
            <link>https://thelawrenceq.medium.com/understanding-the-camino-de-santiago-the-walk-of-saint-james-8dd52afbbddd?source=rss-28e9ea2202b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/8dd52afbbddd</guid>
            <category><![CDATA[spain]]></category>
            <category><![CDATA[santiago-de-compostela]]></category>
            <category><![CDATA[compostela]]></category>
            <category><![CDATA[travel]]></category>
            <category><![CDATA[camino-de-santiago]]></category>
            <dc:creator><![CDATA[Lawrence Quesada]]></dc:creator>
            <pubDate>Mon, 21 Aug 2023 04:53:02 GMT</pubDate>
            <atom:updated>2023-08-22T01:12:10.882Z</atom:updated>
            <content:encoded><![CDATA[<h4>Travel, Santiago de Compostela</h4><h4>Tracing the Ancient Pilgrimage Path</h4><p>More popular in Europe than the United States, the Camino de Santiago and the Kumano Kodo in Japan are the only two walks registered as cultural heritage sites by UNESCO. Though I have long considered myself a seasoned traveler, this journey opened new experiences and challenges. The Camino de Santiago is more than just a walk; it is a journey of self-discovery.</p><p>The last Camino de Santiago I completed was on October 2022. We ended up at Santiago de Compostela on November 1, 2022, in time for a holiday. For that last year, I have been thinking of doing it again. For reasons unknown to me yet, but something I hope to find along the way.</p><p><strong>What is the Camino de Santiago?</strong></p><p>The Camino de Santiago is a pilgrimage in Spain comprising several routes, eventually taking you to your final destination, the cathedral of Santiago de Compostela in the gorgeous city of Santiago de Compostela. This catholic tradition is now open to everyone from all walks of life and for different reasons. This tradition has it that this route has been taken by pilgrims beginning at least in the middle ages.</p><p>It is one of the three great pilgrimages of Christendom. The other two are Israel and Rome.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mWWdTPAFM6GSt72TWMJpZw.jpeg" /><figcaption>The Cathedral of Santiago de Compostela</figcaption></figure><p><strong>A Short History</strong></p><p>One of Jesus’ apostles was Saint James (Santiago in Spanish). In the early days of Christianity, Saint James, including the rest of the apostles, began their mission of evangelization by traveling the world and spreading the good news. In their travels, Saint James ended up evangelizing throughout Spain. Thus he is known as the patron saint of Spain. He eventually returned to Judea, where he was later martyred (beheaded).</p><p>His body was eventually returned to Spain, got lost, and was once again discovered several hundred years later. With the discovery of his remains, a Cathedral was built in his honor. His relics still remain in the church, visited by the faithful daily.</p><p><strong>How do you get there?</strong></p><p>There are several routes and trails to get to Santiago de Compostela. The most popular official one is the French route which starts in the southern French city of Saint Jean de Port. This route is approximately 761.8 kilometers and takes about 45 days.</p><p>There are other routes, such as the Portuguese route, which takes you walking up the coast of Portugal until you reach Santiago de Compostela. Other routes begin in the city of Seville in the Andalusia region of southern Spain. There is also the primitive route, which is believed to be the first route taken by the first pilgrims and King Alfonso II.</p><p>Other unofficial routes can start as far back as Germany, Sweden, and countries across Europe. One could say the Camino begins at their home. For the genuinely adventurous pilgrims, they walk from Turkey or as far as Israel and beyond. One can only imagine.</p><p><strong>What happens on the Camino?</strong></p><p>Some of the things that you experience, (1) walking 15 to 20 km a day, or maybe even longer, (2) walking in the rain, mud, getting soaked, (3) not knowing where to sleep that night, (4) carrying a backpack yourself the entire time, (5) getting blisters, (6) Walking up steep inclines for hours (7) Physical and Emotional intensity of the challenges. Imagine looking at the same boardwalk for a few days without a change in scenery. Your mind begins to calm down.</p><p>As you pass the different towns, villages, and cities, well-wishers will wish you a good journey by saying, “Buen Camino.” The Camino by itself is also a gastronomical experience as you try the different cuisines. My personal recommendation is “Pimiento de Padron” (Padron Peppers). How can a simple dish of peppers fried in Olive oil and salted be that delicious?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d_eU4vrbA7LQ0bQttuXQzw.jpeg" /><figcaption>Padron Peppers (Pimiento de Padron)</figcaption></figure><p>Through these challenges, you will find it very rewarding. You begin to meet people from all walks of life and at different stages. They become your friends. You also start to find connections in people you would not have thought of. One would receive a positive realization as they view things around them, as their heart is touched.</p><p>Everyone has their own Camino; you will find yours.</p><p><strong>What do you see at the Camino?</strong></p><p>One of the familiar sights you will see is stone markers and yellow arrows indicating the way to Santiago de Compostela.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3dJXZtiNQKLRH37z0MY7Gg.jpeg" /><figcaption>The modern stone marker shows direction and distance.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v6AEYsPrEhD6QJs8RC11Mg.jpeg" /><figcaption>The older stone marker shows direction but not the distance.</figcaption></figure><p><strong>Reasons to do it</strong>.</p><p>You will also experience an awakening, whether it is spiritual or not. Challenge yourself physically and emotionally. You will be able to connect with people from all walks of life and make new friends. Upon completing the Camino de Santiago, you will experience different cultures and cuisines and feel accomplished.</p><p>Remember that the Camino is a personal journey, and everyone’s experience will differ. Embrace the journey and enjoy the adventure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8dd52afbbddd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your First CycleGAN using Pytorch]]></title>
            <link>https://thelawrenceq.medium.com/your-first-cyclegan-using-pytorch-85546dfe6317?source=rss-28e9ea2202b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/85546dfe6317</guid>
            <category><![CDATA[cyclegan]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[gans]]></category>
            <dc:creator><![CDATA[Lawrence Quesada]]></dc:creator>
            <pubDate>Mon, 30 Nov 2020 02:02:24 GMT</pubDate>
            <atom:updated>2023-08-22T01:21:09.368Z</atom:updated>
            <content:encoded><![CDATA[<h4>Technology</h4><p>Introduction to cycleGANs using pytorch and a Gender swap image translation</p><p><em>A brief History…</em></p><p>A GAN or Generative Adversarial network was introduced as part of a research paper in 2014 by Ian Goodfellow. In this paper, he initially proposed generating new data with an existing set of data using competing neural networks. In 2017, building on this foundation, another group or researchres (<a href="https://arxiv.org/search/cs?searchtype=author&amp;query=Zhu%2C+J">Jun-Yan Zhu</a>, <a href="https://arxiv.org/search/cs?searchtype=author&amp;query=Park%2C+T">Taesung Park</a>, <a href="https://arxiv.org/search/cs?searchtype=author&amp;query=Isola%2C+P">Phillip Isola</a>, <a href="https://arxiv.org/search/cs?searchtype=author&amp;query=Efros%2C+A+A">Alexei A. Efros</a>) used this method to create their own cycleGAN in order to convert images. One of the more classical example is converting horses to zebras and the other way around,. From these works, the subject of GANs has continued to evolve with different approaches and styles on using GANs.</p><p><em>Your First GAN</em></p><p>Even before using GANs for image to image translation, it has been used in other fields to generate new data with the help of existing data. These sets of data are going to be completely different but close to each other where it may or may not be distinguishable from one another.,\</p><p><em>Use Cases</em></p><p>Though popularized when using this technique with images, there are also non-image related applications. This can be used to discover new proteins when searching for a new vaccine. Law Enforcement can also use this technology to identify suspects amd</p><p><em>Purpose of this article</em></p><p>Assuming that you have seen GANs and cycleGANs through several sources, I will try to guide you through the process of creating a cycleGAN with minimal explanation but instead show you how to create one. We do not want to complicate the process so Phd’s and non-PhD’s would be able to create their own GAN.</p><p><em>Now we begin…</em></p><p>Together with creating several functions and classes, The following are some of the requirements needed in creating a cycle GAN.</p><ol><li>Python Libraries</li></ol><p>2. Image Dataset</p><p>3. CUDA — In order to use the GPU</p><p>4. DataLoader</p><p>5. Transformer</p><p>6. Weights Function</p><p>7. Resnet or a Residual Learning Network</p><p>8. 4 Artificial Neural Networks (2 Generators, 2 Discriminators)</p><p>9. Loss Function</p><p>10. Optimizers</p><p>11. Autoencoder</p><p>Python Libraries:</p><pre><strong>import</strong> <strong>os</strong>, <strong>random</strong>, <strong>cv2</strong>, <strong>glob</strong>, <strong>itertools</strong>, <strong>shutil</strong></pre><pre><strong>import</strong> <strong>numpy</strong> <strong>as</strong> <strong>np</strong></pre><pre><strong>import</strong> <strong>pandas</strong> <strong>as</strong> <strong>pd</strong></pre><pre><strong>import</strong> <strong>matplotlib.pyplot</strong> <strong>as</strong> <strong>plt</strong></pre><pre><strong>import</strong> <strong>matplotlib.image</strong> <strong>as</strong> <strong>mpimg</strong></pre><pre><strong>from</strong> <strong>PIL</strong> <strong>import</strong> Image</pre><pre><strong>import</strong> <strong>torch</strong></pre><pre><strong>import</strong> <strong>torch.nn</strong> <strong>as</strong> <strong>nn</strong></pre><pre><strong>import</strong> <strong>torch.optim</strong> <strong>as</strong> <strong>optim</strong></pre><pre><strong>import</strong> <strong>torch.utils.data</strong> <strong>as</strong> <strong>data</strong></pre><pre><strong>from</strong> <strong>torch.autograd</strong> <strong>import</strong> Variable</pre><pre><strong>import</strong> <strong>torchvision</strong></pre><pre><strong>from</strong> <strong>torchvision</strong> <strong>import</strong> datasets, transforms, utils</pre><pre><strong>from</strong> <strong>tqdm.notebook</strong> <strong>import</strong> tqdm</pre><pre><strong>import</strong> <strong>warnings</strong></pre><pre>warnings.filterwarnings(&#39;ignore&#39;)</pre><p><strong>The Image Dataset</strong></p><p>I have used the <a href="https://susanqq.github.io/UTKFace/">UTKFace</a> Image dataset. This dataset was made publicly available to us by Yang Song and Zhifei Zhang.</p><p>There are approximately 65,000 images which has been labeled. Aside from the images, landmark files have also been provided. For the purpose of this project, we will not be using any of the landmark files / pointers.</p><p><strong>Viewing the Images</strong></p><p><strong>for</strong> i <strong>in</strong> range(5):</p><p>file = np.random.choice(os.listdir(UTKFace_folder))</p><p>image_path= os.path.join(UTKFace_folder, file)</p><p>image=mpimg.imread(image_path)</p><p>plt.subplot(1,10,i+1)</p><p>plt.imshow(image)</p><p><strong>Resizing the Images</strong></p><p>The original images comes in a 200x200 image size. We can first resize this images to a 128x128 for faster learning. This can also be done in the transform section, but for simplification, we will resize them here. The code below will rezise the images on the same path the current images are located. There will be no need to create another folder, except for backup purposes.</p><pre><em>#Gathering all the images and combining them to one</em></pre><pre>all_im = glob(os.path.join(basepath, &#39;**/*&#39;))</pre><pre>for im in tqdm(all_im):</pre><pre>image = Image.open(im)</pre><pre>image = image.resize((128,128), Image.BILINEAR)</pre><pre>image.save(im)</pre><p><strong>Preparing the Training and Testing Set.</strong></p><p>We will need to create 4 sets of images. The training set and a test set of the original images, in this case, the male images. The second set will be images we want to convert them to, also in this case, the Female images dataset.</p><p>In preparing the images, one of the most critical factors is to make sure that the quantity of images are the same for each of the Training set and testing sets. In this case the quantity for each set are the following:</p><p>TrainA_Male: 7, 549 Images</p><p>TestA_Male: 463 Images</p><p>TrainB_Female:7, 549 Images</p><p>TestB_Female: 463 Images</p><p>To speed up the training and see if this model works, I have only taken into account images with their ages ranging from 20 years old to 70 years old. Anyone younger or older images has been removed.</p><p><strong>Parameters:</strong></p><p>Global parameters where also created in order to standardize and make it easier to recall what assignments where made. Keep an eye out for the variables you assign here as this may be the source of some issues you may encounter.</p><pre>parameters = {&#39;ngf&#39;:32,</pre><pre>&#39;ndf&#39;:64,</pre><pre>&#39;num_epochs&#39;:100,</pre><pre>&#39;decay_epoch&#39;: 100,</pre><pre>&#39;lgG&#39;:0.0002,</pre><pre>&#39;lgD&#39;:0.0002,</pre><pre>&#39;beta1&#39;:.5,</pre><pre>&#39;beta2&#39;:.9999,</pre><pre>&#39;lambdaA&#39;:10,</pre><pre>&#39;lambdaB&#39;:10,</pre><pre>&#39;batch_size&#39;:32,</pre><pre>&#39;pool_size&#39;:50,</pre><pre>&#39;img_width&#39;:256,</pre><pre>&#39;img_height&#39;:256,</pre><pre>&#39;img_depth&#39;:3,</pre><pre>&#39;input_size&#39;:128,</pre><pre>&#39;resize_size&#39;:128,</pre><pre>&#39;crop_size&#39;:256,</pre><pre>&#39;fliplr&#39;:<strong>True</strong>,</pre><pre>&#39;num_resnet&#39;:6,</pre><pre>&#39;num_workers&#39;:2}</pre><p><strong>Using the GPU</strong></p><p>Because we also want to use the GPU for a faster process, we will be using CUDA with the following code.</p><pre><strong>def</strong> to_numpy(x):</pre><pre><strong>return</strong> x.data.cpu().numpy()</pre><pre><em>#use GPU</em></pre><pre>device = torch.device(&quot;cuda:0&quot; <strong>if</strong> torch.cuda.is_available() <strong>else</strong> &quot;cpu&quot;)</pre><p><strong>The Transformer</strong></p><p>The transformer will transform the images into a tensor and normalize them. Note that we first transform the image into a tensor before normalizing them.</p><pre><strong>def</strong> to_numpy(x):</pre><pre><strong>return</strong> x.data.cpu().numpy()</pre><pre><em>#use GPU</em></pre><pre>device = torch.device(&quot;cuda:0&quot; <strong>if</strong> torch.cuda.is_available() <strong>else</strong> &quot;cpu&quot;)</pre><p>The transformer is also a great tool we can use to add more data. Neural Networks work well with more data. You may click here for more information on <a href="https://pytorch.org/docs/stable/generated/torch.nn.Transformer.html">transformers</a>.</p><p><strong>Creating an Image pool function</strong></p><p>The image pool function will be used when retrieving images from the fake image pool at a later point.</p><pre><strong>class</strong> <strong>ImagePool</strong>():</pre><pre><strong>def</strong> __init__(self, pool_size):</pre><pre>self.pool_size = pool_size</pre><pre><strong>if</strong> self.pool_size &gt; 0:</pre><pre>self.num_imgs = 0</pre><pre>self.images = []</pre><pre><strong>def</strong> query(self, images):</pre><pre><strong>if</strong> self.pool_size == 0:</pre><pre><strong>return</strong> images</pre><pre>return_images = []</pre><pre><strong>for</strong> image <strong>in</strong> images.data:</pre><pre>image = torch.unsqueeze(image, 0)</pre><pre><strong>if</strong> self.num_imgs &lt; self.pool_size:</pre><pre>self.num_imgs = self.num_imgs + 1</pre><pre>self.images.append(image)</pre><pre>return_images.append(image)</pre><pre><strong>else</strong>:</pre><pre>p = random.uniform(0, 1)</pre><pre><strong>if</strong> p &gt; 0.5:</pre><pre>random_id = random.randint(0, self.pool_size-1)</pre><pre>tmp = self.images[random_id].clone()</pre><pre>self.images[random_id] = image</pre><pre>return_images.append(tmp)</pre><pre><strong>else</strong>:</pre><pre>return_images.append(image)</pre><pre>return_images = Variable(torch.cat(return_images, 0))</pre><pre><strong>return</strong> return_images</pre><p><strong>Plotting the Images</strong></p><p>In order to retrieve the images, we will also want a function to plot the results.</p><pre><strong>def</strong> plot_train_result(real_image, gen_image, recon_image, epoch, save=<strong>False</strong>,</pre><pre>show=<strong>True</strong>, fig_size=(15, 15)):</pre><pre>fig, axes = plt.subplots(2, 3, figsize=fig_size)</pre><pre>imgs = [to_numpy(real_image[0]), to_numpy(gen_image[0]),</pre><pre>to_numpy(recon_image[0]),</pre><pre>to_numpy(real_image[1]), to_numpy(gen_image[1]),</pre><pre>to_numpy(recon_image[1])]</pre><pre><strong>for</strong> ax, img <strong>in</strong> zip(axes.flatten(), imgs):</pre><pre>ax.axis(&#39;off&#39;)</pre><pre>img = img.squeeze()</pre><pre>img = (((img - img.min()) * 255) / (img.max() - img.min())).transpose(1, 2, 0).astype(np.uint8)</pre><pre>ax.imshow(img, cmap=<strong>None</strong>, aspect=&#39;equal&#39;)</pre><pre>plt.subplots_adjust(wspace=0, hspace=0)</pre><pre>title = &#39;Epoch <strong>{0}</strong>&#39;.format(epoch + 1)</pre><pre>fig.text(0.5, 0.04, title, ha=&#39;center&#39;)</pre><p><strong>The Dataloader</strong></p><p>Since we will be unable to load the entire set of images, as it may take enormous amounts of time, we will use a dataloader to load the images in sets. This is a more efficient way of loading datasets as a substantial increase in data is encountered.</p><pre><strong>class</strong> <strong>DatasetFromFolder</strong>(data.Dataset):</pre><pre><strong>def</strong> __init__(self, image_dir, subfolder=&#39;train&#39;, transform=<strong>None</strong>,</pre><pre>resize_scale=<strong>None</strong>, crop_size=<strong>None</strong>, fliplr=<strong>False</strong>):</pre><pre>super(DatasetFromFolder, self).__init__()</pre><pre>self.input_path = os.path.join(image_dir, subfolder)</pre><pre>self.image_filenames = [x <strong>for</strong> x <strong>in</strong> sorted(os.listdir(self.input_path))]</pre><pre>self.file_num = len(self.image_filenames)</pre><pre>self.transform = trans</pre><pre>self.resize_scale = resize_scale</pre><pre>self.crop_size = crop_size</pre><pre>self.fliplr = fliplr</pre><pre><strong>def</strong> __len__(self):</pre><pre><strong>return</strong> len(self.image_filenames)</pre><pre><strong>def</strong> __getitem__(self, index):</pre><pre><em># Load Images</em></pre><pre>img_fn = os.path.join(self.input_path, self.image_filenames[index])</pre><pre>img = Image.open(img_fn).convert(&#39;RGB&#39;)</pre><pre><em>#preprocessing</em></pre><pre><strong>if</strong> self.resize_scale:</pre><pre>img = img.resize((self.resize_scale, self.resize_scale),</pre><pre>Image.BILINEAR)</pre><pre><strong>if</strong> self.crop_size:</pre><pre>x = random.randint(0, self.resize_scale - self.crop_size + 1)</pre><pre>y = random.randint(0, self.resize_scale - self.crop_size + 1)</pre><pre>img = img.crop((x, y, x + self.crop_size, y + self.crop_size))</pre><pre><strong>if</strong> self.fliplr:</pre><pre><strong>if</strong> random.random() &lt; 0.5:</pre><pre>img = img.transpose(Image.FLIP_LEFT_RIGHT)</pre><pre><strong>if</strong> self.transform <strong>is</strong> <strong>not</strong> <strong>None</strong>:</pre><pre>img = self.transform(img)</pre><pre><strong>return</strong> img</pre><p><strong>The DataLoader load from folder</strong></p><pre><strong>class</strong> <strong>DatasetFromFolder</strong>(data.Dataset):</pre><pre><strong>def</strong> __init__(self, image_dir, subfolder=&#39;train&#39;, transform=<strong>None</strong>,</pre><pre>resize_scale=<strong>None</strong>, crop_size=<strong>None</strong>, fliplr=<strong>False</strong>):</pre><pre>super(DatasetFromFolder, self).__init__()</pre><pre>self.input_path = os.path.join(image_dir, subfolder)</pre><pre>self.image_filenames = [x <strong>for</strong> x <strong>in</strong> sorted(os.listdir(self.input_path))]</pre><pre>self.file_num = len(self.image_filenames)</pre><pre>self.transform = trans</pre><pre>self.resize_scale = resize_scale</pre><pre>self.crop_size = crop_size</pre><pre>self.fliplr = fliplr</pre><pre><strong>def</strong> __len__(self):</pre><pre><strong>return</strong> len(self.image_filenames)</pre><pre><strong>def</strong> __getitem__(self, index):</pre><pre><em># index = total_index % self.file_num</em></pre><pre><em># Load Images</em></pre><pre>img_fn = os.path.join(self.input_path, self.image_filenames[index])</pre><pre>img = Image.open(img_fn).convert(&#39;RGB&#39;)</pre><pre><em>#preprocessing</em></pre><pre><strong>if</strong> self.resize_scale:</pre><pre>img = img.resize((self.resize_scale, self.resize_scale),</pre><pre>Image.BILINEAR)</pre><pre><strong>if</strong> self.crop_size:</pre><pre>x = random.randint(0, self.resize_scale - self.crop_size + 1)</pre><pre>y = random.randint(0, self.resize_scale - self.crop_size + 1)</pre><pre>img = img.crop((x, y, x + self.crop_size, y + self.crop_size))</pre><pre><strong>if</strong> self.fliplr:</pre><pre><strong>if</strong> random.random() &lt; 0.5:</pre><pre>img = img.transpose(Image.FLIP_LEFT_RIGHT)</pre><pre><strong>if</strong> self.transform <strong>is</strong> <strong>not</strong> <strong>None</strong>:</pre><pre>img = self.transform(img)</pre><pre><strong>return</strong> img</pre><p><strong>The Convolutional network</strong></p><p>CNN Resources:</p><p><a href="https://en.wikipedia.org/wiki/Convolutional_neural_network">https://en.wikipedia.org/wiki/Convolutional_neural_network</a></p><pre><strong>class</strong> <strong>DatasetFromFolder</strong>(data.Dataset):</pre><pre><strong>def</strong> __init__(self, image_dir, subfolder=&#39;train&#39;, transform=<strong>None</strong>,</pre><pre>resize_scale=<strong>None</strong>, crop_size=<strong>None</strong>, fliplr=<strong>False</strong>):</pre><pre>super(DatasetFromFolder, self).__init__()</pre><pre>self.input_path = os.path.join(image_dir, subfolder)</pre><pre>self.image_filenames = [x <strong>for</strong> x <strong>in</strong> sorted(os.listdir(self.input_path))]</pre><pre>self.file_num = len(self.image_filenames)</pre><pre>self.transform = trans</pre><pre>self.resize_scale = resize_scale</pre><pre>self.crop_size = crop_size</pre><pre>self.fliplr = fliplr</pre><pre><strong>def</strong> __len__(self):</pre><pre><strong>return</strong> len(self.image_filenames)</pre><pre><strong>def</strong> __getitem__(self, index):</pre><pre><em># index = total_index % self.file_num</em></pre><pre><em># Load Images</em></pre><pre>img_fn = os.path.join(self.input_path, self.image_filenames[index])</pre><pre>img = Image.open(img_fn).convert(&#39;RGB&#39;)</pre><pre><em>#preprocessing</em></pre><pre><strong>if</strong> self.resize_scale:</pre><pre>img = img.resize((self.resize_scale, self.resize_scale),</pre><pre>Image.BILINEAR)</pre><pre><strong>if</strong> self.crop_size:</pre><pre>x = random.randint(0, self.resize_scale - self.crop_size + 1)</pre><pre>y = random.randint(0, self.resize_scale - self.crop_size + 1)</pre><pre>img = img.crop((x, y, x + self.crop_size, y + self.crop_size))</pre><pre><strong>if</strong> self.fliplr:</pre><pre><strong>if</strong> random.random() &lt; 0.5:</pre><pre>img = img.transpose(Image.FLIP_LEFT_RIGHT)</pre><pre><strong>if</strong> self.transform <strong>is</strong> <strong>not</strong> <strong>None</strong>:</pre><pre>img = self.transform(img)</pre><pre><strong>return</strong> img</pre><p><strong>The De-Convolutional Network</strong></p><p>de-convolution resources:</p><p><a href="https://datascience.stackexchange.com/questions/6107/what-are-deconvolutional-layers">https://datascience.stackexchange.com/questions/6107/what-are-deconvolutional-layers</a></p><pre><strong>class</strong> <strong>DeconvBlock</strong>(torch.nn.Module):</pre><pre><em>#Initialization Function</em></pre><pre><strong>def</strong> __init__(self, input_size, output_size, kernel_size=3, stride=2,</pre><pre>padding=1, output_padding=1, activation=&#39;relu&#39;,</pre><pre>batch_norm=<strong>True</strong>):</pre><pre>super(DeconvBlock,self).__init__()</pre><pre>self.deconv = torch.nn.ConvTranspose2d(input_size, output_size,</pre><pre>kernel_size, stride, padding,</pre><pre>output_padding)</pre><pre>self.batch_norm = batch_norm</pre><pre>self.bn = torch.nn.InstanceNorm2d(output_size)</pre><pre>self.activation = activation</pre><pre>self.relu = torch.nn.ReLU(<strong>True</strong>)</pre><pre><em>#Forward pass</em></pre><pre><strong>def</strong> forward(self,x):</pre><pre><strong>if</strong> self.batch_norm:</pre><pre>out = self.bn(self.deconv(x))</pre><pre><strong>else</strong>:</pre><pre>out = self.deconv(x)</pre><pre><strong>if</strong> self.activation == &#39;relu&#39;:</pre><pre><strong>return</strong> self.relu(out)</pre><pre><strong>elif</strong> self.activation == &#39;lrelu&#39;:</pre><pre><strong>return</strong> self.lrelu(out)</pre><pre><strong>elif</strong> self.activation == &#39;tanh&#39;:</pre><pre><strong>return</strong> self.tanh(out)</pre><pre><strong>elif</strong> self.activation == &#39;no_act&#39;:</pre><pre><strong>return</strong> out</pre><p><strong>The Resnet or Residual Learning Block / Network</strong></p><p>Resnet resources:</p><p><a href="https://en.wikipedia.org/wiki/Residual_neural_network">Residual neural network - Wikipedia</a></p><p><a href="https://towardsdatascience.com/an-overview-of-resnet-and-its-variants-5281e2f56035">https://towardsdatascience.com/an-overview-of-resnet-and-its-variants-5281e2f56035</a></p><pre><strong>class</strong> <strong>ResnetBlock</strong>(torch.nn.Module):<br>    <strong>def</strong> __init__(self,num_filter,kernel_size=3,stride=1,padding=0):<br>        super(ResnetBlock,self).__init__()<br><br>        conv1 = torch.nn.Conv2d(num_filter, num_filter, kernel_size,<br>                                stride, padding)<br>        <br>        conv2 = torch.nn.Conv2d(num_filter, num_filter, kernel_size,<br>                                stride, padding)<br>        <br>        bn = torch.nn.InstanceNorm2d(num_filter)<br>        relu = torch.nn.ReLU(<strong>True</strong>)<br>        pad = torch.nn.ReflectionPad2d(1)<br>        <br>        self.resnet_block = torch.nn.Sequential(<br>            pad,<br>            conv1,<br>            bn,<br>            relu,<br>            pad,<br>            conv2,<br>            bn<br>            )<br>    <strong>def</strong> forward(self,x):<br>        out = self.resnet_block(x)<br>        <strong>return</strong> out<strong>The Generator</strong></pre><p><strong>The Generator</strong></p><p>Now for the fun part, we now create the Generator which we will be using at the learning block at a later point.</p><pre><strong>class</strong> <strong>Generator</strong>(torch.nn.Module):</pre><pre><strong>def</strong> __init__(self,input_dim,num_filter,output_dim,num_resnet):</pre><pre>super(Generator,self).__init__()</pre><pre><em>#Reflection padding</em></pre><pre>self.pad = torch.nn.ReflectionPad2d(3)</pre><pre><em>#Encoder</em></pre><pre><em># Input Layer - NN Layer 1</em></pre><pre>self.conv1 = ConvBlock(input_dim, num_filter, kernel_size=7, stride=1,</pre><pre>padding=0)</pre><pre><em># NN Layer 2</em></pre><pre>self.conv2 = ConvBlock(num_filter, num_filter*2)</pre><pre><em>## NN Layer 3</em></pre><pre>self.conv3 = ConvBlock(num_filter*2, num_filter*4)</pre><pre><em>#Transformer</em></pre><pre>self.resnet_blocks = []</pre><pre><strong>for</strong> i <strong>in</strong> range(num_resnet):</pre><pre>self.resnet_blocks.append(ResnetBlock(num_filter*4))</pre><pre>self.resnet_blocks = torch.nn.Sequential(*self.resnet_blocks)</pre><pre><em>#Decoder</em></pre><pre>self.deconv1 = DeconvBlock(num_filter*4, num_filter*2)</pre><pre>self.deconv2 = DeconvBlock(num_filter*2, num_filter)</pre><pre>self.deconv3 = ConvBlock(num_filter, output_dim, kernel_size=7,</pre><pre>stride=1, padding=0, activation=&#39;tanh&#39;,</pre><pre>batch_norm=<strong>False</strong>)</pre><pre><em>#Forward Function</em></pre><pre><strong>def</strong> forward(self,x):</pre><pre><em>#Encoder</em></pre><pre>enc1 = self.conv1(self.pad(x))</pre><pre>enc2 = self.conv2(enc1)</pre><pre>enc3 = self.conv3(enc2)</pre><pre><em>#Transformer</em></pre><pre>res = self.resnet_blocks(enc3)</pre><pre><em>#Decoder</em></pre><pre>dec1 = self.deconv1(res)</pre><pre>dec2 = self.deconv2(dec1)</pre><pre>out = self.deconv3(self.pad(dec2))</pre><pre><strong>return</strong> out</pre><pre><em>#Creating weights inside the Generator</em></pre><pre><strong>def</strong> normal_weight_init(self,mean=0.0,std=0.02):</pre><pre><strong>for</strong> m <strong>in</strong> self.children():</pre><pre><strong>if</strong> isinstance(m,ConvBlock):</pre><pre>torch.nn.init.normal_(m.conv.weight,mean,std)</pre><pre><strong>if</strong> isinstance(m,DeconvBlock):</pre><pre>torch.nn.init.normal_(m.deconv.weight,mean,std)</pre><pre><strong>if</strong> isinstance(m,ResnetBlock):</pre><pre>torch.nn.init.normal_(m.conv.weight,mean,std)</pre><pre>torch.nn.init.constant_(m.conv.bias,0)</pre><p>Generator A</p><pre>Generator_A = Generator(3, parameters[&#39;ngf&#39;], 3,</pre><pre>parameters[&#39;num_resnet&#39;]).cuda()</pre><pre>Generator_A.normal_weight_init(mean=0.0, std=0.02)</pre><p>Generator B</p><pre>Generator_A = Generator(3, parameters[&#39;ngf&#39;], 3,</pre><pre>parameters[&#39;num_resnet&#39;]).cuda()</pre><pre>Generator_A.normal_weight_init(mean=0.0, std=0.02)</pre><p>Generator_B = Generator(3, parameters[‘ngf’], 3, parameters[‘num_resnet’]).cuda() Generator_B.normal_weight_init(mean=0.0, std=0.02) Generator_B</p><p><strong>Creating the Discriminator</strong></p><pre><strong>class</strong> <strong>Discriminator</strong>(torch.nn.Module):</pre><pre><strong>def</strong> __init__(self,input_dim,num_filter,output_dim):</pre><pre>super(Discriminator,self).__init__()</pre><pre><em>#Input - NN Layer 1</em></pre><pre>conv1 = ConvBlock(input_dim,num_filter,kernel_size=4,stride=2,padding=1,activation=&#39;lrelu&#39;,batch_norm=<strong>False</strong>)</pre><pre><em>#NN Layer 2</em></pre><pre>conv2 = ConvBlock(num_filter,num_filter*2,kernel_size=4,stride=2,padding=1,activation=&#39;lrelu&#39;)</pre><pre><em>#NN Layer 3</em></pre><pre>conv3 = ConvBlock(num_filter*2,num_filter*4,kernel_size=4,stride=2,padding=1,activation=&#39;lrelu&#39;)</pre><pre><em>#NN Layer 4</em></pre><pre>conv4 = ConvBlock(num_filter*4,num_filter*8,kernel_size=4,stride=1,padding=1,activation=&#39;lrelu&#39;)</pre><pre><em>#Output - NN Layer 5</em></pre><pre>conv5 = ConvBlock(num_filter*8,output_dim,kernel_size=4,stride=1,padding=1,activation=&#39;no_act&#39;,batch_norm=<strong>False</strong>)</pre><pre>self.conv_blocks = torch.nn.Sequential(</pre><pre>conv1,</pre><pre>conv2,</pre><pre>conv3,</pre><pre>conv4,</pre><pre>conv5</pre><pre>)</pre><pre><strong>def</strong> forward(self,x):</pre><pre>out = self.conv_blocks(x)</pre><pre><strong>return</strong> out</pre><pre><em>#Creating the weights for the Discriminator</em></pre><pre><strong>def</strong> normal_weight_init(self, mean=0.0, std=0.02):</pre><pre><strong>for</strong> m <strong>in</strong> self.children():</pre><pre><strong>if</strong> isinstance(m, ConvBlock):</pre><pre>torch.nn.init.normal_(m.conv.weight.data, mean, std)</pre><p><strong>Discriminator A</strong></p><pre>Discriminator_A = Discriminator(3, parameters[&#39;ndf&#39;], 1).cuda()</pre><pre>Discriminator_A.normal_weight_init(mean=0.0, std=0.02)</pre><p><strong>Discriminator B</strong></p><pre>Discriminator_B = Discriminator(3, parameters[&#39;ndf&#39;], 1).cuda()</pre><pre>Discriminator_B.normal_weight_init(mean=0.0, std=0.02)</pre><p><strong>Training Block / Dataloaders</strong></p><pre>train_data_A = DatasetFromFolder(basepath, subfolder=&#39;trainA_Male&#39;, transform=trans,</pre><pre>resize_scale=parameters[&#39;resize_size&#39;],</pre><pre><em>#crop_size=parameters[&#39;crop_size&#39;],</em></pre><pre><em>#fliplr=parameters[&#39;fliplr&#39;]</em></pre><pre>)</pre><pre>train_data_loader_A = torch.utils.data.DataLoader(dataset=train_data_A,</pre><pre>batch_size=parameters[&#39;batch_size&#39;],</pre><pre>num_workers=parameters[&#39;num_workers&#39;],</pre><pre>pin_memory=<strong>True</strong>,</pre><pre>shuffle=<strong>True</strong>)</pre><pre>train_data_B = DatasetFromFolder(basepath, subfolder=&#39;trainB_Female&#39;, transform=trans,</pre><pre>resize_scale=parameters[&#39;resize_size&#39;],</pre><pre><em>#crop_size=parameters[&#39;crop_size&#39;],</em></pre><pre><em>#fliplr=True</em></pre><pre>)</pre><pre>train_data_loader_B = torch.utils.data.DataLoader(dataset=train_data_B,</pre><pre>batch_size=parameters[&#39;batch_size&#39;],</pre><pre>num_workers=parameters[&#39;num_workers&#39;],</pre><pre>pin_memory=<strong>True</strong>,</pre><pre>shuffle=<strong>True</strong>)</pre><pre><em>#Load test data</em></pre><pre>test_data_A = DatasetFromFolder(basepath, subfolder=&#39;testA_Male&#39;, transform=trans)</pre><pre>test_data_loader_A = torch.utils.data.DataLoader(dataset=test_data_A,</pre><pre>batch_size=parameters[&#39;batch_size&#39;],</pre><pre>shuffle=<strong>False</strong>)</pre><pre>test_data_B = DatasetFromFolder(basepath, subfolder=&#39;trainB_Female&#39;, transform=trans)</pre><pre>test_data_loader_B = torch.utils.data.DataLoader(dataset=test_data_B,</pre><pre>batch_size=parameters[&#39;batch_size&#39;],</pre><pre>shuffle=<strong>False</strong>)</pre><p><strong>Test real data A and B</strong></p><p>test_real_A_data = train_data_A.__getitem__(11).unsqueeze(0)</p><pre>test_real_B_data = train_data_B.__getitem__(11).unsqueeze(0)</pre><p><strong>Creating the optimizer</strong></p><p>In our case, we will be using one of the more popular and simplest optimizers, the ADAM optimizer.</p><p>resource:</p><p><a href="https://machinelearningmastery.com/adam-optimization-algorithm-for-deep-learning/#:~:text=Adam%20is%20an%20optimization%20algorithm,iterative%20based%20in%20training%20data.&amp;text=The%20algorithm%20is%20called%20Adam,derived%20from%20adaptive%20moment%20estimation">https://machinelearningmastery.com/adam-optimization-algorithm-for-deep-learning/#:~:text=Adam%20is%20an%20optimization%20algorithm,iterative%20based%20in%20training%20data.&amp;text=The%20algorithm%20is%20called%20Adam,derived%20from%20adaptive%20moment%20estimation</a>.</p><pre>Generator_optimizer = torch.optim.Adam(itertools.chain(Generator_A.parameters(),</pre><pre>Generator_B.parameters()),</pre><pre>betas=(parameters[&#39;beta1&#39;], parameters[&#39;beta2&#39;]),</pre><pre>lr=parameters[&#39;lgG&#39;])</pre><pre>Discriminator_A_optimizer = torch.optim.Adam(itertools.chain(Discriminator_A.parameters(),</pre><pre>Discriminator_B.parameters()),</pre><pre>betas=(parameters[&#39;beta1&#39;], parameters[&#39;beta2&#39;]),</pre><pre>lr=parameters[&#39;lgD&#39;])</pre><pre>Discriminator_B_optimizer = torch.optim.Adam(itertools.chain(Discriminator_A.parameters(),</pre><pre>Discriminator_B.parameters()),</pre><pre>betas=(parameters[&#39;beta1&#39;], parameters[&#39;beta2&#39;]),</pre><pre>lr=parameters[&#39;lgD&#39;])</pre><p><strong>Defining the losses</strong></p><pre>MSE_Loss = torch.nn.MSELoss().cuda()</pre><pre>L1_Loss = torch.nn.L1Loss().cuda()</pre><p><strong>Training the Model and retrieving Images</strong></p><pre>Discriminator_A_avg_losses = []</pre><pre>Discriminator_B_avg_losses = []</pre><pre>Generator_A_avg_losses = []</pre><pre>Generator_B_avg_losses = []</pre><pre>cycle_A_avg_losses = []</pre><pre>cycle_B_avg_losses = []</pre><pre><strong>for</strong> epoch <strong>in</strong> range(parameters[&#39;num_epochs&#39;]):</pre><pre>Discriminator_A_losses = []</pre><pre>Discriminator_B_losses = []</pre><pre>Generator_A_losses = []</pre><pre>Generator_B_losses = []</pre><pre>cycle_A_losses = []</pre><pre>cycle_B_losses = []</pre><pre><em># Learing rate decay</em></pre><pre><strong>if</strong>(epoch + 1) &gt; parameters[&#39;decay_epoch&#39;]:</pre><pre>Discriminatoroptimizer.param_groups[0][&#39;lr&#39;] -= parameters[&#39;lgD&#39;] / (parameters[&#39;num_epochs&#39;] - parameters[&#39;decay_epoch&#39;])</pre><pre>Discriminator_B_optimizer.param_groups[0][&#39;lr&#39;] -= parameters[&#39;lgD&#39;] / (parameters[&#39;num_epochs&#39;] - parameters[&#39;decay_epoch&#39;])</pre><pre>G_optimizer.param_groups[0][&#39;lr&#39;] -= parameters[&#39;lrG&#39;] / (parameters[&#39;num_epochs&#39;] - parameters[&#39;decay_epoch&#39;])</pre><pre><em># training</em></pre><pre><strong>for</strong> i, (real_A, real_B) <strong>in</strong> tqdm(enumerate(zip(train_data_loader_A, train_data_loader_B)), total=len(train_data_loader_A)):</pre><pre><em># input image data</em></pre><pre>real_A = real_A.to(device)</pre><pre>real_B = real_B.to(device)</pre><pre><em># Train The Generator</em></pre><pre><em># A --&gt; B</em></pre><pre>fake_B = Generator_A(real_A)</pre><pre>Discriminator_B_fake_decision = Discriminator_B(fake_B)</pre><pre>Generator_A_loss = MSE_Loss(Discriminator_B_fake_decision, Variable(torch.ones(Discriminator_B_fake_decision.size()).cuda()))</pre><pre><em># Forward Cycle Loss</em></pre><pre>recon_A = Generator_B(fake_B)</pre><pre>cycle_A_loss = L1_Loss(recon_A, real_A) * parameters[&#39;lambdaA&#39;]</pre><pre><em># B --&gt; A</em></pre><pre>fake_A = Generator_B(real_B)</pre><pre>Discriminator_A_fake_decision = Discriminator_A(fake_A)</pre><pre>Generator_B_loss = MSE_Loss(Discriminator_A_fake_decision, Variable(torch.ones(Discriminator_A_fake_decision.size()).cuda()))</pre><pre><em># Backward Cycle Loss</em></pre><pre>recon_B = Generator_A(fake_A)</pre><pre>cycle_B_loss = L1_Loss(recon_B, real_B) * parameters[&#39;lambdaB&#39;]</pre><pre><em># Back Propagation</em></pre><pre>Generator_loss = Generator_A_loss + Generator_B_loss + cycle_A_loss + cycle_B_loss</pre><pre>Generator_optimizer.zero_grad()</pre><pre>Generator_loss.backward()</pre><pre>Generator_optimizer.step()</pre><pre><em># Train Discriminator_A</em></pre><pre>Discriminator_A_real_decision = Discriminator_A(real_A)</pre><pre>Discriminator_A_real_loss = MSE_Loss(Discriminator_A_real_decision, Variable(torch.ones(Discriminator_A_real_decision.size()).cuda()))</pre><pre>fake_A = fake_A_Pool.query(fake_A)</pre><pre>Discriminator_A_fake_decision = Discriminator_A(fake_A)</pre><pre>Discriminator_A_fake_loss = MSE_Loss(Discriminator_A_fake_decision, Variable(torch.zeros(Discriminator_A_fake_decision.size()).cuda()))</pre><pre><em># Back propagation</em></pre><pre>Discriminator_A_loss = (Discriminator_A_real_loss + Discriminator_A_fake_loss) * 0.5</pre><pre>Discriminator_A_optimizer.zero_grad()</pre><pre>Discriminator_A_loss.backward()</pre><pre>Discriminator_A_optimizer.step()</pre><pre><em># Train Discriminator_B</em></pre><pre>Discriminator_B_real_decision = Discriminator_B(real_B)</pre><pre><em># print(&#39;real_A, &#39;,real_A.shape)</em></pre><pre><em># print(&#39;real_B, &#39;,real_B.shape)</em></pre><pre><em># print(&#39;dis_A, &#39;,Discriminator_A_real_decision.shape)</em></pre><pre><em># print(&#39;dis_B, &#39;,Discriminator_B_real_decision.shape)</em></pre><pre>Discriminator_B_real_loss = MSE_Loss(Discriminator_B_real_decision, Variable(torch.ones(Discriminator_B_fake_decision.size()).cuda()))</pre><pre><em>#Discriminator_B_real_loss = MSE_Loss(Discriminator_B_real_decision, Variable(torch.ones(Discriminator_B_real_decision.size()).cuda()))</em></pre><pre>fake_B = fake_B_Pool.query(fake_B)</pre><pre>Discriminator_B_fake_decision = Discriminator_B(fake_B)</pre><pre>Discriminator_B_fake_loss = MSE_Loss(Discriminator_B_fake_decision, Variable(torch.zeros(Discriminator_B_fake_decision.size()).cuda()))</pre><pre><em># Back Propagation</em></pre><pre>Discriminator_B_loss = (Discriminator_B_real_loss + Discriminator_B_fake_loss) * 0.5</pre><pre>Discriminator_B_optimizer.zero_grad()</pre><pre>Discriminator_B_loss.backward()</pre><pre>Discriminator_B_optimizer.step()</pre><pre><em>#  Print</em></pre><pre><em># loss values</em></pre><pre>Discriminator_A_losses.append(Discriminator_A_loss.item())</pre><pre>Discriminator_B_losses.append(Discriminator_B_loss.item())</pre><pre>Generator_A_losses.append(Generator_A_loss.item())</pre><pre>Generator_B_losses.append(Generator_B_loss.item())</pre><pre>cycle_A_losses.append(cycle_A_loss.item())</pre><pre>cycle_B_losses.append(cycle_B_loss.item())</pre><pre><strong>if</strong> i%100 == 0:</pre><pre>print(&#39;Epoch [<strong>%d</strong>/<strong>%d</strong>], Step [<strong>%d</strong>/<strong>%d</strong>], Discriminator_A_losses: <strong>%.4f</strong>, Discriminator_B_loss: <strong>%.4f</strong>, Generator_A_loss: <strong>%.4f</strong>, Generator_B_loss: <strong>%.4f</strong>&#39;</pre><pre>% (epoch+1, parameters[&#39;num_epochs&#39;], i+1, len(train_data_loader_A), Discriminator_A_loss.item(), Discriminator_B_loss.item(), Generator_A_loss.item(), Generator_B_loss.item()))</pre><pre>step += 1</pre><pre>Discriminator_A_avg_loss = torch.mean(torch.FloatTensor(Discriminator_A_losses))</pre><pre>Discriminator_B_avg_loss = torch.mean(torch.FloatTensor(Discriminator_B_losses))</pre><pre>Generator_A_avg_loss = torch.mean(torch.FloatTensor(Generator_A_losses))</pre><pre>Generator_B_avg_loss = torch.mean(torch.FloatTensor(Generator_B_losses))</pre><pre>cycle_A_avg_loss = torch.mean(torch.FloatTensor(cycle_A_losses))</pre><pre>cycle_B_avg_loss = torch.mean(torch.FloatTensor(cycle_B_losses))</pre><pre><em># Average Loss Values</em></pre><pre>Discriminator_A_avg_losses.append(Discriminator_A_avg_loss.item())</pre><pre>Discriminator_B_avg_losses.append(Discriminator_B_avg_loss.item())</pre><pre>Generator_A_avg_losses.append(Generator_A_avg_loss.item())</pre><pre>Generator_B_avg_losses.append(Generator_B_avg_loss.item())</pre><pre>cycle_A_avg_losses.append(cycle_A_avg_loss.item())</pre><pre>cycle_B_avg_losses.append(cycle_B_avg_loss.item())</pre><pre><em># Test Image Results</em></pre><pre>test_real_A = test_real_A_data.cuda()</pre><pre>test_fake_B = Generator_A(test_real_A)</pre><pre>test_recon_A = Generator_B(test_fake_B)</pre><pre>test_real_B = test_real_B_data.cuda()</pre><pre>test_fake_A = Generator_B(test_real_B)</pre><pre>test_recon_B = Generator_A(test_fake_A)</pre><pre>plot_train_result([test_real_A, test_real_B], [test_fake_B, test_fake_A], [test_recon_A, test_recon_B],</pre><pre>epoch, save=<strong>True</strong>)</pre><p><strong>Results at different epochs</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*8L7AJcNuy1_M8NE1rKzaAw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*srVJfnqqnQdZMatYj62S5g.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*faYfm5-R8cCd1Or7wwSNyA.jpeg" /></figure><p><strong>Retrieving Losses</strong></p><pre>all_losses = pd.DataFrame()</pre><pre>all_losses[&#39;Discriminator_A_avg_losses&#39;] = Discriminator_A_avg_losses</pre><pre>all_losses[&#39;Discriminator_B_avg_losses&#39;] = Discriminator_B_avg_losses</pre><pre>all_losses[&#39;Generator_A_avg_losses&#39;] = Generator_A_avg_losses</pre><pre>all_losses[&#39;Generator_B_avg_losses&#39;] = Generator_B_avg_losses</pre><pre>all_losses[&#39;cycle_A_avg_losses&#39;] = cycle_A_avg_losses</pre><pre>all_losses[&#39;cycle_B_avg_losses&#39;] = cycle_B_avg_losses</pre><p><strong>Plotting the Losses</strong></p><pre>plt.figure(figsize=(20,20))</pre><pre>losses.plot()</pre><pre>plt.legend(bbox_to_anchor=(1, 1), loc=&#39;upper left&#39;, ncol=1)</pre><pre>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*RXafhr4TfF_O84qZlAQMrw.jpeg" /></figure><p><strong>Conclusion:</strong></p><p>Though not perfect we can see that the model is working by looking visually at the changes in the images. Additionally, we can also see the decrease in loss as we increase the epochs. With additional resources we can also try to make changes to the epochs and to the learning rate to see what values works well in improving the results.</p><p>It is my hope that I was able to assist in the creation in one of the many GANs you intend to create.</p><p>References:</p><p><a href="https://github.com/ltq477/CycleGAN/blob/master/CycleGAN%20-%20Facial%20Gans%20ver_IV.ipynb">https://github.com/ltq477/CycleGAN/blob/master/CycleGAN%20-%20Facial%20Gans%20ver_IV.ipynb</a></p><p><a href="https://pytorch.org/tutorials/beginner/dcgan_faces_tutorial.html">https://pytorch.org/tutorials/beginner/dcgan_faces_tutorial.html</a></p><p>Pytorch Tutorial:</p><p><a href="https://pytorch.org/tutorials/beginner/dcgan_faces_tutorial.html">https://pytorch.org/tutorials/beginner/dcgan_faces_tutorial.html</a></p><p>Example of Implementation from Tutorial:</p><p><a href="https://www.kaggle.com/pipiking/cyclegan-pytorch">https://www.kaggle.com/pipiking/cyclegan-pytorch</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85546dfe6317" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>