<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Siddhant Dubey</title>
    <description>The latest articles on Forem by Siddhant Dubey (@siddhantdubey).</description>
    <link>https://forem.com/siddhantdubey</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F192696%2F66eea995-9790-41d6-842f-7bf0dbc3d2fa.jpeg</url>
      <title>Forem: Siddhant Dubey</title>
      <link>https://forem.com/siddhantdubey</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/siddhantdubey"/>
    <language>en</language>
    <item>
      <title>I got GPT-3 To Make an Anime That Doesn't Exist!</title>
      <dc:creator>Siddhant Dubey</dc:creator>
      <pubDate>Mon, 05 Jul 2021 15:55:44 +0000</pubDate>
      <link>https://forem.com/siddhantdubey/i-got-gpt-3-to-make-an-anime-that-doesn-t-exist-5hbc</link>
      <guid>https://forem.com/siddhantdubey/i-got-gpt-3-to-make-an-anime-that-doesn-t-exist-5hbc</guid>
      <description>&lt;p&gt;&lt;a href="https://youtu.be/ssr51BidQOs"&gt;https://youtu.be/ssr51BidQOs&lt;/a&gt;&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>python</category>
      <category>programming</category>
      <category>vscode</category>
    </item>
    <item>
      <title>An Introduction to Time Complexity and Big O Notation</title>
      <dc:creator>Siddhant Dubey</dc:creator>
      <pubDate>Fri, 19 Mar 2021 15:13:35 +0000</pubDate>
      <link>https://forem.com/siddhantdubey/an-introduction-to-time-complexity-and-big-o-notation-12dj</link>
      <guid>https://forem.com/siddhantdubey/an-introduction-to-time-complexity-and-big-o-notation-12dj</guid>
      <description>&lt;p&gt;If you're interested in learning the basics of Time Complexity and Big-O Notation which are the fundamental aspects of algorithmic analysis, something that is really important for theoretical computer science check out this YouTube video I made. Additionally, knowing how to analyze the running time of algorithms helps you write efficient code.&lt;/p&gt;

&lt;p&gt;This video contains animated high-quality explanations of Time Complexity concepts along with multiple examples. &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/-sx1fh_alAY"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>programming</category>
      <category>algorithms</category>
      <category>tutorial</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>An Introduction to Cybersecurity, Capture the Flag Contests, and Basic Security Concepts</title>
      <dc:creator>Siddhant Dubey</dc:creator>
      <pubDate>Thu, 24 Dec 2020 20:32:12 +0000</pubDate>
      <link>https://forem.com/siddhantdubey/an-introduction-to-cybersecurity-capture-the-flag-contests-and-basic-security-concepts-5ga2</link>
      <guid>https://forem.com/siddhantdubey/an-introduction-to-cybersecurity-capture-the-flag-contests-and-basic-security-concepts-5ga2</guid>
      <description>&lt;p&gt;Cybersecurity is important, there’s no dodging that fact. It is also nothing like the hacking that is shown in most popular media.&lt;/p&gt;

&lt;p&gt;However, that does not mean it isn’t interesting, it is undoubtedly so. Due to this intrigue, lots of people want to dip their feet into cybersecurity, myself included, and I have found &lt;em&gt;capture the flag events&lt;/em&gt; (CTFs) to be a wonderful way to get a taste of the field.&lt;/p&gt;

&lt;p&gt;Now, by no means are CTFs completely accurate in the day-to-day work of a cybersecurity professional but they are very educational and they do help people develop their cybersecurity skillsets, as well as just being fun to participate in.&lt;/p&gt;

&lt;p&gt;In addition, if you are a programmer, these will give you an insight into the way you should design your programs so that they are not vulnerable to malevolent users. You don’t want to be the person that stored all their passwords in plain text.&lt;/p&gt;

&lt;p&gt;If you gain value from this post consider following me on &lt;a href="https://twitter.com/sidcodes"&gt;Twitter&lt;/a&gt; and &lt;a href="https://www.siddcodes.com/"&gt;subscribing to my email newsletter&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is a CTF?
&lt;/h2&gt;

&lt;p&gt;At this point, you may be asking yourself: “Cool, but what is a CTF?”&lt;/p&gt;

&lt;p&gt;Essentially, it is a team cybersecurity competition of which there are three main types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Jeopardy:** **These have a collection of tasks in several distinct categories: web exploits, binary exploitation, reverse engineering, forensics, and cryptography. By solving these challenges, you find “flags” which typically follow a standard format like flag{Th1s_1s_a_flag}. Some examples include &lt;a href="https://picoctf.com/"&gt;picoCTF&lt;/a&gt; and &lt;a href="https://www.defcon.org/html/links/dc-ctf.html"&gt;Defcon CTF&lt;/a&gt;’s qualification round.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Attack-Defense: In attack-defense competitions, each team is given their own host or service and is tasked with protecting that host from other teams while also trying to exploit other teams’ hosts. Famously, the Defcon CTF final takes this format.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mixed:** **As can be inferred by the name of this type of competition, it is some sort of combination of jeopardy and attack-defense competitions.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this article, I will be mainly focusing on the jeopardy-type CTF. In the future, I may write another article on attack-defense competitions.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are All Those Categories?
&lt;/h2&gt;

&lt;p&gt;Before you get into all of the cool categories in jeopardy contests that I mentioned earlier, you need to learn the basics. Most importantly, you need to familiarize yourself with the Linux terminal.&lt;/p&gt;

&lt;p&gt;Here are a couple of commands that you will use over, and over, and over again:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls: This command lists out all the files and subdirectories that you are currently in.

pwd: This prints your current working directory. If you are in the documents directory, this will return documents.

cd: This command changes the directory into any of the subdirectories of the current directory. Eg: If you have an essays folder in your documents folder and your current directory is documents, cd essays, will take you to your essays folder.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;These are the absolute basics for the Linux terminal and there are a lot more commands that we will cover in the rest of this article.&lt;/p&gt;

&lt;p&gt;To succeed in CTFs, it is also important to know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A scripting language, most popular of which is &lt;a href="https://www.python.org/"&gt;Python&lt;/a&gt;. There are a lot of cool libraries for cybersecurity in Python, including &lt;a href="http://docs.pwntools.com/en/stable/"&gt;pwn&lt;/a&gt; which has a lot of functions that are helpful for CTFs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Number bases. Having an understanding of how this works is very helpful.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JavaScript: Doing good work in web exploitation needs knowledge of JavaScript as well as some SQL for SQL injections.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is also advisable to have a UNIX-based operating system because of all the amazing tools that are readily available on Linux, this can be done in a virtual box, no changing your main OS necessary. However, you can still participate in CTFs on Windows.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Time to start digging into some heavier stuff.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cryptography
&lt;/h2&gt;

&lt;p&gt;Cryptography challenges consist of exactly what you think they would, codebreaking. Given a ciphertext, can you decode it into the original message? Can you do the opposite?&lt;/p&gt;

&lt;p&gt;These types of problems include an encrypted message that you have to decrypt. To prepare for these, it is best to learn different types of ciphers and how to decrypt them.&lt;/p&gt;

&lt;p&gt;Here are some common methods of encryption in these challenges: Caesar Ciphers, Vigenère Ciphers, and RSA. For more info on how to decrypt these, &lt;a href="https://ctf101.org/cryptography/overview/"&gt;check out this link.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Steganography
&lt;/h2&gt;

&lt;p&gt;Steganography is not cryptography by definition but it does involve hiding messages in plain sight. As a result, many CTF organizers will include steganography challenges in the cryptography section.&lt;/p&gt;

&lt;p&gt;Steganography consists of hiding messages in media files, typically audio and images. It is important to note that there aren’t a lot of real applications in the field of cybersecurity with steganography, other than just increasing your knowledge.&lt;/p&gt;

&lt;p&gt;There is a multitude of ways to do this and not enough space in this general-purpose article to cover them all, so here is an in-depth article about steganography:&lt;br&gt;
&lt;a href="https://medium.com/@FourOctets/ctf-tidbits-part-1-steganography-ea76cc526b40"&gt;&lt;strong&gt;CTF Tidbits: Part 1 — Steganography&lt;/strong&gt;&lt;br&gt;
*I have been asked by a few folks what tools I use for CTF’s. What I use all depends on what the CTF is. There are all…*medium.com&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Binary Exploitation
&lt;/h2&gt;

&lt;p&gt;Binary exploitation involves finding vulnerabilities in a program, typically Linux executables, and then exploiting these vulnerabilities to obtain the flag.&lt;/p&gt;

&lt;p&gt;These exploitations usually involve either using the program to gain control of a shell or just modifying the program to yield the flag. This is an extremely broad field and &lt;a href="https://ctf101.org/binary-exploitation/overview/"&gt;some helpful tips can be found here.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Forensics
&lt;/h2&gt;

&lt;p&gt;Forensics challenges in CTFs typically have the following aspects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;File format analysis: Given various files that have something wrong with them, can you fix them? Can you fix a corrupt file to produce a flag?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Memory dump analysis: Taking a look at the memory of the system and seeing if any important information can be learned.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Steganography: Yes, steganography appears in the forensics section as well.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Packet capture analysis: A packet is a segment of data sent from one device to another device over a network. A lot of information can be gleaned from packets and there are a lot of programs for packet analysis and capture out there. Possibly the most popular is &lt;a href="https://www.wireshark.org/"&gt;Wireshark&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is something that goes into a &lt;a href="https://trailofbits.github.io/ctf/forensics/"&gt;lot of detail on this topic&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Web Exploitation
&lt;/h2&gt;

&lt;p&gt;Web exploitation challenges have the contestant retrieve the flag from exploiting websites and web apps. There are a couple of ways to do this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;SQL injections: Sometimes, the creator of a web app unintentionally makes it so that SQL code can be inputted. This provides a golden opportunity for the exploiter to use SQL to obtain information from the databases of the web app.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Just inspecting element: In the easier stages of contests, event organizers may just hide flags in the HTML of the website. They may also have a JavaScript function that needs to take in a certain input to spit out the flag, these can be done with inspect element and some problem-solving skills.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Directory traversal: If an application takes in a directory as input and this input is not properly checked, the attacker can mess with the directories to their heart’s desire.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;XSS (cross-site scripting): This is when the attacker can send JavaScript that will be executed by the browser of another user of the web app.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Command injection: Sometimes, developers forget to properly check for input that goes into a system’s shell. If not properly checked, the attacker can send whatever system commands they want to the web app.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For more in-depth information on the above topics, take a look at this &lt;a href="https://ctf101.org/web-exploitation/overview/"&gt;wonderful resource.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Reverse Engineering
&lt;/h2&gt;

&lt;p&gt;As the name suggests, these types of challenges are based around reverse-engineering a program to figure out how to properly exploit it. The product of a successful exploit is the flag, as desired.&lt;/p&gt;

&lt;p&gt;These could be given in many programming languages but the following, especially the first two, tend to show up more than others:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Assembly: Reading this, you may be thinking that nobody codes in Assembly, on the contrary, quite a lot of people do. It is not extremely widespread but it used in the programming of embedded microsystems which are very relevant. This may be a bummer to learn but it is a fairly useful skill to know.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;C: Lots of programs are written in C and its control over memory allocation makes it a valuable programming language. Familiarity with C may help you do well in reverse engineering programs written in C.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Java: Java is a very popular programming language and has easily-readable code. Knowing Java will help you reverse engineer it tremendously so learning it if you don’t already know it is recommended.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is to be noted that there are a lot of times where you are not given the actual source code of the program and are just given the executable.&lt;/p&gt;

&lt;p&gt;To overcome this hurdle, we use *decompilers. *These programs try to convert the executable back into source code.&lt;/p&gt;

&lt;p&gt;A great example of a decompiler is &lt;a href="https://www.nsa.gov/resources/everyone/ghidra/"&gt;Ghidra&lt;/a&gt; which was created by the NSA. It is a very powerful tool and very good at it what it does. It would be advisable to have set this up on your computer.&lt;/p&gt;

&lt;p&gt;For a more in-depth explanation of reverse engineering, take a look at this &lt;a href="https://ctf101.org/reverse-engineering/overview/"&gt;wonderful resource&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Beginner-Friendly CTFs
&lt;/h2&gt;

&lt;p&gt;Alright, these CTF things seem cool, how do I participate in one?&lt;/p&gt;

&lt;p&gt;Well, future pwner, here’s a list of CTFs that are great for beginners. Note, not all of them are available right now:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://picoctf.com/"&gt;picoCTF: Run by Carnegie Mellon University, this is geared towards middle and high school students and is available year-round.&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://overthewire.org/wargames/"&gt;overthewire: This is great for beginners to learn and test their skills. Starting with the bandit challenge will help you build from zero.&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://hsctf.com/"&gt;HSCTF: Another CTF made for high school students.&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://ctftime.org/event/list/upcoming"&gt;CTFtime: You can find a lot more CTFs here to practice and learn.&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, get out there and capture those flags. Trust me, it is an incredible experience.&lt;/p&gt;

&lt;p&gt;If you gained value from this post consider following me on &lt;a href="https://twitter.com/sidcodes"&gt;Twitter&lt;/a&gt; and &lt;a href="https://www.siddcodes.com/"&gt;subscribing to my email newsletter&lt;/a&gt;. Every Sunday, I send out a newsletter that contains the best programming and learning-related content I’ve seen in the past week along with my own thoughts on the events of the week. The main goal of the newsletter is to bring meaningful and thought-provoking ideas to your inbox every Sunday. Consider signing up if you’re interested.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Giant List of Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://trailofbits.github.io/ctf/web/exploits.html"&gt;Trail of bits&lt;/a&gt;: Lots of good information on CTFs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://ctfs.github.io/resources/"&gt;CTFS Resources: Information on cryptography and forensics.&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://ctf101.org/"&gt;CTF 101: A complete beginner’s guide to all things CTF.&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>cybersecurity</category>
      <category>tutorial</category>
      <category>computerscience</category>
      <category>security</category>
    </item>
    <item>
      <title>An Introduction to Competitive Programming</title>
      <dc:creator>Siddhant Dubey</dc:creator>
      <pubDate>Thu, 24 Dec 2020 20:27:12 +0000</pubDate>
      <link>https://forem.com/siddhantdubey/an-introduction-to-competitive-programming-2ha0</link>
      <guid>https://forem.com/siddhantdubey/an-introduction-to-competitive-programming-2ha0</guid>
      <description>&lt;h3&gt;
  
  
  What is Competitive Programming?
&lt;/h3&gt;

&lt;p&gt;Competitive Programming is an art form. It is creative problem solving at its finest, a combination of hard analytical thinking and creativity. Competitive programmers use their knowledge of algorithms and data structures and logical reasoning skills to solve challenging algorithmic problems in a limited time frame. Java and C++ are extremely popular due to their relative run-time efficiency compared to a language like Python. C++ is my preferred competitive programming language as I love its Standard Template Library (STL) which allows for quick write ups of solutions. Without further ado, lets get right into it. &lt;/p&gt;

&lt;p&gt;If you happen to gain value from this post consider following me on &lt;a href="https://twitter.com/sidcodes"&gt;Twitter&lt;/a&gt; and &lt;a href="https://www.siddcodes.com/"&gt;subscribing to my email newsletter&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Get Started
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Learn C++
&lt;/h4&gt;

&lt;p&gt;I know most people might not want to hear this, but as I mentioned already, Python will be hard to succeed with in competitions.  C++ as a language for Competitive Programming is fairly easy to pick up, but like any languages understanding the nuances takes a little bit more time. Here are a couple of resources I found helpful:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/bqi343/USACO"&gt;Ben Qi's Github Repository&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cses.fi/book/book.pdf"&gt;Book With Problem Set&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.csc.kth.se/~jsannemo/slask/main.pdf"&gt;Principles of Algorithmic Solving&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Learn Algorithm Analysis
&lt;/h4&gt;

&lt;p&gt;Algorithm Analysis a    llows you to look at the solution you came up with and see whether or not it will run in time for a contest or if it will exceed the time limit imposed by the online judge.  Time Complexity analysis as the name suggests, quantifies the amount of time that an algorithm takes to run, it is where the famous O(n) notation comes from. This is called big O notation and yields the worst-case scenario run-time, that is the longest it would take for the algorithm to run. O(n) then means that if there are n elements to perform an operation on, the algorithm would run in time proportional to the n elements. Similarly O(n^2) is proportional to n^2 and O(log n) is proportional to log(n). There are other types of Time Complexity Analysis that are also handy. Here's a resource to read up on Algorithm Analysis:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.geeksforgeeks.org/analysis-algorithms-big-o-analysis/"&gt;Big O Analysis&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Learn how to Brute Force Problems
&lt;/h4&gt;

&lt;p&gt;At the start of one's competitive programming journey you more often than not encounter problems that can be brute forced with simple algorithms and do not require optimization to solve. In this case, you can usually just code out the solution step by step rather than applying specific algorithms. To get good at brute forcing problems, all you really have to do is practice. I would advise practicing rating 1000 problems on codeforces.com. Codeforces is a wonderful site to practice your competitive programming skills on. &lt;/p&gt;

&lt;h4&gt;
  
  
  Learn Greedy Algorithms
&lt;/h4&gt;

&lt;p&gt;Greedy algorithms make the locally optimal choice at each stage of the algorithm in the hope of finding the global optimum. These are usually more efficient than Brute Force solutions as long as you can come up with a greedy solution. They are not suited to every type of problem and may end up being inefficient if you apply them in places they shouldn't be used. Here is some great information on Greedy Algorithms: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://brilliant.org/wiki/greedy-algorithm/"&gt;Brilliant's Greedy Algorithms Page&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Learn Dynamic Programming
&lt;/h4&gt;

&lt;p&gt;Dynamic Programming is an optimization on normal recursion. Essentially it involves solving subproblems, saving those solutions, so that you don't have to resolve them later on as you would with normal recursion. This greatly reduces time complexity and is helpful on recursive type problems. Again the best way to get good at this is to solve multiple dynamic programming problems. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://atcoder.jp/contests/dp"&gt;Educational DP Contest&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.geeksforgeeks.org/dynamic-programming/"&gt;Geeks for Geeks DP&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Learn Graph Algorithms
&lt;/h4&gt;

&lt;p&gt;Once you move to the upper echelons of programming competitions you will find a multitude of Graph Algorithm problems. These will include things like finding the shortest path in between two nodes on a graph. In order to succeed at these types of problems, there are quite a few algorithms you need to master. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.geeksforgeeks.org/depth-first-search-or-dfs-for-a-graph/"&gt;Depth First Search (DFS)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.geeksforgeeks.org/breadth-first-search-or-bfs-for-a-graph/"&gt;Breadth First Search (BFS)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.geeksforgeeks.org/dijkstras-shortest-path-algorithm-greedy-algo-7/"&gt;Dijkstra's Algorithm (Used to find shortest path)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.geeksforgeeks.org/bellman-ford-algorithm-dp-23/"&gt;Bellman-Ford (Used to find shortest path)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.geeksforgeeks.org/floyd-warshall-algorithm-dp-16/"&gt;Floyd-Warshall (Used to find shortest path)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.geeksforgeeks.org/kruskals-minimum-spanning-tree-algorithm-greedy-algo-2/"&gt;Kruskal's Algorithm (Used to find minimum spanning tree)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.geeksforgeeks.org/prims-minimum-spanning-tree-mst-greedy-algo-5/"&gt;Prim's Algorithm (Used to find minimum spanning tree)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Mastering DFS and BFS first will yield great results as you progress in the world of competitive programming. Now that you know what algorithms and techniques you need to learn, you are ready to find out what competitions you can use to practice your skills.&lt;/p&gt;

&lt;h3&gt;
  
  
  Major Competitions / Online Judges
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;a href="http://www.usaco.org/"&gt;United States of America Computing Olympiad(USACO)&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;The USACO is a competitive programming contest held every year in January, February, March, and December. It is divided up into four divisions, Bronze, Silver, Gold, and Platinum. Each division gets progressively harder, Platinum being the hardest. They also have a &lt;a href="https://train.usaco.org/usacogate"&gt;training page&lt;/a&gt; which is a great place to practice and learn Competitive Programming. &lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;a href="//codeforces.com"&gt;Codeforces&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;Codeforces is a platform on which a lot of programming contests are held. The problems are usually of a very high quality and they have a large database of past problems covering a wide variety of topics you can use to practice your skills. Codeforces works on a rating system and if you are just starting out I would recommend solving 1000-1200 rating problems. &lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;a href="https://atcoder.jp/"&gt;Atcoder&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;Atcoder is a wonderful programming contest especially for beginners. They host beginner contests often and they are a great way for newcomers to get into the world of competitive programming and learn how to succeed. Like Codeforces, Atcoder has a large collection of problems for you to work on and improve your skills with.&lt;/p&gt;

&lt;h3&gt;
  
  
  Benefits
&lt;/h3&gt;

&lt;p&gt;Ok cool, but I'm never going to have to implement Dijkstra's algorithm on the job right? I'll just use a built in function or use a library. While these are valid points, the objective of Competitive programming is not to have you implement all these fancy algorithms and data structures from scratch. Rather, it is to develop problem solving skills. Solving a lot of Competitive Programming questions helps you improve your problem solving skills. This is why many companies have you solve Competitive Programming like questions during an interview, not to see whether or not you can implement Dijkstra's algorithm on the job, but to see if you can problem solve on the fly and take things in your stride.&lt;/p&gt;

&lt;p&gt;If you gained value from this post consider following me on &lt;a href="https://twitter.com/sidcodes"&gt;Twitter&lt;/a&gt; and &lt;a href="https://www.siddcodes.com/"&gt;subscribing to my email newsletter&lt;/a&gt;. Every Sunday, I send out a newsletter that contains the best programming and learning-related content I’ve seen in the past week along with my own thoughts on the events of the week. The main goal of the newsletter is to bring meaningful and thought-provoking ideas to your inbox every Sunday. Consider signing up if you’re interested.&lt;/p&gt;

&lt;p&gt;Now get out there and start programming!&lt;/p&gt;

</description>
      <category>technology</category>
      <category>programming</category>
      <category>interview</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Identifying the Gender of a Movie Character with Deep Learning</title>
      <dc:creator>Siddhant Dubey</dc:creator>
      <pubDate>Thu, 24 Dec 2020 20:20:50 +0000</pubDate>
      <link>https://forem.com/siddhantdubey/identifying-the-gender-of-a-movie-character-with-deep-learning-n91</link>
      <guid>https://forem.com/siddhantdubey/identifying-the-gender-of-a-movie-character-with-deep-learning-n91</guid>
      <description>&lt;p&gt;If you were given a single line from a movie, would you be able to identify the gender of the character who delivered the line? Unless you've memorized a lot of movie scripts, probably not. Lucky for you, you don't have to do this as long as we have computers! The field of Natural Language Processing (NLP) has us covered. By applying Deep Learning to NLP and creating a text classifier we can train a computer to identify whether a line from a movie was delivered by a male or female character! &lt;/p&gt;

&lt;p&gt;If you happen to gain value from this post consider following me on &lt;a href="https://twitter.com/sidcodes"&gt;Twitter&lt;/a&gt; and &lt;a href="https://www.siddcodes.com/"&gt;subscribing to my email newsletter&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up Your Environment
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Colab
&lt;/h3&gt;

&lt;p&gt;Deep learning usually requires a large amount of computing power and a solid GPU, Deep Learning NLP is no exception. This used to be a barrier to entry in the field, but thanks to Google Colaboratory, it no longer is. Google Colab is a platform that allows you to train models on GPUs that are in the cloud with Jupyter Notebooks completely for free! You'll be following along with this tutorial on Colab. &lt;/p&gt;

&lt;p&gt;To get started with Google Colab, all you need to do is go to &lt;a href="https://colab.research.google.com/"&gt;https://colab.research.google.com/&lt;/a&gt; and sign in with your google account. Once you've done that, you can make Jupyter Notebooks and use them like you normally would. Usually, you'll want to read from and write to your google drive so that you can actually use data and save your results. In order to do this, add the following block of code as the first cell in every Colab Notebook you create.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from google.colab import drive
drive.mount('/content/gdrive', force_remount=True)
root_dir = "/content/gdrive/My Drive/pathtofolderwithfileshere"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you have a great environment to train your models in!&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing Libraries
&lt;/h3&gt;

&lt;p&gt;One of the best things about Colab is that it comes with all the big data science libraries like PyTorch, Tensorflow, Numpy, Matplotlib, and Scikit-Learn out of the box! In fact, it also comes with NLTK and spaCy, two of the most important NLP libraries.  In short, you don't need to install any libraries to follow along with this tutorial as long as you're using Colab.&lt;/p&gt;

&lt;h3&gt;
  
  
  Obtaining Data
&lt;/h3&gt;

&lt;p&gt;The data that this tutorial uses comes from the Cornell Movie-Dialogs Corpus which contains information about 617 Hollywood films. The data this article is concerned with is the conversational data which is just the lines delivered by the characters in the movie and the genders of the character. For that purpose, I extracted all the relevant data and merged it into one file for easy use which you can find here: &lt;a href="https://drive.google.com/file/d/1pD6u40QVZ6bHeLgUUmH2eRNZv4F-byz_/view?usp=sharing"&gt;https://drive.google.com/file/d/1pD6u40QVZ6bHeLgUUmH2eRNZv4F-byz_/view?usp=sharing&lt;/a&gt;. This data file contains a lot of lines from movies with associated information about the characters, including the gender of the characters, which is of great importance for building the classifier. Once you download the data file, upload it to a folder named data that is within your &lt;code&gt;root_dir&lt;/code&gt; as defined above on Google Drive. When you finish, you're ready to move on to the preprocessing stage of the tutorial.&lt;/p&gt;

&lt;h2&gt;
  
  
  Preprocessing Data
&lt;/h2&gt;

&lt;p&gt;The first step one takes in most Data Science projects of any kind is to examine the data they're working with and then preprocess it. For those of you who are unfamiliar with the term preprocessing, all it really is just making the data usable for whatever task you intend to do with it. The different preprocessing tasks vary based on the field and this section will cover a few common NLP preprocessing tasks that will help with the larger Deep Learning NLP goal.&lt;/p&gt;

&lt;h3&gt;
  
  
  Preliminary Analysis of the Dataset
&lt;/h3&gt;

&lt;p&gt;Before you begin a Data Science project, it is always good to take a brief look at what your dataset actually looks like. We know that we only have two classes to classify: males and females. Hence, you'll also need to look for &lt;em&gt;imbalances&lt;/em&gt; in between the two classes, which is just a fancy way of saying you need to see if the number of data points for each class is around the same. Thankfully to get a quick overview of the data you just need to use a little Python!  While you conduct the preliminary analysis of the data, you'll also be creating two new files, &lt;code&gt;male.txt&lt;/code&gt; and &lt;code&gt;female.txt&lt;/code&gt;, which will make it easier when we're training our models. Before you follow along with the following steps, create a new notebook and call it &lt;code&gt;preprocessing&lt;/code&gt; in Colab. Once you do that and the cell that mounts your drive on Colab, you can follow along with the rest of this section. &lt;/p&gt;

&lt;p&gt;The first thing you should do is open up the &lt;code&gt;collated_data.txt&lt;/code&gt; file and look at its format. You'll notice that it uses "+++$+++" as the delimiter, which is just what it uses to separate different data values, in a CSV the delimiter is a comma. You'll also notice that there's 7 different pieces of information in each line, in order they are: line number, character id, movie id, character name, character gender, line text, and character's position in the credits. You may also see that there is a ? in place of the character gender in some places and that is because the people who put the dataset together were unable to ascertain the gender of the character. &lt;/p&gt;

&lt;p&gt;Now that you've taken a brief look over your data you'll need to separate the data based on the gender of the characters. This can be done in base python without the help of any libraries. Follow along with these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add the following cell to your notebook, all it does is initialize a list that will contain the text of the lines delivered by males and then another list for females.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   male_lines = []
   female_lines = []
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Next, you'll need to loop through the data file and add the text to either the male or female list depending on the gender of the speaker. You can do this with basic file operations and conditional statements. Note that &lt;code&gt;root_dir&lt;/code&gt; is defined in the first cell discussed in this tutorial and that collated_data.txt should be present in that directory.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;with open(root_dir+'collated_data.txt', encoding="charmap") as data:
    for line in data:
        line_no, chr_id, mov_id, chr_name, gender, text, credit = line.strip().split("+++$+++")
        if(gender.strip().lower() == 'm'):
            male_lines.append(text)
        elif(gender.strip().lower() == 'f'):
            female_lines.append(text)      
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll notice that we split the line based on the delimiter and then have variables for each attribute that is on the line. The only two that matter for this tutorial are the character gender and the line text.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You'll now do some preliminary analysis of the dataset which just boils down to looking at the number of male and female lines. This just requires use of the &lt;code&gt;len()&lt;/code&gt; function.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(len(male_lines)) #Output: 170768  
print(len(female_lines)) #Output: 71255
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yikes! There's almost 100,000 more male data points than there are female data points! That's a massive imbalance and something that will need to be corrected before a classifier can be constructed. In the meantime however, we can proceed with writing the male and female lines to separate text files.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;By writing the male and female lines to separate files you'll be doing yourself a favor and making it easier to reuse the data for  future projects.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;with open(root_dir+'male.txt', mode='w+') as male:
    for line in male_lines:
        male.write(line + '\n')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;with open(root_dir+'female.txt', mode='w+') as female:
    for line in female_lines:
        female.write(line + '\n')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code blocks are separate because I encourage you to put them in different cells of your notebook for clarity's sake. Now that you're done with some very basic preprocessing, it's time that you do some preprocessing tasks that are exclusive to NLP.&lt;/p&gt;

&lt;h3&gt;
  
  
  Introduction to NLP Terms and Preprocessing
&lt;/h3&gt;

&lt;p&gt;There's a lot of information that gleaned be from words in the English language, however you often don't need the whole sentence to be able to ascertain its meaning. In NLP, there's usually a lot of unimportant data that we can clear out so as to reduce the noise in the inputs to our model. The most common of these preprocessing steps include: &lt;strong&gt;tokenization&lt;/strong&gt;, &lt;strong&gt;stopword removal&lt;/strong&gt;, and &lt;strong&gt;stemming&lt;/strong&gt;. However, these steps are not always applied because sometimes they remove useful data. In fact, there will be no stopword removal or stemming applied to this dataset because of the important information that may be removed by those steps. Here are some definitions of each of these steps.&lt;/p&gt;

&lt;h4&gt;
  
  
  Tokenization
&lt;/h4&gt;

&lt;p&gt;Tokenization is the breaking down of a sentence or document into individual tokens which are essentially just words. This can be done with the help of a function from the NLTK library called &lt;code&gt;nltk.tokenize.tokenize()&lt;/code&gt;. You can also have this done by PyTorch when you're loading data into your model and this is what you will be doing when you write the LSTM model. By turning sentences into individual tokens you're creating sequential data that is very useful for LSTMs. &lt;/p&gt;

&lt;h4&gt;
  
  
  Stopword Removal
&lt;/h4&gt;

&lt;p&gt;Stopword removal is the process of removing common words in the English language from text. Often this is done so that models don't weight extremely common words disproportionately in comparison to rarer words in the English language that show up more often in that particular text. However, no stopword removal should be done for this project since the movie lines are already fairly short and all the tokens are valuable.&lt;/p&gt;

&lt;h4&gt;
  
  
  Stemming
&lt;/h4&gt;

&lt;p&gt;As the name suggests, Stemming is just turning words into their stems. This is helpful when knowing the tense or form of a word doesn't matter to the task at hand, however, for the task of text classification this may prove to be incredibly useful.&lt;/p&gt;

&lt;h4&gt;
  
  
  Splitting the Data into Training and Testing sets
&lt;/h4&gt;

&lt;p&gt;One of the most important preprocessing steps in Machine Learning in general is dividing your dataset into training and testing sets. Remember, there are a lot more male data points than female data points which mean's you'll have to correct this imbalance somehow. Keep this in mind as you begin to divide the data. The following code will still be a part of the &lt;code&gt;preprocessing&lt;/code&gt; notebook. Your main goal will be to create a file that will contain the training data and a file that will contain the testing data.&lt;/p&gt;

&lt;p&gt;When creating training and testing sets you must keep in mind that the number of data points for each class should be roughly the same in both the training and testing sets. The testing set will usually be much smaller than the training set, following an 80/20 split of all the data. Scikit-learn has a built in function that splits data into training and testing for you! Before you divide the data, throw your mind back to the imbalance in the data that we saw. There are a lot more male data points than female data points. You can combat this by either randomly oversampling or randomly undersampling our training set. By randomly oversampling the train set you will increase the number of female data points by using some of them multiple times until the number of female lines matches the number of male lines in the train set. By randomly undersampling the train set you will decrease the number of male data points to match the number of female lines in the dataset. Oftentimes, randomly undersampling will lead to a lower accuracy for a model because there just isn't enough data, and for that reason you'll be randomly oversampling the train set. &lt;/p&gt;

&lt;p&gt;Now you may be wondering why the train set is being randomly oversampled and that is because if we were to randomly oversample the entire dataset, it is likely that there would be some overlap in between the train set and the test set which would then lead to an inaccurate representation of the performance of the model. &lt;/p&gt;

&lt;p&gt;Alright, enough theory! It is time for you to write some code. Let us have around 10% of the data be for testing and 90% be for training. To properly split your data into training and testing, follow along with these steps.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create the testing set first by simply taking the first 10,000 lines from both the male and female lists.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;male_test = male_lines[:10000]
female_test = female_lines[:10000]
X_test = male_test + female_test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Now that there exists the X portion of the testing set, the labels need to be constructed. Our labels in this case will be 0 if the line was delivered by a male and a 1 if the line was delivered by a female. This can be accomplished with two simple for loops.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Y_test = []
for x in male_test:
    Y_test.append(0)
for x in female_test:
    Y_test.append(1)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;The test set is now complete, it is time for the creation of the train set. First, take everything that wasn't used in the test set and put that it into two new lists: &lt;code&gt;male_train&lt;/code&gt; and &lt;code&gt;female_train&lt;/code&gt;.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;male_train = male_lines[10000:]
female_train = female_lines[10000:]
X_train = male_train + female_train
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Now you need to create &lt;code&gt;Y_train&lt;/code&gt;, which will contain the labels for the lines in X_train. This is the same process  that was used to make the labels for the test set.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Y_train = []
for x in male_train:
    Y_train.append(0)
for x in female_train:
    Y_train.append(1)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Since the number of male lines significantly outnumber the number of female lines in the train set, you'll need to oversample the female lines. This can be done with the help of a library called imblearn which is included in your colab environment. You'll also need to import numpy. The following code oversamples until the number of female lines is equal to the number of the male lines.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import numpy as np
from imblearn.over_sampling import RandomOverSampler
oversample = RandomOverSampler(sampling_strategy='minority')
X_train, Y_train = oversample.fit_resample(np.array(X_train).reshape(-1,1), Y_train)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;The &lt;code&gt;X_train&lt;/code&gt; that is created in the above code block is actually a list of lists with one element where the one element is the movie line. It should just be a list of strings. This is an easy conversion with a quick for loop and list indexing.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;male_lines = []
for phrase in X_train:
    male_lines.append(phrase[0].strip())
X_train = male_lines
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Now that both the training and test sets are completely constructed, they need to be converted into pandas dataframes and then saved as CSVs. The dataframes will have two columns: &lt;code&gt;text&lt;/code&gt; and &lt;code&gt;target&lt;/code&gt;, where &lt;code&gt;text&lt;/code&gt; is a movie line and &lt;code&gt;target&lt;/code&gt; is either 0 or 1 depending on the gender of the speaker. To do all of this, pandas will need to be imported but the code itself is fairly simple. You will create two dataframes and fill them with the train and test lists that have been created and then save them to &lt;code&gt;root_dir&lt;/code&gt;.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pandas as pd
train_df = pd.DataFrame()
test_df = pd.DataFrame()

train_df['text'] = X_train
train_df['target'] = Y_train

test_df['text'] = X_test
test_df['target'] = Y_test

train_df.to_csv(root_dir + 'train.csv')
test_df.to_csv(root_dir + 'test.csv')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Amazing! You now have cleaned data and a training and testing set! The actual creation of the models will take you less time than the preprocessing stage and this is often true of real-life data science projects. Without further ado, it is time to move on to building the classifiers.&lt;/p&gt;

&lt;h2&gt;
  
  
  LSTMs for Text Classification
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How does a Recurrent Neural Network (RNN) work?
&lt;/h3&gt;

&lt;p&gt;Long Short Term Memory Networks (LSTMs) are a version of RNNs. To properly understand how LSTMs work, one needs to know how RNNs work. What's great about RNNs is that they have internal memory which other Neural Networks do not. People use RNNs when they're dealing with sequential data, such as language! In this explanation of the workings of a RNN, it is assumed that you know how basic feed-forward networks work.&lt;/p&gt;

&lt;p&gt;In a RNN the input data cycles in a loop, when it comes time to make a decision the RNN takes into account the current input and the input that came before it. A normal RNN has short-term memory which is one of the reasons LSTMs need to be used, so that the network has long-term memory as well. In essence a RNN has two inputs: the current input, and the recent inputs. This provides an edge when doing language related tasks. Additionally, unlike Feed-Forward networks which can only map one input to one output, RNNs can do one to many, many to many, and many to one. This is a brief summary of RNNs and there's a lot of in-depth math that one can get into and I would advise you to read up on that to get a really thorough understanding of the network.&lt;/p&gt;

&lt;h3&gt;
  
  
  GloVe Vectors
&lt;/h3&gt;

&lt;p&gt;GloVe vectors are what we'll be using as the inputs to our model. GloVe stands for global vectors for word representation and it is used to create word embeddings. Word embeddings often serve as the inputs for Deep Learning NLP models and are just a way to convert textual information like sentences into numerical like data. This makes the input understandable for deep learning models. This section will walk you through the first few steps of writing the LSTM in PyTorch which is really just loading the data and creating GloVe vectors. &lt;/p&gt;

&lt;p&gt;First you'll need to create a new notebook on Colab to actually write the LSTM in. You should probably name it something along the lines of &lt;code&gt;GenderClassifierLSTM.ipynb&lt;/code&gt;. Before you type up any lines of code, make sure to change the runtime of your notebook and ensure that it is utilizing a GPU. To do this, click on Runtime &amp;gt; Change Runtime Type and then change the Hardware Accelerator to a GPU.  To load in the data and set the base for your LSTM, follow along with these steps. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Mount your Google Drive in Colab
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from google.colab import drive
drive.mount('/content/gdrive', force_remount=True)
root_dir = "/content/gdrive/My Drive/pathtoyourdatahere"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Import all the necessary libraries. Don't be scared at everything that is being imported here, you'll know what everything means by the end. Some quick highlights are that we're using PyTorch, Numpy, Pandas, and Scikit-Learn. The PyTorch documentation is something that you'll need to continuously look at and you can find it at &lt;a href="https://pytorch.org/docs/stable/index.html"&gt;https://pytorch.org/docs/stable/index.html&lt;/a&gt;.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import torch
import torch.nn as nn 
import torch.nn.functional as F
import torchtext 
import numpy as np
import pandas as pd
from torchtext import data
from torch.utils.data import Dataset, DataLoader
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence 
from sklearn.metrics import mean_squared_error
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Now it is time to load in the data that you have, a fairly easy task.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;train_df = pd.read_csv(root_dir + 'train.csv')
test_df = pd.read_csv(root_dir + 'test.csv')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Now, when you load in a CSV into Colab, you'll end up with an extra column at the beginning and to fix that you'll need to reconstruct both the &lt;code&gt;train_df&lt;/code&gt; and &lt;code&gt;test_df&lt;/code&gt;. The way to do this is by just extracting the relevant columns and then putting them into new dataframes.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;X_train = train_df['text']
Y_train = train_df['target']
X_test = test_df['text']
Y_test = test_df['target']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Another point you must look into as one final bit of preprocessing is removing NaN values from your data. An easy way to do this is to just remove all data types that are floats from your lists because when dealing with textual data only the nans will be floats.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;indices = []
for i in range(len(X_train)):
  if (isinstance(X_train[i], float)):
    indices.append(i)

for index in sorted(indices, reverse=True):
    del X_train[index]
    del Y_train[index]

indices = []
for i in range(len(X_test)):
  if (isinstance(X_test[i], float)):
    indices.append(i)

for index in sorted(indices, reverse=True):
    del X_test[index]
    del Y_test[index]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Now you will seed your notebook so that you'll get the same results everytime you run the notebook.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SEED = 42

torch.manual_seed(SEED)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Now if you recall, one of the important parts of preprocessing textual data is tokenization. PyTorch allows us to do this when we're creating the fields of the model, of which we have two: &lt;code&gt;TEXT&lt;/code&gt; and &lt;code&gt;LABEL&lt;/code&gt; which are self-explanatory.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TEXT = data.Field(tokenize = 'spacy', include_lengths = True)
LABEL = data.LabelField(dtype = torch.float)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, we're creating two fields using the built in fields that &lt;code&gt;torch.utils.data&lt;/code&gt; has. The text is then being tokenized using spaCy, which is one of the text processing libraries that is used in such projects.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;When working with Deep Learning NLP in PyTorch and any other type of Deep Learning, you usually need to write classes to accommodate your custom Datasets and make sure you can load it into your model. In this case, you'll be writing a custom class that will represent a dataframe.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class DataFrameDataset(data.Dataset):

    def __init__(self, df, fields, is_test=False, **kwargs):
        examples = []
        for i, row in df.iterrows():
            label = row.target if not is_test else None
            text = row.text
            examples.append(data.Example.fromlist([text, label], fields))

        super().__init__(examples, fields, **kwargs)

    @staticmethod
    def sort_key(ex):
        return len(ex.text)

    @classmethod
    def splits(cls, fields, train_df, val_df=None, test_df=None, **kwargs):
        train_data, val_data, test_data = (None, None, None)
        data_field = fields

        if train_df is not None:
            train_data = cls(train_df.copy(), data_field, **kwargs)
        if val_df is not None:
            val_data = cls(val_df.copy(), data_field, **kwargs)
        if test_df is not None:
            test_data = cls(test_df.copy(), data_field, True, **kwargs)

        return tuple(d for d in (train_data, val_data, test_data) if d is not None)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All of this code is standard among many projects that I've done before and you will most likely end up using this class multiple times so be sure to save it! The most important part of this class is the splits method and it used to split the TEXT and LABEL field into a train and test dataset that is readable by the model we create. This also happens to be the next step in this process. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The next step is to make the train and test dataset readable to the model you'll create and to do do this you'll be using the splits method in the DataFrameDataset class that you wrote.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fields = [('text',TEXT), ('label',LABEL)]
train_ds, test_ds = DataFrameDataset.splits(fields, train_df=train_df, val_df=test_df)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you have your train and test datasets in a readable format, and you are ready to construct GloVe vectors. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;When constructing GloVe vectors you're going to have to define the size of your vocabulary, and in this case it will be the size of the X_train vector. You also have to define the size of the vector, or how many dimensions it will have. 200 dimensions is standard. In the following code block, you are building the vocabulary for your TEXT. As you can see your vocabulary's size is the number of lines in the X_train list.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MAX_VOCAB_SIZE = len(train_df['text'])

TEXT.build_vocab(train_ds, 
                 max_size = MAX_VOCAB_SIZE, 
                 vectors = 'glove.6B.200d',
                 unk_init = torch.Tensor.zero_)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Having built the vocabulary for the text, you'll need to do the same for your labels but you won't be using GloVe vectors.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LABEL.build_vocab(train_ds)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alright! You've finished all the preprocessing you need and have set the basis for writing your LSTM. It is time to learn more about the wonder that is a Long Short Term Memory Network.&lt;/p&gt;

&lt;h3&gt;
  
  
  What are LSTMs?
&lt;/h3&gt;

&lt;p&gt;LSTMs are an improvement upon RNNs. It was mentioned earlier that RNNs have short-term memory which is one of their advantages and this is improved upon in LSTMs. LSTMs are able to maintain memories long-term which significantly boosts their performance. &lt;/p&gt;

&lt;p&gt;LSTMs are centered around something called the cell state which is commonly thought of as a conveyor belt. This conveyor belt goes through the chain of modules of the neural network. Information usually goes through the chain unchanged and uninterrupted. However, the LSTM can alter the information that the cell state has through the use of "gates". Gates are made of a pointwise multiplication operation and a sigmoid neural net layer. If you're familiar with deep learning you'll know that the sigmoid layer just outputs numbers between zero and one. This corresponds to how much of each component should be let through. As you may surmise, 0 means nothing should be let through and 1 means everything should be let through. LSTMs have three such gates and that is how they control the flow of information in the networks. I'd suggest that you read more about the math behind Long Short Term Memory Networks after you implement one and it will help you gain a better understanding of the network.&lt;/p&gt;

&lt;p&gt;Enough theory! Time to implement this in PyTorch. Follow along with these steps and you'll be golden the next time you want to implement an LSTM.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Before you really get into writing the LSTM there's some housekeeping things you need to do that is common amongst most PyTorch Neural Network implementations. Namely, making sure that you'll be using a GPU to train and choosing some hyperparameters. Another important thing that you're doing is declaring a &lt;code&gt;train_iterator&lt;/code&gt; and a &lt;code&gt;valid_iterator&lt;/code&gt;. These will be used during the training and testing of the model respectively to, as the name suggests, iterate through data.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BATCH_SIZE = 256

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

train_iterator, valid_iterator = data.BucketIterator.splits(
    (train_ds, test_ds), 
    batch_size = BATCH_SIZE,
    sort_within_batch = True,
    device = device)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Alright, the only hyperparameter that is defined so far is the BATCH_SIZE. There are a lot of other important hyperparameters that should be discussed. They are all in the code block below with accompanying explanations.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Hyperparameters
num_epochs = 25 #This is the number of epochs and dictates how long the model trains for
learning_rate = 0.001 #This essentially determines how quickly a model trains

INPUT_DIM = len(TEXT.vocab) #As the name suggests this is the input dimension
EMBEDDING_DIM = 200 #The GloVe Embedding dimensions which is 200
HIDDEN_DIM = 256 #The number of hidden dimensions
OUTPUT_DIM = 1 #The number of output dimensions: 1 (either 0 or 1)
N_LAYERS = 4 #The number of layers in the neural network.
BIDIRECTIONAL = True #LSTMs are Bidirectional so don't change this hyperparameter
DROPOUT = 0.2 # Dropout is when random neurons are ignored, the higher the dropout the greater percentage of neurons are ignored.
PAD_IDX = TEXT.vocab.stoi[TEXT.pad_token] # padding makes it so that sequences are padded to the maximum length of any one of the sequences, in this case that would be the longest utterance delivered by a movie character.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Now comes the exciting part, actually writing the LSTM. You'll be creating a class called &lt;code&gt;LSTM_net&lt;/code&gt; that inherits from PyTorch's &lt;code&gt;nn.Module&lt;/code&gt;. As with any class that one writes in Python, the first thing to do is write the &lt;code&gt;__init__&lt;/code&gt; method.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class LSTM_net(nn.Module):
    def __init__(self, vocab_size, embedding_dim, hidden_dim, output_dim, n_layers, 
                 bidirectional, dropout, pad_idx):

        super().__init__()

        self.embedding = nn.Embedding(vocab_size, embedding_dim, padding_idx = pad_idx)

        self.rnn = nn.LSTM(embedding_dim, 
                           hidden_dim, 
                           num_layers=n_layers, 
                           bidirectional=bidirectional, 
                           dropout=dropout)

        self.fc1 = nn.Linear(hidden_dim * 2, hidden_dim)

        self.fc2 = nn.Linear(hidden_dim, 1)

        self.dropout = nn.Dropout(dropout)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you take a look at the parameters that the &lt;code&gt;__init__&lt;/code&gt; method takes, you'll notice that they are the hyperparameters we've already set and that they're being used to construct the LSTM. The method starts off with a classic trait of inheritance in Python which is calling &lt;code&gt;super().__init__&lt;/code&gt; to call the init method of the nn.Module class, for which you should look at the documentation of. Next the embedding for the LSTM is being constructed using the vocab size, embedding dimensions, and padding. This embedding is just a simple lookup table that stores embeddings of a fixed dictionary and size and is being used to store the GloVe word embeddings. &lt;/p&gt;

&lt;p&gt;You'll also notice that an RNN is being used as the base of the LSTM with some of the hyperparameters that have already been defined. You may be confused by the two variables called &lt;code&gt;self.fc1&lt;/code&gt; and &lt;code&gt;self.fc2&lt;/code&gt;, but don't fear, these are just the two activation layers of the LSTM with the first one being larger than the second one. FC is shorthand for fully connected layer. The last variable that is initialized is the dropout of the network which was discussed earlier. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now it is time to move on the second of the two methods that this class will have: &lt;code&gt;forward()&lt;/code&gt; which encodes the forward pass for the network.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def forward(self, text, text_lengths):  
        embedded = self.embedding(text)

        packed_embedded = nn.utils.rnn.pack_padded_sequence(embedded, text_lengths)
        packed_output, (hidden, cell) = self.rnn(packed_embedded)

        # concat the final forward (hidden[-2,:,:]) and backward (hidden[-1,:,:]) hidden layers
        # and apply dropout
        hidden = self.dropout(torch.cat((hidden[-2,:,:], hidden[-1,:,:]), dim = 1))
        output = self.fc1(hidden)
        output = self.dropout(self.fc2(output)) 
        #hidden = [batch size, hid dim * num directions] 
        return output
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The forward pass deals with the embedded text, packing said text and then applying the dropout to the final forward and backward hidden layers, and applying dropout to that to get the final output for the method. The above code represents that process and if you would like to know more about these functions I would suggest you take a look at the PyTorch documentation.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Ok, now that the LSTM class has been created, you'll need to make an instance of the class.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#creating instance of our LSTM_net class

model = LSTM_net(INPUT_DIM, 
            EMBEDDING_DIM, 
            HIDDEN_DIM, 
            OUTPUT_DIM, 
            N_LAYERS, 
            BIDIRECTIONAL, 
            DROPOUT, 
            PAD_IDX)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;It is time to store the embeddings in a variable, conveniently labeled &lt;code&gt;pretrained_embeddings&lt;/code&gt; and then imparting this knowledge to the model.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pretrained_embeddings = TEXT.vocab.vectors
model.embedding.weight.data.copy_(pretrained_embeddings)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;To make the padding of the network you'll need to fill it out with a bunch of zero which can be done with  the following line of code.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;model.embedding.weight.data[PAD_IDX] = torch.zeros(EMBEDDING_DIM)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;To make sure the model trains on the GPU, use the following line of code.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;model.to(device)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;All neural networks need a loss function and optimizer! Add them with the following block of code.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Loss and optimizer
criterion = nn.BCEWithLogitsLoss()
optimizer = torch.optim.Adam(model.parameters(), learning_rate)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Next, you'll be writing a function that will calculate the accuracy of your model's predictions with some basic logic. Pay attention to the comments to understand what's happening!
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def binary_accuracy(preds, y):
    """
    Returns accuracy per batch, i.e. if you get 8/10 right, this returns 0.8, NOT 8
    """

    #round predictions to the closest integer
    rounded_preds = torch.round(torch.sigmoid(preds))
    correct = (rounded_preds == y).float() #convert into float for division 
    acc = correct.sum() / len(correct)
    return acc

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Training the LSTM
&lt;/h3&gt;

&lt;p&gt;Whew! You've worked through a lot so far and you're almost at the end of the road! It is time to train and test the model! &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You'll need to write a function that you'll use to train the model.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def train(model, iterator):
    epoch_loss = 0
    epoch_acc = 0

    model.train()

    for batch in iterator:
        text, text_lengths = batch.text
        optimizer.zero_grad()
        predictions = model(text, text_lengths).squeeze(1)
        loss = criterion(predictions, batch.label)
        acc = binary_accuracy(predictions, batch.label)

        loss.backward()
        optimizer.step()

        epoch_loss += loss.item()
        epoch_acc += acc.item()

    return epoch_loss / len(iterator), epoch_acc / len(iterator)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This function keeps track of both the accuracy and loss for each Epoch that you're training the model for and goes through forward passes and backpropagation and then measures the accuracy by using the &lt;code&gt;binary_accuracy&lt;/code&gt; function that you wrote earlier. It returns the accuracy and loss for the epoch when it is done training.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; You'll also need a function that you'll use to evaluate the model's performance.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def evaluate(model, iterator):

    epoch_loss = 0
    epoch_acc = 0
    model.eval()

    with torch.no_grad():
        for batch in iterator:
            text, text_lengths = batch.text

            predictions = model(text, text_lengths).squeeze(1)
            loss = criterion(predictions, batch.label)
            acc = binary_accuracy(predictions, batch.label)

            epoch_loss += loss.item()
            epoch_acc += acc.item()

    return epoch_loss / len(iterator), epoch_acc / len(iterator)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This function loops through the test data, feeds it to the model and then measures the prediction against the actual label. It then outputs the loss and accuracy for the epoch.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;This will be the last block of code you write, it is what will actually train the model. It is fairly plain python and requires one import, the &lt;code&gt;time&lt;/code&gt; library that is already included with colab so you don't have to install anything.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import time

t = time.time()
loss=[]
acc=[]
val_acc=[]
val_losses=[]

for epoch in range(num_epochs):
    train_loss, train_acc = train(model, train_iterator)
    val_loss, valid_acc = evaluate(model, valid_iterator)
    print("Epoch " + str(epoch) + " :")
    print(f'\tTrain Loss: {train_loss:.3f} | Train Acc: {train_acc*100:.2f}%')
    print(f'\tVal Loss: {val_loss:.3f} | Val. Acc: {valid_acc*100:.2f}%')
    print('\n')
    loss.append(train_loss)
    acc.append(train_acc)
    val_acc.append(valid_acc)
    val_losses.append(val_loss)
print(f'time:{time.time()-t:.3f}')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code block above keeps track of the loss and accuracy for each epoch and then stores them in a list that you can use to graph and see the performance of the model over epochs. It also keeps track of the time the model takes to train on each epoch. With the current hyperparameters, you'll end with a validation accuracy in the range of 70% and a training time of 30 minutes. By adjusting the hyperparameters you can boost the performance of the model, but that may come at the cost of having higher training time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;You've learned a lot in this article, mainly how to perform binary text classification on a dataset with PyTorch. The skills you learned through this article are transferrable to any other textual dataset where you want to classify two labels but the level of work required for datasets will vary. Some come pre-cleaned and in that case you just have to make a model but others are rough and you'll have to do a lot of textual preprocessing before you even think about making a model. Preprocessing is usually the most time consuming part of developing a model besides training the model itself. You are now armed with incredibly valuable knowledge and I advise you to go out and find a dataset and practice the skills you just learned.&lt;/p&gt;

&lt;p&gt;If you gained value from this post consider following me on &lt;a href="https://twitter.com/sidcodes"&gt;Twitter&lt;/a&gt; and &lt;a href="https://www.siddcodes.com/"&gt;subscribing to my email newsletter&lt;/a&gt;. Every Sunday, I send out a newsletter that contains the best programming and learning-related content I’ve seen in the past week along with my own thoughts on the events of the week. The main goal of the newsletter is to bring meaningful and thought-provoking ideas to your inbox every Sunday. Consider signing up if you’re interested.&lt;/p&gt;

</description>
      <category>deeplearning</category>
      <category>python</category>
      <category>machinelearning</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>#100DaysOfNLP Day 5: Gendered Dialogue in Movies</title>
      <dc:creator>Siddhant Dubey</dc:creator>
      <pubDate>Tue, 16 Jun 2020 21:13:27 +0000</pubDate>
      <link>https://forem.com/siddhantdubey/100daysofnlp-day-5-gendered-dialogue-in-movies-1037</link>
      <guid>https://forem.com/siddhantdubey/100daysofnlp-day-5-gendered-dialogue-in-movies-1037</guid>
      <description>&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@andrewtneel?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Andrew Neel&lt;/a&gt; on &lt;a href="https://dev.to/s/photos/research?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: This post was written for work done on the 15th of June, 2020. If you want to catch up with the first four days, which you definitely do not need to do, the articles are available on my &lt;a href="https://www.siddcodes.com/"&gt;blog&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It has been a while since I last wrote one of these blog posts but that was because I really hadn't learned or done anything of value. However, I have now begun work on an incredibly interesting project that I'll now be writing about every day until it reaches completion. I'm currently being mentored by &lt;a href="https://www.ssriva.com/"&gt;Dr. Srivastava&lt;/a&gt; and &lt;a href="https://cs.unc.edu/people/snigdha-chaturvedi/"&gt;Dr. Chaturvedi&lt;/a&gt; at UNC Chapel Hill and working with one of my classmates, Bhargav Vaduri, on the project. Without further ado, let me get into covering what the project is and what work we've done on it so far. If you want to see the code for the project, &lt;a href="https://github.com/siddhantdubey/GenderedMovieDialogue"&gt;here is our github repository&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Research Problem:
&lt;/h2&gt;

&lt;p&gt;What we're attempting to do with the project is analyze lines from movies and then identify the gender of the character who said the line. The first big goal we want to hit with this project is to be able to build a classifier that can identify the gender of the speaker of a line to a fairly high degree of accuracy. Hopefully, we'll be able to hit that goal soon and then move on to trying to hit other goals using the same dataset.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Dataset:
&lt;/h2&gt;

&lt;p&gt;Speaking of our dataset, we'll be using the &lt;a href="https://www.cs.cornell.edu/~cristian/Cornell_Movie-Dialogs_Corpus.html"&gt;Cornell Movie-Dialogs Corpus&lt;/a&gt; which is a massive textual dataset that contains dialogue from 617 movies, with 304,713 lines of dialogues. Since we're focusing on the gender of the characters that said the utterance (line of dialogue), we are only focusing on two of the files in the dataset: movie_lines.txt and movie_characters_metadata.txt. This is only for the time being, as we make progress with the project we will most likely use other data from the dataset to perform other analyses.&lt;/p&gt;




&lt;h2&gt;
  
  
  Events of the Day:
&lt;/h2&gt;

&lt;p&gt;Most of today was spent working on preprocessing the data, formatting it to our needs, and reading the &lt;a href="https://www.cs.cornell.edu/~cristian/papers/chameleons.pdf"&gt;original research paper&lt;/a&gt; that accompanied the corpus: &lt;a href="https://www.cs.cornell.edu/~cristian/papers/chameleons.pdf"&gt;Chameleons in imagined conversations: A new approach to understanding coordination of linguistic style in dialogs&lt;/a&gt;. I've already mentioned that we wanted to format our data in a specific way that would make it easier for us to work with it. The main thing we're doing here is adding information about the character's gender and their position in the credits to the information present about each line of dialogue in movie_lines.txt. We then put this combined information into a new text file that we are calling collated_data.txt. This file is 304,713 lines long with 7 tokens on each line: the line number in the script, the movie id, the character id, the character gender, character name, and the text of the utterance. This was a simple task to do with python and we got it done in the day. We also did some precursory analysis of the data. I attempted to POS tagging of the textual data today, but formatting in the way I wanted got to be a little tedious for how tired I was by the end of the day, so I decided to finish it on Tuesday morning. Our results for the day are present in the next section, it is pretty sparse since we only really did preprocessing, however, Tuesday's results section will be significantly bigger.&lt;/p&gt;




&lt;h2&gt;
  
  
  Results of the Day:
&lt;/h2&gt;

&lt;p&gt;Our precursory analysis focused on seeing how the data breaks down by gender and this is what we found:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The number of male characters is 2049&lt;/li&gt;
&lt;li&gt;The number of instances of a male character speaking is 170,168.&lt;/li&gt;
&lt;li&gt;The number of female characters is 966&lt;/li&gt;
&lt;li&gt;The number of instances of female speech is 71255&lt;/li&gt;
&lt;li&gt;The number of characters of unknown gender is 6020&lt;/li&gt;
&lt;li&gt;The number of instances of speech from a character of unknown gender is 62690.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Like I mentioned at the beginning of today's post, the code for the project is being hosted on &lt;a href="https://github.com/siddhantdubey/GenderedMovieDialogue"&gt;our github repository.&lt;/a&gt; So if you want to check that out, be my guest! Until then, keep coding!&lt;/p&gt;

&lt;p&gt;As always, if you want to keep up to date with my work, consider subscribing to my &lt;a href="https://mailchi.mp/35c069691d2c/newsletter-signup"&gt;newsletter here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>100daysofcode</category>
      <category>datascience</category>
    </item>
    <item>
      <title>5 Great Productivity Tools for Programmers</title>
      <dc:creator>Siddhant Dubey</dc:creator>
      <pubDate>Sun, 14 Jun 2020 15:25:53 +0000</pubDate>
      <link>https://forem.com/siddhantdubey/5-great-productivity-tools-for-programmers-3oj7</link>
      <guid>https://forem.com/siddhantdubey/5-great-productivity-tools-for-programmers-3oj7</guid>
      <description>

&lt;p&gt;As a programmer, you probably have a love-hate relationship with your craft. There are times that you love programming and there are other times that you just don’t want to write &lt;code&gt;print("Hello World").&lt;/code&gt; However, you probably always want to get your work done and make it as enjoyable as possible, and using some productivity apps can have that exact effect. I’ve been using all of the tools I list in here for at least a month now and I love each and every single one of them. They’ve made working a lot more fun for me and have definitely allowed me to finish my work quicker. So without further ado, let me show you five great productivity tools that will make your life better.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;a href="https://kite.com/"&gt;Kite&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NOlVxB6K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2A_a0xjNK0D6EE9sF2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NOlVxB6K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2A_a0xjNK0D6EE9sF2.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://kite.com/"&gt;Kite&lt;/a&gt; is an AI-powered autocomplete plugin for Python and Javascript that works for all your favorite text editors. You’ve probably seen sponsored segments in youtube videos about the plugin, but its value speaks for itself. While your standard autocomplete can only complete the word or the line, Kite allows you to complete multiple lines at a time so that you spend less time writing out repetitive boilerplate like code. It also gives you in-depth documentation for Python and Javascript within your code editor so you don’t have to leave to make a quick google search. Best of all, it’s free! If you’re a Python or Javascript developer, I implore you to get this extension for your code editor and I promise you’ll see your productivity increase.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;a href="https://www.notion.so/login"&gt;Notion&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--h6sx6VPt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2ARvUxzduZV4Da23Vv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h6sx6VPt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2ARvUxzduZV4Da23Vv.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Picture from Notion’s website.&lt;/p&gt;

&lt;p&gt;If you’ve been on either productivity Twitter or productivity YouTube within the last couple of months, you’ve probably heard about this tool. For those of you who are uninitiated, Notion is basically an all in one project management tool for teams and individuals. It allows you to take notes, build wikis and publish them as webpages, mark out your calendar, and track the progress of your projects with a kanban board. It also allows you to create dynamic databases that you can use to track your work and notes as well. It is an incredibly powerful tool that will help you stay on track of your work and make note-taking fun again. It has a free tier that is more than enough for the average user, but you can also upgrade for free if you have a student email. If you want to learn more about using Notion, I suggest Ali Abdaal’s youtube channel: &lt;a href="https://www.youtube.com/channel/UCoOae5nYA7VqaXzerajD0lg"&gt;https://www.youtube.com/channel/UCoOae5nYA7VqaXzerajD0lg&lt;/a&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;a href="https://obsidian.md/"&gt;Obsidian&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uVDZ4GLO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AxFgreKP_VLxdR2lbxt4z4g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uVDZ4GLO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AxFgreKP_VLxdR2lbxt4z4g.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A graph of my notes from the last week in obsidian.&lt;/p&gt;

&lt;p&gt;Continuing on the subject of note-taking. Obsidian has changed the way I take notes and write articles. I have only been using it for a week, but I used a very similar tool called Roam Research for much longer and switched when they started charging 15 dollars a month. Obsidian markets itself as your second brain, and honestly? It might as well be. Just like your brain makes connections between things you learn, you can make links in between your notes in Obsidian and then visualize the way they look using its graph view. This follows the Zettelkasten method of note-taking. What this method of note-taking focuses on is connecting all your notes to make it easier for you to come up with ideas. It also focuses on making sure you have easy access to all your notes by making the archival of your notes easy. It’s an incredibly rewarding note-taking process and it really helps you generate ideas and keep your notes in order. All of your notes in Obsidian will be markdown files, so you get all the robustness of markdown editing with some additional features that Obsidian has. The best part is, the app is totally free. It is currently only available for PC and Mac.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;a href="https://justgetflux.com/"&gt;F. lux&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3efry6nK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2A4CIs5eCl1xDgonVEglWqVA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3efry6nK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2A4CIs5eCl1xDgonVEglWqVA.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Blue light is harmful and it makes looking at your screen for long periods of time hard to do. Which is horrible if you’re a programmer because you usually have to look at your screen for extended periods of time every day. F. lux makes your screen warmer and makes it so that there isn’t as much blue light emanating from your screen, making it easier to look at your screen so that you can get your work done in comfort. It is free to install, so go nuts using it!&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;a href="https://clockify.me/developer-time-tracking"&gt;Clockify&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SPAcKqg0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AEcvCtSK5eK-kSxrh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SPAcKqg0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AEcvCtSK5eK-kSxrh.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Screenshot from clockify’s website&lt;/p&gt;

&lt;p&gt;Clockify is a time tracker that was created for developers. It lets you track how much of your time you spend doing focused work, which helps keep you on track. If you’re a freelance developer, you can use this to make sure you’re being paid properly for the hours you are putting in. Just like a normal time tracker, using Clockify lets you get an overview of your work habits so that you know if you’re spending your time the way you want to spend it.&lt;/p&gt;




&lt;p&gt;Those are my top five productivity tools for programmers and they’re all free! So go ahead install them, have fun, and keep coding!&lt;/p&gt;

&lt;p&gt;Follow me on &lt;a href="https://twitter.com/sid_dubey0312"&gt;twitter&lt;/a&gt;.&lt;br&gt;
Sign up for my &lt;a href="https://mailchi.mp/35c069691d2c/newsletter-signup"&gt;newsletter&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>vscode</category>
    </item>
    <item>
      <title>How to Make a Cross-platform Image Classifying App with Flutter and Fastai</title>
      <dc:creator>Siddhant Dubey</dc:creator>
      <pubDate>Mon, 08 Jul 2019 21:05:00 +0000</pubDate>
      <link>https://forem.com/siddhantdubey/how-to-make-a-cross-platform-image-classifying-app-with-flutter-and-fastai-5fi7</link>
      <guid>https://forem.com/siddhantdubey/how-to-make-a-cross-platform-image-classifying-app-with-flutter-and-fastai-5fi7</guid>
      <description>&lt;p&gt;&lt;a href="https://medium.com/better-programming/how-to-make-a-cross-platform-image-classifying-app-with-flutter-and-fastai-2a6af6701535?source=rss-65edcdb268ba------2"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M-NlIzP6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1249/1%2AsNNHtFJLI41fzaiG_InclA.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this article, I’ll be explaining how to use an API to build a cross-platform mobile app that uses a neural network to classify images…&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/better-programming/how-to-make-a-cross-platform-image-classifying-app-with-flutter-and-fastai-2a6af6701535?source=rss-65edcdb268ba------2"&gt;Continue reading on Better Programming »&lt;/a&gt;&lt;/p&gt;

</description>
      <category>deeplearning</category>
      <category>machinelearning</category>
      <category>android</category>
      <category>programming</category>
    </item>
    <item>
      <title>How I Used a Convolutional Neural Network to Classify Cricket Shots</title>
      <dc:creator>Siddhant Dubey</dc:creator>
      <pubDate>Sun, 30 Jun 2019 23:29:19 +0000</pubDate>
      <link>https://forem.com/siddhantdubey/how-i-used-a-convolutional-neural-network-to-classify-cricket-shots-2il3</link>
      <guid>https://forem.com/siddhantdubey/how-i-used-a-convolutional-neural-network-to-classify-cricket-shots-2il3</guid>
      <description>&lt;p&gt;&lt;a href="https://medium.com/better-programming/how-i-used-a-convolutional-neural-network-to-classify-cricket-shots-d44197e79aff?source=rss-65edcdb268ba------2"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_8B5hrCI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2600/0%2AKGV_CLuZOVfyj5XB" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have recently delved into the world of deep learning, more specifically, image classification. After completing the first lecture in the…&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/better-programming/how-i-used-a-convolutional-neural-network-to-classify-cricket-shots-d44197e79aff?source=rss-65edcdb268ba------2"&gt;Continue reading on Better Programming »&lt;/a&gt;&lt;/p&gt;

</description>
      <category>deeplearning</category>
      <category>technology</category>
      <category>datascience</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Tips and Tricks for Programming Beginners</title>
      <dc:creator>Siddhant Dubey</dc:creator>
      <pubDate>Sat, 29 Jun 2019 19:33:22 +0000</pubDate>
      <link>https://forem.com/siddhantdubey/tips-and-tricks-for-programming-beginners-840</link>
      <guid>https://forem.com/siddhantdubey/tips-and-tricks-for-programming-beginners-840</guid>
      <description>&lt;p&gt;&lt;a href="https://medium.com/@sid12.dubey/tips-and-tricks-for-programming-beginners-f22e0ce24516?source=rss-65edcdb268ba------2"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h7keYvXd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2600/0%2ArXXypb_bGBTqtUrM" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How not to lose your mind while coding&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@sid12.dubey/tips-and-tricks-for-programming-beginners-f22e0ce24516?source=rss-65edcdb268ba------2"&gt;Continue reading on Medium »&lt;/a&gt;&lt;/p&gt;

</description>
      <category>tipsandtricks</category>
      <category>programming</category>
      <category>tips</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>My Competitive Programming Journey: Week 1</title>
      <dc:creator>Siddhant Dubey</dc:creator>
      <pubDate>Tue, 25 Jun 2019 20:53:10 +0000</pubDate>
      <link>https://forem.com/siddhantdubey/my-competitive-programming-journey-week-1-19b9</link>
      <guid>https://forem.com/siddhantdubey/my-competitive-programming-journey-week-1-19b9</guid>
      <description>&lt;p&gt;I love programming. I love competition. I always have, I’ve always embraced the joy of learning that is enhanced by the feeling of competition. So when I heard about competitive programming, I was over the moon! This will detail my journey and progress through the world of Competitive Programming. Jump on the coding train with me, it's going to be a fun ride!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/media/6f0c111d5d11ef070594e20d4c348a09/href" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://medium.com/media/6f0c111d5d11ef070594e20d4c348a09/href" rel="noopener noreferrer"&gt;https://medium.com/media/6f0c111d5d11ef070594e20d4c348a09/href&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This was about a year ago, but I really didn’t take it too seriously until this summer. I had participated in some online contests and done fairly well. I even made the Gold Division in the USACO(United States of America Computing Olympiad), which is the second highest division. Throughout this 4–5 month period, I just hoped that I would progress through the ranks without doing any work at all, obviously, that isn’t the greatest idea.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F0%2AOidyN31qj865iWUO" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F0%2AOidyN31qj865iWUO"&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@clemensvanlay?utm_source=medium&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Clemens van Lay&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Competitive Programming?
&lt;/h3&gt;

&lt;p&gt;Competitive Programming is a mind sport. It consists of either individuals or teams coming up with solutions to algorithmic problems within a certain time limit. Some of the more famous programming contests are the IOI (International Olympiad of Informatics) and the ACM-ICPC ( Association for Computing Machinery — International Collegiate Programming Contest).&lt;/p&gt;

&lt;h3&gt;
  
  
  What resources am I going to use?
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Textbook:&lt;/em&gt; &lt;a href="https://www.csc.kth.se/~jsannemo/slask/main.pdf" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Principles of Algorithmic Problem Solving by Johan Sannemo&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Text Editor:&lt;/em&gt; &lt;a href="https://code.visualstudio.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Visual Studio Code&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Problem Sites&lt;/em&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://codeforces.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Codeforces&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://open.kattis.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Kattis&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cses.fi/problemset/" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;CSES&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What did I do this week?
&lt;/h3&gt;

&lt;p&gt;Alright, here’s what you clicked on the article for. Feel free to follow along at your own pace.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I went through chapter 1 and 2 in the textbook and absorbed as much as I could about C++.&lt;/li&gt;
&lt;li&gt;I learned how most Competitive Programming problems are formatted and how to cut through to the heart of the problem.&lt;/li&gt;
&lt;li&gt;I did 50 odd problems from the problem sites above.&lt;/li&gt;
&lt;li&gt;Did all the exercises in chapter 2 of the textbook.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What did I Learn?&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The format of a C++ program&lt;/li&gt;
&lt;li&gt;How to implement basic programs into C++&lt;/li&gt;
&lt;li&gt;The format of Codeforces contests&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I didn’t learn a whole lot this week due to it being mostly a refresher course on things I already knew, however, next week looks to be a completely different matter.&lt;/p&gt;

&lt;h3&gt;
  
  
  Goals for next week
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Finish at least chapter 3 in the textbook.&lt;/li&gt;
&lt;li&gt;Do 1 Codeforces contest&lt;/li&gt;
&lt;li&gt;Do 30 CSES Problems&lt;/li&gt;
&lt;li&gt;Do all the exercises in chapter 3 on Kattis.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>computerscience</category>
      <category>competitiveprogramm</category>
      <category>programming</category>
      <category>competition</category>
    </item>
    <item>
      <title>What I Learned from Trying to Make a Lie Detector Using a Neural network</title>
      <dc:creator>Siddhant Dubey</dc:creator>
      <pubDate>Mon, 24 Jun 2019 16:58:58 +0000</pubDate>
      <link>https://forem.com/siddhantdubey/what-i-learned-from-trying-to-make-a-lie-detector-using-a-neural-network-3mjh</link>
      <guid>https://forem.com/siddhantdubey/what-i-learned-from-trying-to-make-a-lie-detector-using-a-neural-network-3mjh</guid>
      <description>&lt;p&gt;&lt;a href="https://medium.com/@sid12.dubey/what-i-learned-from-trying-to-make-a-lie-detector-using-a-neural-network-b310eb94ef0?source=rss-65edcdb268ba------2" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AAFMzt73_SwlueJFf2cOU3g.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Over this weekend I tried to build a lie detector that would take the spectrogram of some audio and then decide whether it was a lie or…&lt;/p&gt;

&lt;p&gt;Over this weekend I tried to build a lie detector that would take the spectrogram of some audio and then decide whether it was a lie or not.&lt;br&gt;
Going into this experiment, I was quite convinced that there was no way this would actually work. So I did the usual, I collected my data, I cleaned it, and made a training and validation set. Now I will admit that the method of data gathering I chose, recording my voice say different truths and lies, was not the most scientific but for a home experiment, it worked fine. At this point, all I was focused on was whether or not it would work. This led me to forget the most important question. What happens if it does work?&lt;/p&gt;

&lt;p&gt;Clearly, a lie detector isn't as big of a problem as people bringing dinosaurs back to life, right? Time to answer that question, but first we have to look at the results of the experiment. I trained the network and the results were very shocking to me. It had an error rate of 0! &lt;/p&gt;

&lt;p&gt;Of course, the error rate should have been very small, considering my dataset was small, and since all of the files came from the same source. So I dismissed this as a case of overfitting.&lt;/p&gt;

&lt;p&gt;Unknowingly, my mindset had shifted from wanting this network to succeed to wanting it to fail. Why? Probably because I realized that was definitely not an ethical thing to do.&lt;/p&gt;

&lt;p&gt;Now comes the really interesting part. I fed it audio files of myself of different lies and truths, and it identified the file correctly every single time. If this was a normal neural network, I would be absolutely elated. This time, however, I felt an intense amount of apprehension.&lt;/p&gt;

&lt;p&gt;I decided to test it on other people's voices and the results were just a tiny bit better than a human guessing whether something was a lie or not. I felt a lot of relief, but why?&lt;/p&gt;

&lt;p&gt;You might be asking, why is a lie-detecting neural network a problem? I mean, polygraphs exist and those are fine.&lt;/p&gt;

&lt;p&gt;Yes, but polygraphs can't become web apps with always listen modes on. Polygraphs can't become Alexa skills to infiltrate the homes of people across the world. Polygraphs can't take in information continuously while far far away from the subject.&lt;/p&gt;

&lt;p&gt;Making neural networks do interesting tasks has become incredibly easy, but with that also comes the lack of thought as to what the network actually does. We rush to make it because of how cool it but we forget to ponder the ethics of the action.&lt;/p&gt;

&lt;p&gt;Now, this isn't a Skynet level problem, but just like all tech, neural networks can be used by elements of society that don't exactly have our best interests at heart. That's why policing AI and Machine Learning becomes so important. It would be incredibly easy for someone to wreak havoc with a seemingly harmless app if there isn't a proper way to police neural networks for harmful intent.&lt;/p&gt;

&lt;p&gt;Of course, although I overfit this version of a lie detector, other versions have been iterated by multiple researchers throughout the past and iterations will continue to be made. It isn't a question of whether we can do it, because we definitely can, it is a question of how to do it ethically.&lt;/p&gt;

&lt;p&gt;After all, humanity's moral compass is one of its finest traits.&lt;/p&gt;

</description>
      <category>philosophy</category>
      <category>machinelearning</category>
      <category>ethics</category>
      <category>dsintherealworld</category>
    </item>
  </channel>
</rss>
