<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rabia Gondur on Medium]]></title>
        <description><![CDATA[Stories by Rabia Gondur on Medium]]></description>
        <link>https://medium.com/@rabiagondur?source=rss-c96f8c8854b2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*VHlVRN_ZmH5Ane_h2hv12Q.jpeg</url>
            <title>Stories by Rabia Gondur on Medium</title>
            <link>https://medium.com/@rabiagondur?source=rss-c96f8c8854b2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 07:14:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rabiagondur/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Terminal Multiplexers, Screen or Tmux?]]></title>
            <link>https://medium.com/@rabiagondur/terminal-multiplexers-screen-or-tmux-7e757da81cf1?source=rss-c96f8c8854b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e757da81cf1</guid>
            <dc:creator><![CDATA[Rabia Gondur]]></dc:creator>
            <pubDate>Mon, 13 May 2024 19:21:55 GMT</pubDate>
            <atom:updated>2024-05-13T19:21:55.894Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*K2sw5Ss-Vw-ypvs-" /><figcaption>Photo by <a href="https://unsplash.com/@6heinz3r?utm_source=medium&amp;utm_medium=referral">Gabriel Heinzer</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Linux novices are sooner or later going to find themselves facing the black and empty wall of the elusive terminal. Sometimes due to curiosity but almost always due to necessity, the new user will navigate a confusing and ever growing web of terminal commands. And if they have to work on a server or cluster, chances are that they will need to use a terminal multiplexer. As if there weren’t enough things to learn and choices to make, the terminal user must also choose their multiplexer of choice. Thankfully there are only two main multiplexers: screen and tmux.</p><p>On the surface they might appear like the same thing, and for a novice they might as well be. I find that with these interchangeable terminal programs, a lot of the differences are not easy to understand for the new user. Try to explain the difference between bash and zsh, or vi and vim, to an unseasoned terminal user. You will have a hard time doing so. With these programs I find that if you need to ask why you should choose one over the other, it really doesn’t matter which one you choose.</p><p>However, I would rather make the right choice from the start for the sake of future proofing myself and avoiding a headache later on. So, screen or tmux?</p><p>When I first started seriously using a shared cluster to train ML models, a terminal multiplexer was a necessity. A model can be training for days, thus, without a multiplexer I would risk losing that progress if my terminal session was terminated, and I also wouldn’t be able to do anything with the cluster while the model was training. The cluster came with screen pre-installed, as I imagine is the case with most clusters and servers. So for simplicity sake I figured I should stick with screen. It wasn’t until I was searching some screen commands that I came across tmux, and I found that the popular opinion was that you should use tmux instead of screen. It was time to spend an hour trying to figure out which one to choose.</p><p>That was when I found this 2012 <a href="https://www.youtube.com/watch?v=QxTse5Elq8s&amp;t=5s">talk</a> by Jon Jensen in which he discussed this exact topic. It turns out that choosing between screen and tmux is not as hard as choosing which distro to use. You will find screen in any server or cluster, that is true. And there are probably a lot of people out there who use screen for this very reason. This is perhaps the biggest advantage of screen over tmux. Even though, screen is available everywhere and used by many people, tmux is not that far behind. A number of optimizations and quality-of-life features are what sets tmux apart from screen. A window in tmux takes up less memory than a window in screen for instance. Tmux comes with a status bar, and it uses Vi keybindings by default. It is also a better software for pair programming, as it includes features like follow-the-leader by default.</p><p>In short, even though screen is a completely capable multiplexer, tmux is more efficient and more feature-rich. Due to these advantages, tmux appears to be the most popular online, and that brings benefits in and of itself since it means that there are more people discussing tmux configs and bug fixes, which increases the likelihood you will find an answer online for a question you have on tmux. In many ways, the screen vs tmux comparison is similar to the vi vs vim comparison. Just like vi, screen is legacy software that is still widely available and used, however, just like vim, tmux is the most popular and feature-rich of the two.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e757da81cf1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring the Validity of Artificial Neural Networks; System Identification of Neural Systems: If…]]></title>
            <link>https://medium.com/@rabiagondur/exploring-the-validity-of-artificial-neural-networks-system-identification-of-neural-systems-if-953609fddc68?source=rss-c96f8c8854b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/953609fddc68</guid>
            <dc:creator><![CDATA[Rabia Gondur]]></dc:creator>
            <pubDate>Wed, 01 May 2024 16:06:06 GMT</pubDate>
            <atom:updated>2024-05-01T16:06:06.679Z</atom:updated>
            <content:encoded><![CDATA[<h3>Exploring the Validity of Artificial Neural Networks; System Identification of Neural Systems: If We Got It Right, Would We Know?</h3><p>Artificial neural networks (ANNs) have shown promise as <em>in silico</em> models to understand the complex computations in the brain. Thus, a comparison between these networks and biological recordings is crucial in validating their efficacy as representations of the brain. However, as we progress there are more and more models that can mimic the neural response accurately, yet have completely different architectures. Which brings the question: to what extent does the success of ANNs in reproducing neural responses truly validate their architectural design? A recent paper at ICML 2023, ‘System Identification of Neural Systems: If We Got It Right, Would We Know?’ by Cheung et. al (2023) investigates this very question.</p><p>Using artificial models (e.g. ANNs) to draw insights about biological models (e.g. the brain) has been ubiquitous in computational neuroscience. It is not an unknown fact that the brain is complicated, the underlying computation behind many cognitive processes requires a wide range of connections and combinations. Since we can’t directly study these phenomena in the biological model itself, using <em>in silico </em>models to study the inner workings of the brain has been helpful to us. The visual cortex areas, such as V1, V2, etc, are some of the most common regions for which you can see artificial neural networks resembling their biological counterparts. In these models we can see the predictivity of the artificial models be on par with the biological ones, showing a great promise. However, recently many researchers realized that despite the variety of model architectures, most models can predict the neural activity successfully, raising the question; Do we even know which model has the highest fidelity? In ‘System Identification of Neural Systems: If We Got It Right, Would We Know?’ by Cheung et. al (2023) they demonstrate this issue with 6 classes of models.</p><p>They use 6 ANNs: AlexNet, VGG11, ResNet18, CORnet-S, ViT-B/32, and MLP-Mixer-B/16, which all together represent a variety of different architectures (e.g. ViT-B/32 is a transformer, AlexNet is a CNN, etc.), to test how different architectures predict neural activity and whether or not their design is necessary. The main question that this paper focuses on is as follows: If we got an ANN that can accurately mimic brain, would we even know? And in Figure 1 they demonstrate this with an illustration. We have the top network which is the network that we want to replicate, e.g. the brain, and we have the bottom networks which are all the ANNs that we develop to replicate the processes in the brain. At the end we want to know if we could confidently say ‘yes, the top and bottom network in the figure give rise to same neural activity and have similar calculations. After all, we now have many neural networks that can successfully predict the neural activity yet we can’t say we replicated the brain. They demonstrate this with the different model classes they provide. We have transformer architecture, CNN architecture, MLP architecture and so on, and all of these give rise to a similar level of accuracy. What does this mean then?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*VXwckU-IyBRF7CmEt0uLNg.png" /><figcaption><a href="https://openreview.net/attachment?id=NkTEhPQCjg&amp;name=pdf">Figure 1</a>: Illustration of their research question</figcaption></figure><p>Two of the most popular methods in computational neuroscience for evaluating a system for similarity are linear regression and centered kernel alignment scores. Although there are many more methods, this paper focused on these two so we will look at the results of them for our evaluations. In Figure 2, we can see the regression score of different networks with different architectures for their ability to produce the neural response in the visual areas V1, V2, V4 and IT. The scores seem on par with each other for all the models for a given visual area, with the exception of VOneNets in V1. VOneNets were specifically designed with properties observed from neuroscience, hence why they significantly outperform other models in here. This figure overall points out one important thing, we have different architectures yet similar accuracies. Then is one model really better than the other?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*y5CEWL9BYQfbluatdf2rVw.png" /><figcaption>Figure 2: Pearson correlation coefficients of deep neural networks</figcaption></figure><p>In Figure 3 and 4, the authors make the ground truth (target) one of the 6 models, they do this one model at a time, and see how well they can be predicted by themselves and the other 5 models. In Figure 3 they look at the regression score and in Figure 4 they look at the CKA score.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pkrv6DkVCS8hVd5VbXrAoA.png" /><figcaption><a href="https://openreview.net/attachment?id=NkTEhPQCjg&amp;name=pdf">Figure 3</a>: Linear regression scores for 6 ANNs for different layers</figcaption></figure><p>In Figure 3, we can see that for three of the ANNs the ground candidate model matches with the ground truth across all the layers and for the other three, ResNet18, CORnet-S, and MLP-Mixer-B/16 it doesn&#39;t. If we look at the top right (ResNet18) for layer 0, CORnet-S or AlexNet better predict the activation of ResNet18 than ResNet18. Thus given the regression scores, we would predict the wrong model for this network. This means that not only we would guess the target net wrong but also guess the architecture of the system wrong. For example, for the top right ResNet18 graph in Figure 3, we would assume that there are recurrent connections, since CORnet-S has higher score, but in reality our ground truth model is ResNet18. In Figure 4, we are now looking at the CKA scores of the same setup. Here we can see that CKA seems to be more robust where the source network and target network match for most of the cases. This suggests system identification can be more reliable by using CKA as a measure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*omTU8sGD8NjfmThirHYWOA.png" /><figcaption><a href="https://openreview.net/attachment?id=NkTEhPQCjg&amp;name=pdf">Figure 4</a>: CKA scores for 6 ANNs for different layers</figcaption></figure><p>Lastly, they look at stimulus distribution on the results (which I omit here) but they find that this also plays an important role in the results. Specifically, they find that natural images show higher identifiability than texture and noise images for all the models.</p><p>Overall, this paper is one of many that opens up this new avenue for model testing where we need more methods to test the fidelity of our model. To create more biologically relevant models, we need to check for similarities not only in predicting the responses but also how the model operates. More engineering approaches are necessary to dissect these candidate models and understand the role of different units.</p><h3>References</h3><p><a href="https://openreview.net/attachment?id=NkTEhPQCjg&amp;name=pdf">https://openreview.net/attachment?id=NkTEhPQCjg&amp;name=pdf</a> (Han, Y., Poggio, T. A., &amp; Cheung, B. (2023, July). System identification of neural systems: If we got it right, would we know?. In <em>International Conference on Machine Learning</em> (pp. 12430–12444). PMLR.)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=953609fddc68" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Potential of Neural Networks; Universal Approximation Theorem]]></title>
            <link>https://medium.com/@rabiagondur/the-endless-potential-of-neural-networks-c093026db378?source=rss-c96f8c8854b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/c093026db378</guid>
            <dc:creator><![CDATA[Rabia Gondur]]></dc:creator>
            <pubDate>Mon, 29 Apr 2024 04:09:35 GMT</pubDate>
            <atom:updated>2024-04-29T04:09:59.591Z</atom:updated>
            <content:encoded><![CDATA[<p>Neural networks have an impressive ability to learn complex patterns and relationships in data, making them popular for a variety of fields. To me, one of the most fascinating properties of neural networks is their capability to approximate any arbitrary function, given a sufficiently large number of neurons in their hidden layers. This property is known as the Universal Approximation Theorem, which states that a feedforward neural network with a single hidden layer containing a finite number of neurons can approximate any function, given the right conditions. In this blog we will look into neural networks and their impressive power as universal approximators.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*W_lqPBNy0Ja3sn-WSk2XDQ.gif" /><figcaption>Figure 1: The evolution of neural net prediction through 500 epochs vs ground truth function</figcaption></figure><p>Neural networks are some of the most powerful tools in deep learning given their incredible capability of learning complex patterns and relationships in data. At their core, they are a combination of many affine transformations put through different non-linearity to optimize a given goal and this positions them to be great approximators of any function. Here, we will look at this behavior using the universal approximation theorem.</p><p>In 1989, George Cybenko proposed this theorem, Cybenko’s Universal Approximation Theorem, which provides a framework for understanding the expressive power of neural nets in approximating functions. This focuses on a specific type of neural net architecture with a single hidden layer where the layer contains a finite number of neurons, and each neuron applies a weighted sum of the inputs followed by a sigmoidal activation function. And at its essence, it demonstrates that, under certain conditions, neural networks can approximate any continuous function to arbitrary accuracy, given a sufficiently large number of neurons in the hidden layer and appropriate parameter tuning.</p><p>More specifically, as we can see in Figure 2, the theorem asserts that the set of all possible functions that the neural network can approximate is dense in the space of continuous functions. Meaning that for any continuous function defined on the n-dimensional unit cube, and for any small positive value ε, there exists a neural network with weights and biases chosen appropriately such that the difference between the output of the network and the true function is less than ε for all points.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tA2qB5QGQkxkfuaA6UQuww.png" /><figcaption>Figure 2: Cybenko Theorem</figcaption></figure><p>This theorem highlights the approximation capability of neural nets, elucidating their ability to represent a wide array of functions within a continuous domain. However, the process of determining the optimal parameters is far from straightforward. As I am sure you are familiar with, training a neural network involves a tricky balance between various hyperparameters, (e.g. the learning rate, batch size, epochs, etc.) yet, there is no one-size-fits-all solution, as the hyperparameter tuning depends on many things such as the specific task, dataset, etc. Thus, although neural nets can approximate a variety of functions, finding the optimal configuration still requires some experimentation.</p><p>Overall, the universal approximation theorem brings some clarity to the expressive power of neural networks, shedding light on their ability to capture complex relationships in data and approximate arbitrary functions. Knowing that, regardless of the specific function we want to approximate, as long as it is continuous and defined on the unit cube, that we can find a neural net capable of approximating it makes the power of neural nets more concrete and impressive.</p><h3>References</h3><p><a href="https://www.deep-mind.org/2023/03/26/the-universal-approximation-theorem/">The Universal Approximation Theorem</a></p><p><a href="https://www.mathematik.uni-wuerzburg.de/fileadmin/10040900/2019/Seminar__Artificial_Neural_Network__24_9__.pdf">https://www.mathematik.uni-wuerzburg.de/fileadmin/10040900/2019/Seminar__Artificial_Neural_Network__24_9__.pdf</a></p><p><a href="https://www.youtube.com/watch?v=0QczhVg5HaI">https://www.youtube.com/watch?v=0QczhVg5HaI</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c093026db378" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Choosing the Right Optimizer: A Brief Look at Adam]]></title>
            <link>https://medium.com/@rabiagondur/choosing-the-right-optimizer-a-brief-look-at-adam-bc857409ecf9?source=rss-c96f8c8854b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc857409ecf9</guid>
            <dc:creator><![CDATA[Rabia Gondur]]></dc:creator>
            <pubDate>Fri, 26 Apr 2024 21:57:53 GMT</pubDate>
            <atom:updated>2024-04-26T21:57:53.176Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>An optimizer is a crucial component in any model training process. Furthermore, with popular deep learning libraries such as PyTorch and Tensorflow, you get a variety of options for optimizers for your specific needs. Therefore, it is essential to have an intuition behind different optimizers to make informed decisions regarding model training.</blockquote><p>An optimizer is responsible for iteratively updating the parameters of a model (e.g., weights and biases in a neural network) in order to minimize a given loss function. This process involves adjusting the parameters of the model in such a way that the value of the loss function decreases over time. Currently, this is typically achieved using optimization algorithms in popular deep learning libraries, which make use of the gradient of the loss function with respect to the model parameters in an efficient way. E.g. PyTorch provides various built-in optimizers, such as Adam, SGD, etc. that implement popular optimization algorithms. Although there are many optimizers, (e.g. Adagrad, RMSprop etc.) here we will focus on 1 optimizer; Adam.</p><h3>Adam</h3><p>As you can see below, Adam has a few hyperparameters that helps you control the optimization processes. I think the best way to demonstrate its usefulness is through an example. Suppose we are training a neural network with Adam. At each iteration, we compute gradients for the parameters of the neural network with respect to a given loss function. Then we use these gradients to update the parameters according to the update rule of Adam, where this process repeats until convergence or for a fixed number of epochs.</p><p>Adam, Adaptive Moment Estimation, is a popular optimizer as it combines adaptive learning rates and momentum. Here, adaptive learning rate refers to the adjustment of the learning rate during optimization based on the magnitude of gradients, and momentum refers to accumulating gradients over time to accelerate the optimization process. They are integrated by computing moment estimates, representing the first moment and second moment of the gradients, respectively. These estimates are then bias-corrected to enhance accuracy. Subsequently, the parameters are updated using a fraction of the first moment estimate and the second moment estimate, scaled by the learning rate, hence facilitating adaptive learning rate adjustments and momentum-based optimization during training.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AgEJILpE6wAzJj3znhHDMA.png" /><figcaption><a href="https://pytorch.org/docs/stable/generated/torch.optim.Adam.html">Adam Algorithm</a></figcaption></figure><p>Staying close to the principles of Adam, AdamW, a variant of Adam, addresses the issue of weight decay in Adam by decoupling weight decay from the optimization steps. It applies weight decay directly to the parameters rather than incorporating it into the gradient updates, resulting in more stable optimization. Here I want to note that this approach differs from the traditional use of an L2 penalty (also known as weight decay). With the traditional L2 penalty, the penalty term is added directly to the loss function during gradient computation, and the optimizer adjusts the parameters accordingly during the update step. In contrast, in AdamW weight decay is applied directly to the parameters themselves, independent of the optimization updates. This means that during the optimization process, the parameters themselves are adjusted to account for the weight decay, rather than modifying the gradient updates directly.</p><p>Overall, Adam is only one of many successful optimizers and as it can be seen above, it has its own learning rule. Although this rule works in almost all cases, your model might perform better with another optimizer such as RMSprop or SGD. Similar to Adam, these algorithms will also have their own unique learning rule thus they will have different strengths.</p><h3><strong>References</strong></h3><p><a href="https://pytorch.org/docs/stable/optim.html">https://pytorch.org/docs/stable/optim.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc857409ecf9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[To zip, or not to zip, that is the question.]]></title>
            <link>https://medium.com/@rabiagondur/to-zip-or-not-to-zip-that-is-the-question-c8b92f99acba?source=rss-c96f8c8854b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8b92f99acba</guid>
            <dc:creator><![CDATA[Rabia Gondur]]></dc:creator>
            <pubDate>Tue, 16 Apr 2024 02:34:01 GMT</pubDate>
            <atom:updated>2024-04-16T02:34:01.944Z</atom:updated>
            <content:encoded><![CDATA[<h4>File retrieval is a crucial process for any machine learning task. After all, without data our models are pretty much useless. One important aspect of dealing with the data we have is how we store them. This will then automatically affect the way we access them. In this blog, we will specifically focus on images as our data type and compare the pros and cons of accessing them in zipped and unzipped formats. Finally we will do a simple access speed test to demonstrate which structure allows for faster access.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*i8rn_o9l1xv5UVOa" /><figcaption>Photo by <a href="https://unsplash.com/@beatriz_perez?utm_source=medium&amp;utm_medium=referral">Beatriz Pérez Moya</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3><strong>Zipped Files</strong></h3><p>Zip files are widely used compression format, conceived by Phil Katz in 1989. The idea behind zip files are to employ a lossless compression algorithm (deflate, which is too technical for our intents and purposes so I will omit in article) by reducing file sizes while maintaining data integrity. In turn, this allows for faster data transfer and efficient storage, allowing us to deal with large amounts of data. From my experience, since zip files are lossless compression, the amount of disk space you save by zipping a folder is not always significant (especially if your files are already compressed) but what is non trivial is the speed of transferring files from one place to another.</p><p>Regular folders consist of multiple individual files, each with its own metadata. So when transferring a folder, each file and its associated metadata must be processed individually, leading to potentially slower transfer speeds due to this increased overhead. With zips we don’t have this problem since they squeeze multiple files into a single file, thus reducing the number of operations required during transfer. With this streamlined process, we get faster transfer speeds, and we can see that this is particular prominent when we are dealing with a lot of small files.</p><h3><strong>Folders</strong></h3><p>Folders (directories) are fundamental components of file systems used in operating systems where they serve as a container for organizing and storing files and other folders in a hierarchical structure.</p><p>When transferring a folder, each file and subfolder contained within it is individually processed. Each file’s metadata, such as file name, permissions, etc. must be handled separately during the transfer process, causing slower transfer speeds. Due to all these factors, there is an increased overhead with transferring a folder compared to transferring a single compressed file like a zip file.</p><h3>Comparisons</h3><p>As we covered above, both folders and zip files have their pros and cons. But to briefly summarize, if you know that you need to move your images from one location to another, zip file is probably a better option. If you want to access them faster, storing them in a folder might be better option since you don’t have to deal with unnecessary decompression. When you are training a machine learning model, you want to access your data very fast because training within itself can be already slow, so you want to optimize every aspect of the process. Although the speed can also be influenced by many other factors, and can vary, below I will show results of a speed test that I ran with 100k images.</p><p>To run the speed test, I had a folder with 100k png images, and a zip file with 100k png images. Then with the code below, I tried to read 100k images from both the zip file and folder and got the results in Figure 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*4VzanHV92QnQwrHC-qa-sQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*HhHk8mU0BBlv20o3E56VVg.png" /><figcaption>Figure 1: Time taken to retrieve 100k images from a zip file (left). Time taken to retrieve 100k images from a folder (right)</figcaption></figure><p>Here we can see that retrieving 100k images from a folder is about 12 times faster than retrieving them from a folder. This might be due to differences in access mechanisms and data retrieval processes. In a folder each image file exists as a separate entity within the file system, allowing direct access without the need for decompression. In addition to that, there is no overhead associated with decompression before usage. On the other hand, accessing images from a zip file involves decompressing the entire archive and extracting the specific image file, which incurs CPU processing and disk I/O overhead.</p><p><strong>Code for a quick speed test;</strong></p><pre>amount = 100000 # you can modify this depending on the amount of files you want to read<br>def access_images_in_folder(folder_path):<br>    print(&#39;start&#39;)<br>    start_time = time.time()<br>   <br>    only_100k = 0<br>    for file in os.listdir(folder_path):<br>        with open(os.path.join(folder_path, file), &#39;rb&#39;) as f:<br>            only_100k +=1<br>            if only_100k &lt; amount:<br>                f.read()<br>            else:<br>                break<br>    end_time = time.time()<br>    return end_time - start_time<br><br>def access_images_in_zip(zip_file_path):<br>    start_time = time.time()<br>    only_100k = 0<br>    with zipfile.ZipFile(zip_file_path, &#39;r&#39;) as zip_ref:<br>        for file_info in zip_ref.infolist():<br>            with zip_ref.open(file_info) as f:<br>                only_100k +=1<br>                if only_100k &lt; amount:<br>                    f.read()<br>                else:<br>                    break<br>    end_time = time.time()<br>    return end_time - start_time</pre><h3><strong>References</strong></h3><p><a href="https://support.microsoft.com/en-us/windows/zip-and-unzip-files-8d28fa72-f2f9-712f-67df-f80cf89fd4e5">Zip and unzip files</a></p><p><a href="https://www.mymcpl.org/blogs/what-zip-file">https://www.mymcpl.org/blogs/what-zip-file</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8b92f99acba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Choosing the Right Image Format for Your ML Model: A transparent look at PNG file sizes]]></title>
            <link>https://medium.com/@rabiagondur/choosing-the-right-image-format-for-your-ml-model-a-transparent-look-at-png-file-sizes-0d89ffbe59b0?source=rss-c96f8c8854b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/0d89ffbe59b0</guid>
            <dc:creator><![CDATA[Rabia Gondur]]></dc:creator>
            <pubDate>Mon, 08 Apr 2024 17:36:49 GMT</pubDate>
            <atom:updated>2024-04-08T17:36:49.760Z</atom:updated>
            <content:encoded><![CDATA[<p>Image processing is a standard procedure for many deep learning tasks, yet a lot of people don’t know the difference between different image types. We process jpeg, png, tiff and many more images but do we pay attention to why do we use the image type that we use? This might be a trivial question for many of our deep learning problems but it is still good to get acquainted with some of their distinct characteristics in case we want to make more informed choices for a given task. In this blog, we will go over one of the most used image types; Portable Network Graphic (PNG). We will first briefly talk about PNG images then explore the factors influencing the size variation of PNG images based on their content.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Dzkjym2ntvJYwdVS" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The PNG file is a widely used format to train different machine learning models. PNGs offer lossless compression, a type of compression method that aims to reduce file size without sacrificing image quality. And due to this compression method, unlike JPEG files, PNG images contain more data than JPEG files.</p><h3><strong>Lossy vs Lossless Compression</strong></h3><ol><li>Lossy Compression: Lossy compression techniques are commonly found in image formats like JPEG. Lossy compression has a tradeoff between file size and image quality. So the idea behind this method is that it can achieve compression by discarding certain image details that are less essential to human perception, typically through quantization and approximation methods. The downside of this is that it inevitably leads to a loss of image fidelity, plus it can introduce some blurring. However, if you don’t mind losing some details in the images, JPEG can save you a good amount of space.</li><li>Lossless Compression: Contrary to lossy compression, goal of lossless compression techniques aim to reduce file size without sacrificing image quality. We can find this compression method in image formats like PNG. Lossless compression identifies and eliminates redundancy within the image data while preserving every pixel’s original color and detail. Because of this, if you used this method to compress your images, you can decompress it to its original format without any loss of information. However, because of the amount of detail you preserve, you won’t save as much space as you would with lossy compression.</li></ol><p>Although the difference might not seem big for many of the usual deep learning tasks, it is important to be aware of the trade-offs in case you want to put emphasis on the detail or the size of the files you are using.</p><p>Since we established the compression method behind PNG images, in this part let’s demonstrate that with an example. Imagine you have a dataset of images that are all 224 by 224, and you go back to see the size of these images. Would you guess that all would take up the same amount of space since they are all 224 by 224 or would you guess that they would vary in the amount of space they would take depending on the image we are looking at? Hopefully, if the above section between lossy vs lossless compression made sense, you would guess that regardless of the resolution of the images, if they are PNG, they will differ. Below in Figure 1 we can see 2 images (224 x 224) that look quite different. The image on the left has a lot of detail and the image on the right is very bland comparatively. Because PNG format cares about the detail captured in images, when we look at the sizes of these images, image on the left takes up 161 KB and image on the right takes up 84 KB, quite a difference!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/224/1*sXuvQXjVRquFoKlvAX-k4A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/224/1*TIaFD63GIU0Nk8GMtnrkvQ.png" /><figcaption>Figure 1: Two 224 by 224 images, larger file size (left) and smaller file size (right)</figcaption></figure><p>Overall, with this blog, I wanted to talk more about a topic that is usually not highlighted. In some sophisticated ML models, understanding the nuances of PNG images can be essential for optimizing model performance and storage efficiency. And by considering factors such as image complexity and compression level, we can make informed decisions when we select the format of our image data.</p><p><strong>References</strong></p><ul><li><a href="https://www.adobe.com/creativecloud/file-types/image/raster/png-file.html#:~:text=PNG%20is%20short%20for%20Portable,transparent%20or%20semi%2Dtransparent%20backgrounds.">What are PNG files and how do you open them? | Adobe</a></li><li><a href="https://www.adobe.com/creativecloud/file-types/image/comparison/jpeg-vs-png.html#:~:text=Because%20of%20their%20different%20compression,them%20preferred%20for%20graphic%20design.">JPEG vs. PNG: Which one should you use? | Adobe</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0d89ffbe59b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Most Distant Points; Understanding the Max-Min algorithm]]></title>
            <link>https://medium.com/@rabiagondur/most-distance-points-understanding-the-max-min-algorithm-a185d3cb73ac?source=rss-c96f8c8854b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/a185d3cb73ac</guid>
            <dc:creator><![CDATA[Rabia Gondur]]></dc:creator>
            <pubDate>Thu, 04 Apr 2024 19:02:19 GMT</pubDate>
            <atom:updated>2024-06-04T03:41:27.013Z</atom:updated>
            <content:encoded><![CDATA[<h4>Given a search objective, there are several options that one may pick. One of these being carefully selecting a subset of points to start the initial search with (global search) and later on adding an additional step for more targeted search (local search). In this blog, I won’t be focusing on the search objective, instead we will look into sampling the data space in a way that we can get an even representations of the data. What does that mean? This means that we want to make sure that we are looking at as much as the dataset manifold as we can when we are searching a space rather than accidentally getting stuck at a local optimum.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*IE3vg5MdTFBzIJ3Sd4_ySw.gif" /><figcaption>An illustration of curating a core set of 5 points</figcaption></figure><p>Given a dataset, it may seem trivial to find the most distant set of points. However, it can be very useful to get a sense of the values and relationships of datapoints all around the data manifold. Despite its utility, finding the most distant points might not be as straightforward as one might think. Let’s demonstrate this with an example; You have 100 datapoints and you calculated the Euclidean distance matrix for this dataset, thus now you have 100 x 100 matrix consisting of distances. E.g. if you pull one row of this matrix, you will get this points distance with all the other points in the dataset, and this will be of shape 1x 100. First we can randomly get a datapoint to be our initial starting point, and getting the next point for our coreset will be straightforward as we can just look at all the distances for this point and get the most distant one. Now this is where it gets tricky, how do you get the 3rd point? Or the 4th and so on? There isn’t one way to go about this but the one I will talk about is the max-min approach.</p><p>Given 2 datapoints that are as far away from each other as possible, the third point needs to be a datapoint that is far away from both of these datapoints equally. But what happens if the data point that is the most distant from point1 and point2 is not the same? This is where the max-min algorithm comes in. If the datapoint that is maximally distant from both of our points is different, we can instead maximize the minimum distance. This might sound confusing so let’s demonstrate with an example;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*VHRMgKGTH-Xwgwi83HRf2w.png" /><figcaption>Figure 1: Example dataset</figcaption></figure><p>Here we can see that we have 9 datapoints and our goal is to create a coreset that consists of 3 points. The first thing we can do is to pick a starting point, this is arbitrary so let’s pick the point below;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*ackkvl899GdVtQ2jKSYiIQ.png" /><figcaption>Figure 2: Picking a starting point</figcaption></figure><p>After this we can check all the distances between our starting point (red) and the rest of the dataset (black dots). This will give us a list of of distances and from here we can pick the next point as the datapoint with the largest distance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*pE7Bx5ncFML26pGCYf0V4A.png" /><figcaption>Figure 3: Selecting the second point</figcaption></figure><p>How do we get the 3rd point now? It is easy if we check all the distances for the x_1red and x_2red and find that the point that is most distant from x_1red and x_2red is the same. But most likely, this won’t be the case;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*DuVMOzRPV9NaM1Db2tdQKA.png" /><figcaption>Figure 4: Possible candidates for the 3rd point in our coreset</figcaption></figure><p>This is where the max-min approach comes in handy. Here we will first check the distances from each of our datapoints in our coreset (red dots) to all the other points in the dataset. Below we can see the possible distances we consider for each of our coreset points. Please note that for illustration purposes some of the lines are bent but in reality we are looking at a linear distance between datapoints, such as the euclidean distance;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z3fD9zqDhyBNxYCIoh1eQg.png" /><figcaption>Figure 5: Distances from x_coreset1 to all other datapoints</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e7YJGo1YxcSZIKr-LxKxpg.png" /><figcaption>Figure 6: Distances from x_coreset2 to all other datapoints</figcaption></figure><p>After listing all the distances, we will now check the minimum distance for each datapoint, that is, we will look at all the black dots one by one and see which coreset value has the shortest distance;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S1gAuR0ivZn_QywTnv8llQ.png" /><figcaption>Figure 7: Given a datapoint we check its distance from the coreset points</figcaption></figure><p>Here we are looking at a particular point and its distance from our coreset points. To highlight this, I colored the distances in purple. Now we will get the minimum out of both;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qf2V0Hxfvv-CKlXrFF24Ow.png" /><figcaption>Figure 8: Given a datapoint we check its distance from the coreset points and save the minimum</figcaption></figure><p>In Figure 8, we can see that after checking the distances we conclude that the coreset point on the top has a shorter distance to this point than the coreset point on the bottom. Now we need to do this for every point in the dataset and we get the following figure, where only the minimum distances are highlighted;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cefmiDUhvqOXXEBV-1Esgw.png" /><figcaption>Figure 9: Minimum saved distances</figcaption></figure><p>Since we saved all these minimum distances, now we will go through the list and get the largest distance out of the list and use this point as our 3rd coreset point! (the pink line with the largest distance)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rFsgKNzkGbiRUrGl9ErTBQ.jpeg" /><figcaption>Figure 10: Adding the next point to our coreset</figcaption></figure><p>Why does this work? In other words, how do we know that this 3rd coreset point is the most distant point from all of our previous coreset points? By selecting all the minimum distances for each datapoint and getting the largest one out of all those minimum distances, we ensure that the final selected point will be the one most equally distant from all the other points in the coreset.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a185d3cb73ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A primer on Principal Component Analysis; PCA]]></title>
            <link>https://medium.com/@rabiagondur/a-primer-on-principal-component-analysis-pca-fa0c0bec6e66?source=rss-c96f8c8854b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa0c0bec6e66</guid>
            <category><![CDATA[linear-algebra]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[pca-analysis]]></category>
            <category><![CDATA[principal-component]]></category>
            <dc:creator><![CDATA[Rabia Gondur]]></dc:creator>
            <pubDate>Tue, 05 Mar 2024 23:29:48 GMT</pubDate>
            <atom:updated>2024-03-05T23:29:48.861Z</atom:updated>
            <content:encoded><![CDATA[<p>Most often the data we collect is high-dimensional in nature, rendering it hard for us to understand and extract useful information from it. A natural solution to this is to first apply a dimensionality reduction to this given data and then do the further analysis. One of the most widely-available and used dimensionality reduction methods is Principal Component Analysis, PCA. PCA is a linear dimensionality reduction method that was invented by Karl Pearson in 1901 and since then has been a fundamental method for extracting the lower dimensional structure from high-dimensional complex data. Here we will look into the math behind PCA, and get an intuition behind its processes using Bishop’s <a href="https://www.microsoft.com/en-us/research/uploads/prod/2006/01/Bishop-Pattern-Recognition-and-Machine-Learning-2006.pdf"><em>Pattern Recognition and Machine Learning</em></a> as our guide.</p><h3><strong>High-level idea</strong></h3><p>The most important intuition in any of the dimensionality reduction methods is realizing that not all high-dimensional data needs all of its components to represent itself, what does that mean? It means that we might have an image that is 100x100 pixels, 10,000 dimensional space, but might need &lt;10,000 dimensions to represent that image. Below we can see images of the digit ‘3’ which is 100x100. Here we see that all of these 3s look very similar with the only things varying between them being the rotation and horizontal and vertical translations. Thus, we can say that although these 3s are 10,000 dimensional, the intrinsic dimensionality of them is 3, corresponding to 2 translations and 1 rotation. Another way of thinking about this is through a matrix perspective. If we have a 10,000 dimensional matrix with rank 3, that means we can express any column in this matrix with our original 3, making the rest redundant. (Note; this is not exactly what’s happening in PCA but it has a similar intuition).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uFIcdA9WGWEMTvbnmMXeDQ.png" /><figcaption>Figure 12.1 Taken from p.g. 560 of Pattern Recognition and Machine Learning by Bishop</figcaption></figure><p>In the figure below we can see how exactly we can represent our original high-dimensional data points, x_n (red dots), in a lower-dimensional line, u_1 (the magenta line, also known as the principal subspace). There are two ways to project our data onto a lower dimensional space; 1) through maximizing the variance of the projected data. 2) through minimizing the sum-of-squares between our original data (red dots) and projected data (green dots). Both of these lead to the same algorithm but here I will focus on number 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*duo7c5tkDc4VOBcUdHBGMw.png" /><figcaption>Figure 12.2 Taken from p.g. 561 of Pattern Recognition and Machine Learning by Bishop</figcaption></figure><h3>Maximum Variance Formulation</h3><p>Borrowing the classic setup from Bishop, let’s consider we have a dataset of our observations {x_n}, where we have n=1,2,3,…N observations and the dimensionality of our data x_n to be D. We want to project our data onto a space, M, that is lower dimensional than our original such that M&lt;D while maximizing the variance of the projected data. There are several ways on deciding the appropriate dimensionality for our M but for this example let’s assume we know that M equals to 1. We will define the direction of this space using u_1, dimensionality of D x M, and we will constrain this to be a unit vector such that (u_1)^T(u_1) = 1. We then project our data onto its lower dimensional scalar representation via (u_1)^T(x_n) where the first term is of dimension M x D and the second term is of dimension D x 1, making our lower dimensional scalar representation to be of dimension M x 1. For the rest of this blog, we will denote this representation with z.</p><p>The mean of our projected data, z, will be;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/132/1*7XWwPJhR_Rr-xYraKyUC9g.png" /><figcaption>p.g. 562 of Pattern Recognition and Machine Learning by Bishop</figcaption></figure><p>where x^bar is the sample set mean given by;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*qoV_fpYU2BuuVMp_HagHxA.png" /><figcaption>Equation 12.1 Taken from p.g. 562 of Pattern Recognition and Machine Learning by Bishop</figcaption></figure><p>and the variance of the projected data will be;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*5R4vsecYd30PB45Hsyixrw.png" /><figcaption>Equation 12.2 Taken from p.g. 562 of Pattern Recognition and Machine Learning by Bishop</figcaption></figure><p>where S is the covariance matrix defined by;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*erm-PUXUEDsiGXolgmqujw.png" /><figcaption>Equation 12.3 Taken from p.g. 562 of Pattern Recognition and Machine Learning by Bishop</figcaption></figure><p>Let’s unpack these. Starting with the most straightforward one, the mean of the projected data is the dot product of the unit vector (u_1) and the sample set mean value (x^bar). And as a reminder, this unit vector (u_1) represents a specific direction. Thus by taking the dot product of u_1 and x^bar, we effectively compute the average position of the projected data points along the direction represented by u_1. For the variance, this quantifies the spread of the data points along the direction defined by u_1 so that we can see how much the data varies when projected onto this direction. The most important part of the variance equation is S which is our covariance matrix. This will give us the pairwise covariances between the different features of the dataset and it is very crucial for PCA as we will soon see that the eigenvectors of the covariance matrix represent the directions of maximum variance and the eigenvalues represent the amount of variance captured along each principal component.</p><p>Since it is our objective to maximize the projected variance, we need to set the variance of the projected data to 0 and take the derivative with respect to u_1. However, as we mentioned before, this needs to be a constrained optimization so that (u_1)^T(u_1) = 1. We will use Lagrange multiplier to enforce this constraint by setting up our equation as below. Here note that we re-organize (u_1)^T(u_1) = 1 by moving (u_1)^T(u_1) to the right side so we have 0 = 1-(u_1)^T(u_1) and then multiply our new quantity by the Lagrange multiplier lambda (λ).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*pl0Bn--59Wmq49EBZo-RYQ.png" /><figcaption>Equation 12.4 Taken from p.g. 562 of Pattern Recognition and Machine Learning by Bishop</figcaption></figure><p>Now we can take the derivative of the above equation with respect to u_1 and we get;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*f_cUSo3KBCXjPSQSFH3v9Q.png" /><figcaption>Equation 12.5 Taken from p.g. 562 of Pattern Recognition and Machine Learning by Bishop</figcaption></figure><p>You might see that this is the same familiar form of Av = λv where for our square matrix A, v must be the eigenvector of A and λ is the eigenvalue. This means that u is the eigenvector of S (our covariance matrix) and λ is its eigenvalue. Now if we re-arrange this equation, by using the property of (u_1)^T(u_1) = 1, we get;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*VWIOEzs5kALeJZTejhH-RQ.png" /><figcaption>Equation 12.6 Taken from p.g. 562 of Pattern Recognition and Machine Learning by Bishop</figcaption></figure><p>If you think this looks familiar too you are right, this is our variance equation! This effectively shows that variance will be maximum when we pick the eigenvector with the largest eigenvalue. This was for a simple 1- dimensional projection space so if we try to generalize this to an M-dimensional projection space the optimal linear projection with maximum variance can be defined by the M eigenvectors u_1, . . . , u_M of the covariance matrix S corresponding to the M largest eigenvalues λ_1, . . . , λ_M.</p><h3>Takeaways</h3><p>PCA is a fundamental method in statistical analysis and machine learning. It is one of the most useful tools for data visualization, and dimensionality reduction. Here we covered the maximum variance formulation of PCA and showed that eigenvectors with the largest eigenvalues maximize our variance. In essence, as we identify each principal component, we make sure that it captures as much variability as possible while being orthogonal to the previously identified components.</p><h3>References</h3><p><a href="https://www.sciencedirect.com/topics/agricultural-and-biological-sciences/principal-component-analysis#:~:text=PCA%20was%20invented%20in%201901,the%20modeling%20of%20response%20data.">https://www.sciencedirect.com/topics/agricultural-and-biological-sciences/principal-component-analysis#:~:text=PCA%20was%20invented%20in%201901,the%20modeling%20of%20response%20data.</a></p><p><a href="https://www.microsoft.com/en-us/research/uploads/prod/2006/01/Bishop-Pattern-Recognition-and-Machine-Learning-2006.pdf">https://www.microsoft.com/en-us/research/uploads/prod/2006/01/Bishop-Pattern-Recognition-and-Machine-Learning-2006.pdf</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa0c0bec6e66" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mental simulations; How do we predict?]]></title>
            <link>https://medium.com/@rabiagondur/mental-simulations-how-do-we-predict-fedc801111ab?source=rss-c96f8c8854b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/fedc801111ab</guid>
            <dc:creator><![CDATA[Rabia Gondur]]></dc:creator>
            <pubDate>Mon, 12 Feb 2024 17:22:55 GMT</pubDate>
            <atom:updated>2024-02-12T17:22:55.354Z</atom:updated>
            <content:encoded><![CDATA[<h4>We have a flexible view of the world, where we keep track of the constantly evolving dynamics of our surroundings and update our beliefs accordingly. Thus, our brains have the unique ability to simulate the outcome of many potential scenarios internally without explicitly being trained on them (i.e. without prior exposure). One of the dominant theories in the area that can explain this is mental simulation. Mental simulation is our ability to think ahead the outcome of an event before it even occurs. Given an event, this allows us the consider many possible scenarios and select the most optimal one. In ‘<em>Neural Foundations of Mental Simulation: Future Prediction of Latent Representations on Dynamic Scenes’ </em>by Nayebi et al. (2023), the authors explored the basis of mental simulations in artificial and biological networks and compared the activations of these networks and how they effect the behavioral outcome. Here, I will share my thoughts on their work.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uM7MV-ypkDEwYM11" /><figcaption>Photo by <a href="https://unsplash.com/@siderius_creativ?utm_source=medium&amp;utm_medium=referral">Gerard Siderius</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>Mental Simulation</strong></p><p>Our ability to seamlessly draw rich inferences in constantly evolving environments and think ahead of different scenarios has been a much sought after topic. Contrary to many artificial networks, our brains have enormous ability to adapt to different environments and perform tasks in novel settings. Hence, understanding the basis of mental simulations can help us understand the underlying mechanisms behind our adaptability and swift inference capabilities. However despite the interest in the inner works of this phenomenon, we still do not know how it happens, and if we see a similar pattern in artificial neural networks. To test this, the authors propose a comparison of diverse set of foundation models to test and evaluate mental simulation in relation to behavior predictivity and neural response matching.</p><p><strong>Foundation Models</strong></p><p>This paper focused on several foundation models; Image foundation models (pre-trained on static scenes) and Video foundation models (pre-trained on dynamic scenes). The neural network architectures range from convolutional neural networks (CNNs), e.g. VGG16, ResNet-50, to Vision Transformers (ViT), e.g. DINOv2, CLIP.</p><p><strong>Experiments</strong></p><p>The authors evaluate the performance of the foundation models in two-folds;</p><ol><li>Comparison to human behavior in Physion Object Contact Prediction (OCP) task.</li><li>Comparison to neural response in a novel environment, Mental-Pong, to check the generalizability and adaptability of the model.</li></ol><p>An important part of their experiments is that the models were never trained on Mental-Pong, thus it is completely new to all of these models. This novel environment mimics the human experience as we are constantly exposed to different environments and have to transfer our knowledge to new tasks without needing extra information. Thus, I find the evaluations from this out-of-distribution environment to be the most promising.</p><p><strong>Results/Takeaways</strong></p><p>Overall, this paper focuses on revealing the underlying mechanics of future predictions via a close comparison of a variety of foundation models.</p><p>They find that end-to-end self-supervised future prediction models best matched the human behavior in the ‘Physion Object Contact Prediction (OCP)’ task. Contrary to this, for the neural data, they find that the models that best match the neural responses are the latent self-supervised future prediction models where the predictive performance increases if the model was pre-trained on diverse range of tasks.</p><p>These findings allude that foundation models (specifically latent future prediction) trained on diverse set of dynamic scenes are promising in terms of their ability to adapt to dynamics in a novel environment compared to image foundation models.</p><p><strong>References</strong></p><p>Nayebi, A., Rajalingham, R., Jazayeri, M., &amp; Yang, G. R. (2023). Neural Foundations of Mental Simulation: Future Prediction of Latent Representations on Dynamic Scenes. <em>arXiv preprint arXiv:2305.11772</em>.</p><p>Rajalingham, R., Sohn, H., &amp; Jazayeri, M. (2022). Dynamic tracking of objects in the macaque dorsomedial frontal cortex. <em>bioRxiv</em>, 2022–06.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fedc801111ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deep Learning; Getting Started with PyTorch]]></title>
            <link>https://medium.com/@rabiagondur/deep-learning-getting-started-with-pytorch-6f32a0422f4e?source=rss-c96f8c8854b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f32a0422f4e</guid>
            <dc:creator><![CDATA[Rabia Gondur]]></dc:creator>
            <pubDate>Sat, 13 Jan 2024 15:02:16 GMT</pubDate>
            <atom:updated>2024-01-13T15:02:41.178Z</atom:updated>
            <content:encoded><![CDATA[<p>In the world of deep learning, PyTorch is one of the most popular deep learning libraries for researchers and machine learning enthusiast in the field. Due to its more Pythonic nature, PyTorch is easy to use and can be used for many deep learning tasks. In this article, we will look at the very basics of PyTorch; the fundamental data structure of PyTorch, different data types, and mathematical operations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FXCW4NyslCWg5riG" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The most fundamental data structure of PyTorch and many deep learning libraries is a tensor. Tensor is a multi-dimensional array that can represent things like vectors, matrices, or higher-dimensional arrays. To create a tensor in PyTorch we can use <strong>torch.tensor()</strong>. In the example below we can see how to create a scalar, vector, and matrix using <strong>torch.tensor()</strong>, note that regardless of whether these objects are a matrix or a scalar, it is important to remember that they are still of tensor datatype.</p><pre>example_scalar = torch.tensor(16)<br>example_vector = torch.tensor([16,12])<br>example_matrix = torch.tensor([[16,12],[10,11]])</pre><p>Even though we didn’t cover neural networks yet, an important part of training deep neural networks is knowing the shape of these tensors that you are working with. When we cover convolutional neural networks (CNNs) in the future articles, you will understand how the right shapes of tensors can interfere with your training if not specified correctly. To check the shape of a given tensor we can either use <strong>.shape</strong> attribute or<strong> .size() </strong>method. You can use either of them to get the shapes of your tensors as they serve the same purpose, the only difference is one of them is an attribute (<strong>.shape</strong>) so it doesn’t require the parentheses and the other one (<strong>.size()</strong>) does because it is a method.</p><pre>print(example_vector.shape)<br>print(example_vector.size())</pre><p>Another important part of PyTorch is the tensor data types, which we can have access to via <strong>.dtype</strong>. This will decide how your tensors are stored in your computer memory and can be crucial depending on the amount of precision you need for your task. The default data type is <em>torch.float32</em> which represents 32-bit floating-point numbers and it is generally used for training neural networks. In my experience the second most used one that you will come across is <em>torch.float64</em> (also known as <em>torch.double)</em> which as the name implies represents 64-bit floating-point numbers. The reason why this one is not the default is because although it provides higher precision than <em>torch.float32</em>, it also requires more memory and computation which can be expensive. Thus, using 32 bits allows for a compromise between precision and memory while providing sufficient precision for many tasks. Although these are the most popular ones, there are many more tensor data types you can use, which you can find it <a href="https://pytorch.org/docs/stable/tensors.html#torch.Tensor">here</a>.</p><pre>print(example_vector.dtype)</pre><p>If you need to change the data type of a given variable, you can do so via <strong>.to()</strong> method. Similar to shape of a tensor, tensor datatype can also cause a lot of interference with your regular workflow if you don’t pay attention, so those too are always good to check whenever you run into any issues for a quick sanity check.</p><pre>changed_example = example_vector.to(torch.float64)</pre><p>Lastly, I want to talk about broadcasting which allows for element-wise mathematical operations between tensors of different shapes by expanding the smaller tensor to match the larger one. For example, if you have a tensor of size (2,3) and another tensor of (1,3), normally you wouldn’t be able to do any element wise operations due to incompatible shapes. However, because of broadcasting, in PyTorch you can multiply these two tensors and get the result. In the below example, the result will equal to tensor([[ 1, 4, 9], [ 4, 10, 18]]) where we multiply tensor2 element-wise with all the rows of tensor1. This can be helpful but again getting back to my earlier point on shapes, if you are not careful you might end up doing an operation that you didn’t intend on doing and not get an error.</p><pre>tensor1 = torch.tensor([[1, 2, 3], [4, 5, 6]])<br>tensor2 = torch.tensor([[1,2,3]])<br><br>result = tensor1 * tensor2<br>print(result)</pre><p>There are many other important things that I didn’t cover here but I hope that these can get you started and also make you be able to manage some of the finicky errors that you might get while dealing with PyTorch data structures.</p><p><strong>References:</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FZ_ikDlimN6A%3Fstart%3D63354%26feature%3Doembed%26start%3D63354&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DZ_ikDlimN6A&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FZ_ikDlimN6A%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/efc06a8dcc1ec0e40e4be7488f1d19ec/href">https://medium.com/media/efc06a8dcc1ec0e40e4be7488f1d19ec/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FBzcBsTou0C0%3Flist%3DPLQVvvaa0QuDdeMyHEYc0gxFpYwHY2Qfdh&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DBzcBsTou0C0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FBzcBsTou0C0%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/75b4a578adfaa8ec92bd59a2ac73e912/href">https://medium.com/media/75b4a578adfaa8ec92bd59a2ac73e912/href</a></iframe><ul><li><a href="https://pytorch.org/docs/stable/tensors.html#torch.Tensor">torch.Tensor - PyTorch 2.1 documentation</a></li><li><a href="https://pytorch.org/docs/stable/generated/torch.Tensor.size.html">torch.Tensor.size - PyTorch 2.1 documentation</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f32a0422f4e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>