{
  "source_file": "0930",
  "source_platform": "Medium",
  "author": "Muhammad Ardi Putra",
  "title_listed": "YOLOv1 Paper Walkthrough: The Day YOLO First Saw the World",
  "keywords": "",
  "domain": "图像处理",
  "content_type": "深度技术解析",
  "is_paid_flag": "否",
  "url": "https://towardsdatascience.com/yolov1-paper-walkthrough-the-day-yolo-first-saw-the-world/",
  "publish_date": "2025-12-05",
  "corpus_stage": "",
  "notes": "",
  "id": "03e30b6796ac",
  "collected_at": "2026-10-02T02:34:56",
  "title": "YOLOv1 Paper Walkthrough: The Day YOLO First Saw the World | Towards Data Science",
  "body_markdown": "![Revisit consent button](../images/body-df29beacd7496220cc94.svg)\nWe value your privacy\nWe use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking \"Accept All\", you consent to our use of cookies.\nCustomise Reject All Accept All\nCustomise Consent Preferences ![](../images/body-2159bb67f3de8ad870eb.svg)\nWe use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.\nThe cookies that are categorised as \"Necessary\" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... Show more\nNecessaryAlways Active\nNecessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.\n  * Cookie\nBCTempID\n  * Duration\n10 minutes\n  * Description\nNo description available.\n\n\n  * Cookie\n__cf_bm\n  * Duration\n1 hour\n  * Description\nThis cookie, set by Cloudflare, is used to support Cloudflare Bot Management. \n\n\n  * Cookie\nAWSALBCORS\n  * Duration\n7 days\n  * Description\nAmazon Web Services set this cookie for load balancing.\n\n\n  * Cookie\n_cfuvid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to track users across sessions to optimize user experience by maintaining session consistency and providing personalized services\n\n\n  * Cookie\nli_gc\n  * Duration\n6 months\n  * Description\nLinkedin set this cookie for storing visitor's consent regarding using cookies for non-essential purposes.\n\n\n  * Cookie\n__hssrc\n  * Duration\nsession\n  * Description\nThis cookie is set by Hubspot whenever it changes the session cookie. The __hssrc cookie set to 1 indicates that the user has restarted the browser, and if the cookie does not exist, it is assumed to be a new session.\n\n\n  * Cookie\n__hssc\n  * Duration\n1 hour\n  * Description\nHubSpot sets this cookie to keep track of sessions and to determine if HubSpot should increment the session number and timestamps in the __hstc cookie.\n\n\n  * Cookie\nwpEmojiSettingsSupports\n  * Duration\nsession\n  * Description\nWordPress sets this cookie when a user interacts with emojis on a WordPress site. It helps determine if the user's browser can display emojis properly.\n\n\n  * Cookie\nBCSessionID\n  * Duration\n1 year 1 month 4 days\n  * Description\nBlueconic sets this cookie as a unique identifier for the BlueConic profile.\n\n\n  * Cookie\n_octo\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nlogged_in\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\n__Secure-YEC\n  * Duration\npast\n  * Description\nYouTube sets this cookie to stores the user's video player preferences using embedded YouTube video\n\n\n  * Cookie\n__eoi\n  * Duration\n6 months\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTGCORS\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\nlogin-status-p\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTG\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\ncsrf_token\n  * Duration\nsession\n  * Description\nNo description available.\n\n\n  * Cookie\ntoken_v2\n  * Duration\n1 day\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nD\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nPHPSESSID\n  * Duration\nsession\n  * Description\nThis cookie is native to PHP applications. The cookie stores and identifies a user's unique session ID to manage user sessions on the website. The cookie is a session cookie and will be deleted when all the browser windows are closed.\n\n\n  * Cookie\nVISITOR_PRIVACY_METADATA\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to store the user's cookie consent state for the current domain. \n\n\n  * Cookie\ncookietest\n  * Duration\nsession\n  * Description\nThe cookietest cookie is typically used to determine whether the user's browser accepts cookies, essential for website functionality and user experience.\n\n\n  * Cookie\n__Host-airtable-session\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\n__Host-airtable-session.sig\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\nm\n  * Duration\n1 year 1 month 4 days\n  * Description\nStripe sets this cookie for fraud prevention purposes. It identifies the device used to access the website, allowing the website to be formatted accordingly.\n\n\n  * Cookie\nBIGipServer*\n  * Duration\nsession\n  * Description\nMarketo sets this cookie to collect information about the user's online activity and build a profile about their interests to provide advertisements relevant to the user. \n\n\n  * Cookie\n__cfruid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to identify trusted web traffic.\n\n\n  * Cookie\n_GRECAPTCHA\n  * Duration\n6 months\n  * Description\nGoogle Recaptcha service sets this cookie to identify bots to protect the website against malicious spam attacks.\n\n\n  * Cookie\n__Secure-YNID\n  * Duration\n6 months\n  * Description\nGoogle cookie used to protect user security and prevent fraud, especially during the login process.\n\n\n  * Cookie\ncookieyes-consent\n  * Duration\n1 year\n  * Description\nCookieYes sets this cookie to remember users' consent preferences so that their preferences are respected on subsequent visits to this site. It does not collect or store any personal information about the site visitors.\n\n\nFunctional\nFunctional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.\n  * Cookie\nlidc\n  * Duration\n1 day\n  * Description\nLinkedIn sets the lidc cookie to facilitate data center selection.\n\n\n  * Cookie\nbrw\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nbrwConsent\n  * Duration\n5 minutes\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nWMF-Uniq\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nloom_anon_comment\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nloom_referral_video\n  * Duration\nsession\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nVISITOR_INFO1_LIVE\n  * Duration\n6 months\n  * Description\nA cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.\n\n\n  * Cookie\nyt-remote-connected-devices\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nytidb::LAST_RESULT_ENTRY_KEY\n  * Duration\nNever Expires\n  * Description\nThe cookie ytidb::LAST_RESULT_ENTRY_KEY is used by YouTube to store the last search result entry that was clicked by the user. This information is used to improve the user experience by providing more relevant search results in the future.\n\n\n  * Cookie\nyt-remote-device-id\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-name\n  * Duration\nsession\n  * Description\nThe yt-remote-session-name cookie is used by YouTube to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\nyt-remote-fast-check-period\n  * Duration\nsession\n  * Description\nThe yt-remote-fast-check-period cookie is used by YouTube to store the user's video player preferences for embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-app\n  * Duration\nsession\n  * Description\nThe yt-remote-session-app cookie is used by YouTube to store user preferences and information about the interface of the embedded YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-available\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-available cookie is used to store the user's preferences regarding whether casting is available on their YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-installed\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-installed cookie is used to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\ncp_session\n  * Duration\n3 months\n  * Description\nCodepen sets this cookie for Help systems found in the website.\n\n\n  * Cookie\nloid\n  * Duration\n1 year 1 month 4 days\n  * Description\nThis cookie is set by the Reddit. The cookie enables the sharing of content from the website onto the social media platform.\n\n\nAnalytics\nAnalytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.\n  * Cookie\n__hstc\n  * Duration\n6 months\n  * Description\nHubspot set this main cookie for tracking visitors. It contains the domain, initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session).\n\n\n  * Cookie\nhubspotutk\n  * Duration\n6 months\n  * Description\nHubSpot sets this cookie to keep track of the visitors to the website. This cookie is passed to HubSpot on form submission and used when deduplicating contacts.\n\n\n  * Cookie\n_ga\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors.\n\n\n  * Cookie\n_ga_*\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to store and count page views.\n\n\n  * Cookie\n__Host-psifi.analyticsTrace\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n__Host-psifi.analyticsTraceV2\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n_gh_sess\n  * Duration\nsession\n  * Description\nGitHub sets this cookie for temporary application and framework state between pages like what step the user is on in a multiple step form.\n\n\n  * Cookie\nYSC\n  * Duration\nsession\n  * Description\nYSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.\n\n\n  * Cookie\najs_anonymous_id\n  * Duration\n1 year\n  * Description\nThis cookie is set by Segment to count the number of people who visit a certain site by tracking if they have visited before.\n\n\n  * Cookie\nvuid\n  * Duration\n1 year 1 month 4 days\n  * Description\nVimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. \n\n\nPerformance\nPerformance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.\n  * Cookie\nAWSALB\n  * Duration\n7 days\n  * Description\nAWSALB is an application load balancer cookie set by Amazon Web Services to map the session to the target.\n\n\n  * Cookie\nacq\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nacq.sig\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nptc\n  * Duration\n2 years\n  * Description\nNo description available.\n\n\nAdvertisement\nAdvertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.\n  * Cookie\nmuc_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to collect user behaviour and interaction data to optimize the website.\n\n\n  * Cookie\nguest_id_marketing\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\nguest_id_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\npersonalization_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to integrate and share features for social media and also store information about how the user uses the website, for tracking and targeting.\n\n\n  * Cookie\nguest_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor. It registers if a user is signed in to the Twitter platform and collects information about ad preferences.\n\n\n  * Cookie\nbcookie\n  * Duration\n1 year\n  * Description\nLinkedIn sets this cookie from LinkedIn share buttons and ad tags to recognize browser IDs.\n\n\n  * Cookie\n__Secure-ROLLOUT_TOKEN\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to manage feature rollout and experimentation. It helps Google control which new features or interface changes are shown to users as part of testing and staged rollouts, ensuring consistent experience for a given user during an experiment.\n\n\n  * Cookie\nyt.innertube::nextId\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nyt.innertube::requests\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nsession_tracker\n  * Duration\nsession\n  * Description\nThis cookie is set by the Reddit. This cookie is used to identify trusted web traffic. It also helps in adverstising on the website.\n\n\n  * Cookie\nedgebucket\n  * Duration\nsession\n  * Description\nReddit sets this cookie to save the information about a log-on Reddit user, for the purpose of advertisement recommendations and updating the content.\n\n\n  * Cookie\ndid\n  * Duration\n1 year\n  * Description\nArbor sets this cookie to show targeted ads to site visitors.This cookie expires after 2 months or 1 year.\n\n\nUncategorised\nOther uncategorised cookies are those that are being analysed and have not been classified into a category as yet.\nNo cookies to display.\nReject All Save My Preferences Accept All\nToggle Search[](https://towardsdatascience.com/)Toggle Mobile Navigation\n[](https://towardsdatascience.com/)\nPublish AI, ML & data-science insights to a global community of data professionals.\nSign in[Submit an Article](https://write.insightmediagroup.io)\n[Latest](https://towardsdatascience.com/latest/)[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Newsletter](https://towardsdatascience.com/tag/the-variable/)[ShipAI](https://towardsdatascience.com/shipai/)\n* * *\n[Write For TDS](https://towardsdatascience.com/submissions/)\n[LinkedIn](https://www.linkedin.com/company/towards-data-science/)[X](https://x.com/TDataScience)Toggle Search\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\n# YOLOv1 Paper Walkthrough: The Day YOLO First Saw the World\nA detailed walkthrough of the YOLOv1 architecture and its PyTorch implementation from scratch\n[Muhammad Ardi Putra](https://towardsdatascience.com/author/muhammad_ardi/)\nDecember 5, 202517 min read\n![](../images/000.jpg)\nPhoto by Hassan on [Unsplash](https://unsplash.com/photos/a-toy-robot-sitting-on-top-of-a-wooden-table-MFYmMBUEkmQ)\n## Introduction\nIf we talk about object detection, one model that likely comes to our mind first is YOLO — well, at least for me, thanks to its popularity in the field of computer vision.\nThe very first version of this model, referred to as YOLOv1, was released back in 2015 in the research paper titled “ _You Only Look Once: Unified, Real-Time Object Detection”_ [1]. Before YOLOv1 was invented, one of the state-of-the-art algorithms for performing object detection was R-CNN (Region-based Convolutional Neural Network), in which it uses multi-stage mechanism to do the task. It initially employs selective search algorithm to create region proposal, then uses CNN-based model to extract the features within all these regions, and finally classifies the detected objects using SVM [2]. Here you can clearly imagine how long the process is just to perform object detection on a single image.\nThe motivation of YOLO in the first place was to improve speed. In fact, not only achieving low computational complexity, but the authors proved that their proposed deep learning model was also able to achieve high accuracy. As this article is written, YOLOv13 has just published several days ago [3]. But let’s just talk about its very first ancestor for now so that you can see the beauty of this model starting from the time it first came out. This article is going to discuss how YOLOv1 works and how to build this neural network architecture from scratch with PyTorch.\n···\nLearn this step by step with the interactive [AI Engineer](https://roadmap.sh/ai-engineer) roadmap.\n## The Underlying Theory Behind YOLOv1\nBefore we get into the architecture, it would be better if we understand the idea behind YOLOv1 in advance. Let’s start with an example. Suppose we have a picture of a cat, and we are about to use it as a training sample of a YOLOv1 model. And so, we need to create a ground truth for that. It is mentioned in the original paper that we need to define the parameter _S_ , which denotes the number of grid cells we are going to divide our image into along each spatial dimension. By default, this parameter is set to 7, so we will have 7×7=49 cells in total. Take a look at Figure 1 below to better understand this idea.\n![](../images/001.png)\nFigure 1. What the image looks like after being divided into uniform-sized grid cells. The cell (3, 3) is responsible to store the information about the cat [4].\nNext, we need to determine which cell corresponds to the midpoint of the object. In the above case, the cat is located almost exactly at the center of the image, hence the midpoint must lie at cell (3, 3). Later in the inference phase, we can think of this cell as the one responsible to predict the cat. Now taking a closer look at the cell, we need to determine the exact position of the midpoint. Here you can see that along the vertical axis it is located exactly in the middle, but in the horizontal axis it is slightly shifted to the left from the middle. So, if I were to approximate, the coordinate would be (0.4, 0.5). This coordinate value is relative to the cell and is normalized to the range of 0 to 1. It might be worth noting that the (_x_ , _y_) coordinate of the midpoint should neither be less than 0 nor greater than 1, since a value outside this range would mean the midpoint lies in another cell. Meanwhile, the width _w_ and the height _h_ of the bounding box are approximately 2.4 and 3.2, respectively. These numbers are relative to the cell size, meaning that if the object is bigger than the cell, then the value will be greater than 1. Later on, if we were to create a ground truth for an image, we need to store all these _x_ , _y_ , _w_ and _h_ information in the so-called _target vector_.\n### Target Vector\nThe length of the target vector itself is 25 for each cell, in which the first 20 elements (index 0 to 19) store the class of the object in form of one-hot encoding. This is essentially because YOLOv1 was originally trained on PASCAL VOC dataset which has that number of classes. Next, index 20 is used to store the confidence of the bounding box prediction, which in the training phase this is set to 1 whenever there is an object midpoint within the cell. Lastly, the (_x_ , _y_) coordinate of the midpoint are placed at indices 21 and 22, whereas _w_ and _h_ are stored at indices 23 and 24. The illustration in Figure 2 below displays what the target vector for cell (3, 3) looks like.\n![](../images/body-0f58dd9de55f4f1ed35f.png)\nFigure 2. The target vector for cell (3, 3) of the image in Figure 1 [5].\nAgain, remember that the above target vector only corresponds to a single cell. To create the ground truth for the entire image, we need to have a bunch of similar vectors concatenated, forming the so-called _target tensor_ as shown in Figure 3. Note that the class probabilities as well as the bounding box confidences, locations, and sizes from all other cells are set to zero because there is no other object appearing within the image.\n![](../images/body-a55b138d552ad4c9e90a.png)\nFigure 3. How all target vectors from each cell are concatenated. This entire tensor will act as the ground truth of a single image [5].\n### Prediction Vector\nThe _prediction vector_ is quite a bit different. If the target vector consists of 25 elements, the prediction vector consists of 30. This is because by default YOLOv1 predicts two bounding boxes for the same object during inference. Thus, we need 5 additional elements to store the information about the second bounding box generated by the model. Despite predicting two bounding boxes, later we will only take the one that has greater confidence.\n![](../images/body-941827f783919008a56f.png)\nFigure 4. The prediction vector has 5 additional elements dedicated for the second bounding box (highlighted in orange) [5].\nThis unique target and prediction vector dimensions required the authors to rethink the loss function. For regression problems, we typically use MAE, MSE or RMSE, whereas for classification tasks we usually use cross entropy loss. But YOLOv1 is more than just a regression and classification problem, considering that we have both continuous (bounding box) and discrete (class) values in the vector representation. Thanks to this reason, the authors created a new loss function specialized for this model as shown in Figure 5. This loss function is quite complex (you see, right?), so I decided to write it in a separate article because there are lots of things to explain about it — stay tuned, I’ll publish it very soon.\n![](../images/body-08911c15a607e8332fa9.png)\nFigure 5. The loss function of YOLOv1 [1].\n···\n## The YOLOv1 Architecture\nJust like typical earlier computer vision models, YOLOv1 uses CNN-based architecture as the backbone of the model. It comprises 24 convolution layers stacked according to the structure in Figure 6. If you take a closer look at the figure, you will notice that the output layer produces a tensor of shape 30×7×7. This dimension indicates that every single cell has its corresponding prediction vector of length 30 containing the class and the bounding box information of the detected object, in which this matches exactly with our previous discussion.\n![](../images/body-a19bca61c198af811992.png)\nFigure 6. The architecture of YOLOv1 [1].\nWell, I think I’ve covered all the fundamentals of YOLOv1, so now let’s start implementing the architecture from scratch with PyTorch. Before doing anything, what we need to do first is to import the required modules and initialize the parameters _S_ , _B_ , and _C_. See Codeblock 1 below.\npython\n\n```\n# Codeblock 1\nimport torch\nimport torch.nn as nn\n\nS = 7\nB = 2\nC = 20\n```\n\nThe three parameters I initialized above are the default values given in the paper, in which `S` represents the number of grid cells along the horizontal and vertical axes, `B` denotes the number of bounding boxes generated by each cell, and `C` is the number of classes available in the dataset. Since we use `S=7` and `B=2`, our YOLOv1 will produce7×7×2=98 bounding boxes in total for each image.\n### The Building Block\nNext, we are going to create the `ConvBlock` class, in which it contains a single convolution layer (line `#(1)`), a leaky ReLU activation function (`#(2)`), and an optional maxpooling layer (`#(3)`) as shown in Codeblock 2.\npython\n\n```\n# Codeblock 2\nclass ConvBlock(nn.Module):\n    def __init__(self, \n                 in_channels, \n                 out_channels, \n                 kernel_size, \n                 stride, \n                 padding, \n                 maxpool_flag=False):\n        super().__init__()\n        self.maxpool_flag = maxpool_flag\n        \n        self.conv = nn.Conv2d(in_channels=in_channels,       #(1)\n                              out_channels=out_channels, \n                              kernel_size=kernel_size, \n                              stride=stride, \n                              padding=padding)\n        self.leaky_relu = nn.LeakyReLU(negative_slope=0.1)   #(2)\n        \n        if self.maxpool_flag:\n            self.maxpool = nn.MaxPool2d(kernel_size=2,       #(3)\n                                        stride=2)\n            \n    def forward(self, x):\n        print(f'original\\t: {x.size()}')\n\n        x = self.conv(x)\n        print(f'after conv\\t: {x.size()}')\n        \n        x = self.leaky_relu(x)\n        print(f'after leaky relu: {x.size()}')\n        \n        if self.maxpool_flag:\n            x = self.maxpool(x)\n            print(f'after maxpool\\t: {x.size()}')\n        \n        return x\n```\n\nIn modern architectures, we normally use the _Conv-BN-ReLU_ structure, but at the time YOLOv1 was created, it seems like batch normalization layer was not quite popular just yet, as it came out only several months before YOLOv1. So, I guess this is probably the reason that the authors did not utilize this normalization layer. Instead, it only uses a stack of convolutions and leaky ReLUs throughout the entire network.\nJust a quick refresher, leaky ReLU is an activation function similar to the standard ReLU, except that the negative values are multiplied with a small number instead of being zeroed out. In the case of YOLOv1, we set the multiplier to 0.1 (`#(2)`) so that it can still preserve a little bit amount of information contained in the negative input numbers.\n![](../images/body-793f04919546724339a7.png)\nFigure 7. ReLU vs Leaky ReLU activation functions [6].\nAs the `ConvBlock` class has been defined, now I am going to test it just to check if it works properly. In Codeblock 3 below I try to implement the very first layer in the network and pass a dummy tensor through it. You can see in the codeblock that `in_channels` is set to 3 (`#(1)`) and `out_channels` is set to 64 (`#(2)`) because we want this initial layer to accept an RGB image as the input and return a 64-channel image. The size of the kernel is 7×7 (`#(3)`), hence we need to set the padding to 3 (`#(5)`). Normally, this configuration allows us to preserve the spatial dimension of the image, but since we use `stride=2` (`#(4)`), this padding size ensures that the image is exactly halved. Next, if you go back to Figure 6, you will notice that some conv layers are followed by a maxpooling layer and some others are not. Since the first convolution utilizes a maxpooling layer, we need to set the `maxpool_flag` parameter to `True` (`#(6)`).\npython\n\n```\n# Codeblock 3\nconvblock = ConvBlock(in_channels=3,       #(1)\n                      out_channels=64,     #(2)\n                      kernel_size=7,       #(3)\n                      stride=2,            #(4)\n                      padding=3,           #(5)\n                      maxpool_flag=True)   #(6)\nx = torch.randn(1, 3, 448, 448)            #(7)\nout = convblock(x)\n```\n\nAfterwards, we can simply generate a tensor of random values with the dimension of 1×3×448×448 (`#(7)`) which simulates a batch of a single RGB image of size 448×448 and then pass it through the network. You can see in the resulting output below that our convolution layer successfully increased the number of channels to 64 and halved the spatial dimension to 224×224. The halving was done once again all the way to 112×112 thanks to the maxpooling layer.\nmarkup\n\n```\n# Codeblock 3 Outputoriginal         : torch.Size([1, 3, 448, 448])after conv       : torch.Size([1, 64, 224, 224])after leaky relu : torch.Size([1, 64, 224, 224])after maxpool    : torch.Size([1, 64, 112, 112])\n```\n\n### The Backbone\nThe next thing we are going to do is to create a sequence of `ConvBlocks` to build the entire backbone of the network. In case you’re still not familiar with the term _backbone_ , in this case it is essentially everything before the two fully-connected layers (refer to Figure 6). Now look at the Codeblock 4a and 4b below to see how I define the `Backbone` class.\npython\n\n```\n# Codeblock 4a\nclass Backbone(nn.Module):\n    def __init__(self):\n        super().__init__()\n        # in_channels, out_channels, kernel_size, stride, padding, maxpool_flag\n        self.stage0 = ConvBlock(3, 64, 7, 2, 3, maxpool_flag=True)      #(1)\n        self.stage1 = ConvBlock(64, 192, 3, 1, 1, maxpool_flag=True)    #(2)\n        \n        self.stage2 = nn.ModuleList([\n            ConvBlock(192, 128, 1, 1, 0), \n            ConvBlock(128, 256, 3, 1, 1), \n            ConvBlock(256, 256, 1, 1, 0),\n            ConvBlock(256, 512, 3, 1, 1, maxpool_flag=True)      #(3)\n        ])\n        \n        \n        self.stage3 = nn.ModuleList([])\n        for _ in range(4):\n            self.stage3.append(ConvBlock(512, 256, 1, 1, 0))\n            self.stage3.append(ConvBlock(256, 512, 3, 1, 1))\n            \n        self.stage3.append(ConvBlock(512, 512, 1, 1, 0))\n        self.stage3.append(ConvBlock(512, 1024, 3, 1, 1, maxpool_flag=True))  #(4)\n        \n        \n        self.stage4 = nn.ModuleList([])\n        for _ in range(2):\n            self.stage4.append(ConvBlock(1024, 512, 1, 1, 0))\n            self.stage4.append(ConvBlock(512, 1024, 3, 1, 1))\n        \n        self.stage4.append(ConvBlock(1024, 1024, 3, 1, 1))\n        self.stage4.append(ConvBlock(1024, 1024, 3, 2, 1))    #(5)\n        \n        \n        self.stage5 = nn.ModuleList([])\n        self.stage5.append(ConvBlock(1024, 1024, 3, 1, 1))\n        self.stage5.append(ConvBlock(1024, 1024, 3, 1, 1))\n```\n\nWhat we do in the above codeblock is to instantiate `ConvBlock` instances according to the architecture given in the paper. There are several things I want to emphasize here. First, the term _stage_ I use in the code is not explicitly mentioned in the paper. However, I decided to use that word to describe the six groups of convolutional layers in Figure 6. Second, notice that we need to set the `maxpool_flag` to `True` for the last `ConvBlock` in the first four groups to perform spatial downsampling (`#(1–4)`). For the fifth group, the downsampling is done by setting the stride of the last convolution layer to 2 (`#(5)`). Third, Figure 6 does not mention the padding size of the convolution layers, so we need to calculate them manually. There is indeed a specific formula to find padding size based on the given kernel size. However, I feel like it is much easier to memorize it. Just keep in mind that if we use kernel of size 7×7, then we need to set the padding to 3 to preserve the spatial dimension. Meanwhile, for 5×5, 3×3 and 1×1 kernels, the padding should be set to 2, 1, and 0, respectively.\nAs all layers in the backbone have been instantiated, we can now connect them all using the `forward()` method below. I don’t think I need to explain anything here since it basically only works by passing the input tensor `x` through the layers sequentially.\npython\n\n```\n# Codeblock 4b\n    def forward(self, x):\n        print(f'original\\t: {x.size()}\\n')\n        \n        x = self.stage0(x)\n        print(f'after stage0\\t: {x.size()}\\n')\n        \n        x = self.stage1(x)\n        print(f'after stage1\\t: {x.size()}\\n')\n        \n        for i in range(len(self.stage2)):\n            x = self.stage2[i](x)\n            print(f'after stage2 #{i}\\t: {x.size()}')\n        \n        print()\n        for i in range(len(self.stage3)):\n            x = self.stage3[i](x)\n            print(f'after stage3 #{i}\\t: {x.size()}')\n        \n        print()\n        for i in range(len(self.stage4)):\n            x = self.stage4[i](x)\n            print(f'after stage4 #{i}\\t: {x.size()}')\n        \n        print()\n        for i in range(len(self.stage5)):\n            x = self.stage5[i](x)\n            print(f'after stage5 #{i}\\t: {x.size()}')\n            \n        return x\n```\n\nNow let’s verify if our implementation is correct by running the following testing code.\npython\n\n```\n# Codeblock 5\nbackbone = Backbone()\nx = torch.randn(1, 3, 448, 448)\nout = backbone(x)\n```\n\nIf you try to run the above codeblock, the following output should appear on your screen. Here you can see that the spatial dimension of the image correctly got reduced after the last `ConvBlock` of each stage. This process continued all the way to the last stage until eventually we obtained a tensor of size 1024×7×7, in which this matches exactly with the illustration in Figure 6.\nmarkup\n\n```\n# Codeblock 5 Outputoriginal        : torch.Size([1, 3, 448, 448])after stage0    : torch.Size([1, 64, 112, 112])after stage1    : torch.Size([1, 192, 56, 56])after stage2 #0 : torch.Size([1, 128, 56, 56])after stage2 #1 : torch.Size([1, 256, 56, 56])after stage2 #2 : torch.Size([1, 256, 56, 56])after stage2 #3 : torch.Size([1, 512, 28, 28])after stage3 #0 : torch.Size([1, 256, 28, 28])after stage3 #1 : torch.Size([1, 512, 28, 28])after stage3 #2 : torch.Size([1, 256, 28, 28])after stage3 #3 : torch.Size([1, 512, 28, 28])after stage3 #4 : torch.Size([1, 256, 28, 28])after stage3 #5 : torch.Size([1, 512, 28, 28])after stage3 #6 : torch.Size([1, 256, 28, 28])after stage3 #7 : torch.Size([1, 512, 28, 28])after stage3 #8 : torch.Size([1, 512, 28, 28])after stage3 #9 : torch.Size([1, 1024, 14, 14])after stage4 #0 : torch.Size([1, 512, 14, 14])after stage4 #1 : torch.Size([1, 1024, 14, 14])after stage4 #2 : torch.Size([1, 512, 14, 14])after stage4 #3 : torch.Size([1, 1024, 14, 14])after stage4 #4 : torch.Size([1, 1024, 14, 14])after stage4 #5 : torch.Size([1, 1024, 7, 7])after stage5 #0 : torch.Size([1, 1024, 7, 7])after stage5 #1 : torch.Size([1, 1024, 7, 7])\n```\n\n### The Fully-Connected Layers\nAfter the backbone is done, we can now move on to the fully-connected part, which I write in Codeblock 6 below. This part of the network is very simple as it mainly only consists of two linear layers. Speaking of the details, it is mentioned in the paper that the authors apply a dropout layer with the rate of 0.5 (`#(3)`) between the first (`#(1)`) and the second (`#(4)`) linear layers. It is important to note that the leaky ReLU activation function is still used (`#(2)`) but only after the first linear layer. This is because the second one acts as the output layer, hence it does not require any activation applied to it.\npython\n\n```\n# Codeblock 6\nclass FullyConnected(nn.Module):\n    def __init__(self):\n        super().__init__()\n        \n        self.linear0 = nn.Linear(in_features=1024*7*7, out_features=4096)   #(1)\n        self.leaky_relu = nn.LeakyReLU(negative_slope=0.1)                  #(2)\n        self.dropout = nn.Dropout(p=0.5)                                    #(3)\n        self.linear1 = nn.Linear(in_features=4096, out_features=(C+B*5)*S*S)#(4)\n    \n    def forward(self, x):\n        print(f'original\\t: {x.size()}')\n        \n        x = self.linear0(x)\n        print(f'after linear0\\t: {x.size()}')\n        \n        x = self.leaky_relu(x)\n        x = self.dropout(x)\n        \n        x = self.linear1(x)\n        print(f'after linear1\\t: {x.size()}')\n        \n        return x\n```\n\nRun the Codeblock 7 below to see how the tensor transforms as it is processed by the stack of linear layers.\npython\n\n```\n# Codeblock 7\nfc = FullyConnected()\nx = torch.randn(1, 1024*7*7)\nout = fc(x)\n```\n\nmarkup\n\n```\n# Codeblock 7 Outputoriginal      : torch.Size([1, 50176])after linear0 : torch.Size([1, 4096])after linear1 : torch.Size([1, 1470])\n```\n\nWe can see in the above output that the `fc` block takes an input of shape 50176, which is essentially the flattened 1024×7×7 tensor. The `linear0` layer works by mapping this input into 4096-dimensional vector, and then the `linear1` layer eventually maps it further to 1470. Later in the post-processing stage we need to reshape it to 30×7×7 so that we can take the bounding box and the object classification results easily. Technically speaking, this reshaping process can be done either internally by the model or outside the model. For the sake of simplicity, I decided to leave the output flattened, meaning the reshaping will be handled externally.\n### Connecting the FC Part to the Backbone\nAt this point we already have our backbone and the fully-connected layers done. Thus, they are now ready to be assembled to construct the entire YOLOv1 architecture. There is not much thing I can explain regarding the following code, as what we do here is only instantiating both parts and connect them in the `forward()` method. Just don’t forget to flatten (`#(1)`) the output of `backbone` to make it compatible with the input of the `fc` block.\npython\n\n```\n# Codeblock 8\nclass YOLOv1(nn.Module):\n    def __init__(self):\n        super().__init__()\n        \n        self.backbone = Backbone()\n        self.fc = FullyConnected()\n        \n    def forward(self, x):\n        x = self.backbone(x)\n        x = torch.flatten(x, start_dim=1)    #(1)\n        x = self.fc(x)\n        \n        return x\n```\n\nIn order to test our model, we can simply instantiate the `YOLOv1` model and pass a dummy tensor that simulates an RGB image of size 448×448 (`#(1)`). After feeding the tensor into the network (`#(2)`), I also try to simulate the post-processing step by reshaping the output tensor to 30×7×7 as shown at line `#(3)`.\npython\n\n```\n# Codeblock 9\nyolov1 = YOLOv1()\nx = torch.randn(1, 3, 448, 448)      #(1)\n\nout = yolov1(x)                      #(2)\nout = out.reshape(-1, C+B*5, S, S)   #(3)\n```\n\nAnd below is what the output looks like after the code above is run. Here you can see that our input tensor successfully flows through all layers within the entire network, indicating that our YOLOv1 model works properly and thus is ready to train.\nmarkup\n\n```\n# Codeblock 9 Outputoriginal        : torch.Size([1, 3, 448, 448])after stage0    : torch.Size([1, 64, 112, 112])after stage1    : torch.Size([1, 192, 56, 56])after stage2 #0 : torch.Size([1, 128, 56, 56])after stage2 #1 : torch.Size([1, 256, 56, 56])after stage2 #2 : torch.Size([1, 256, 56, 56])after stage2 #3 : torch.Size([1, 512, 28, 28])after stage3 #0 : torch.Size([1, 256, 28, 28])after stage3 #1 : torch.Size([1, 512, 28, 28])after stage3 #2 : torch.Size([1, 256, 28, 28])after stage3 #3 : torch.Size([1, 512, 28, 28])after stage3 #4 : torch.Size([1, 256, 28, 28])after stage3 #5 : torch.Size([1, 512, 28, 28])after stage3 #6 : torch.Size([1, 256, 28, 28])after stage3 #7 : torch.Size([1, 512, 28, 28])after stage3 #8 : torch.Size([1, 512, 28, 28])after stage3 #9 : torch.Size([1, 1024, 14, 14])after stage4 #0 : torch.Size([1, 512, 14, 14])after stage4 #1 : torch.Size([1, 1024, 14, 14])after stage4 #2 : torch.Size([1, 512, 14, 14])after stage4 #3 : torch.Size([1, 1024, 14, 14])after stage4 #4 : torch.Size([1, 1024, 14, 14])after stage4 #5 : torch.Size([1, 1024, 7, 7])after stage5 #0 : torch.Size([1, 1024, 7, 7])after stage5 #1 : torch.Size([1, 1024, 7, 7])original        : torch.Size([1, 50176])after linear0   : torch.Size([1, 4096])after linear1   : torch.Size([1, 1470])torch.Size([1, 30, 7, 7])\n```\n\n···\n## Ending\nIt might be worth noting that all the codes I show you throughout this entire article is for the base YOLOv1 architecture. It is mentioned in the paper that the authors also proposed the lite version of this model which they refer to as _Fast YOLO_. This smaller YOLOv1 version offers faster computation time as it only consists of 9 convolution layers instead of 24. Unfortunately, the paper does not provide the implementation details, so I cannot demonstrate you how to implement that one.\nHere I encourage you to play around with the above code. In theory, it is possible to replace the CNN-based backbone with other deep learning models, such as ResNet, ResNeXt, ViT, etc. All you need to do is just to match the output shape of the backbone with the input shape of the fully-connected part. Not only that, I also want you to try training this model from scratch. But if you decided to do so, you might probably want to make this model smaller by reducing the depth (no of convolution layers) or the width (no of kernels) of the model. This is essentially because the authors mentioned that they required around a week just to do the pretraining on ImageNet dataset, not to mention the time for fine tuning on the object detection task.\nAnd well, I think that’s pretty much everything I can explain you about how YOLOv1 works and its architecture. Please let me know if you spot any mistake in this article. Thank you!\n_By the way, the code used in this article is also available on my GitHub repo [7]._\n···\n## References\n[1] Joseph Redmon _et al._ You Only Look Once: Unified, Real-Time Object Detection. Arxiv. <https://arxiv.org/pdf/1506.02640> [Accessed July 5, 2025].\n[2] Ross Girshick _et al._ Rich feature hierarchies for accurate object detection and semantic segmentation. Arxiv. <https://arxiv.org/pdf/1311.2524> [Accessed July 5, 2025].\n[3] Mengqi Lei _et al._ YOLOv13: Real-Time Object Detection with Hypergraph-Enhanced Adaptive Visual Perception. Arxiv. <https://arxiv.org/abs/2506.17733> [Accessed July 5, 2025].\n[4] Image generated by author with Gemini, edited by author.\n[5] Image originally created by author.\n[6] Bing Xu _et al._ Empirical Evaluation of Rectified Activations in Convolutional Network. Arxiv. <https://arxiv.org/pdf/1505.00853> [Accessed July 5, 2025].\n[7] MuhammadArdiPutra. The Day YOLO First Saw the World — YOLOv1. GitHub. <https://github.com/MuhammadArdiPutra/medium_articles/blob/main/The%20Day%20YOLO%20First%20Saw%20the%20World%20-%20YOLOv1.ipynb> [Accessed July 7, 2025].\n## Register Now to Continue Reading\n### Unlock Towards Data Science with a Free Account\nAll articles on Towards Data Science are available to registered users. Create a free account today to access this article and thousands more.\nRegister for freeSign in to your account\n* * *\n![](../images/body-59e1c17daab1fcb582c5.jpeg)\nWritten By\n## [Muhammad Ardi Putra](https://towardsdatascience.com/author/muhammad_ardi/)\nDeep learning storyteller\n[See all from Muhammad Ardi Putra](https://towardsdatascience.com/author/muhammad_ardi/)\n[Deep Dives](https://towardsdatascience.com/tag/deep-dives/)[Deep Learning](https://towardsdatascience.com/tag/deep-learning/)[Object Detection](https://towardsdatascience.com/tag/object-detection/)[Python](https://towardsdatascience.com/tag/python/)[Yolo](https://towardsdatascience.com/tag/yolo/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Fyolov1-paper-walkthrough-the-day-yolo-first-saw-the-world%2F&title=YOLOv1%20Paper%20Walkthrough%3A%20The%20Day%20YOLO%20First%20Saw%20the%C2%A0World)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Fyolov1-paper-walkthrough-the-day-yolo-first-saw-the-world%2F&title=YOLOv1%20Paper%20Walkthrough%3A%20The%20Day%20YOLO%20First%20Saw%20the%C2%A0World)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Fyolov1-paper-walkthrough-the-day-yolo-first-saw-the-world%2F&text=YOLOv1%20Paper%20Walkthrough%3A%20The%20Day%20YOLO%20First%20Saw%20the%C2%A0World)\n\n\nTowards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program.\n[Write for TDS](https://towardsdatascience.com/submissions/)\n## Related Articles\n  * [![](../images/002.jpeg)](https://towardsdatascience.com/data-analysis-series-an-overview-of-fifa-19-players-dataset-e995ea33dd29/)\n## [Data Analysis Series: An Overview of FIFA 19 Players Dataset](https://towardsdatascience.com/data-analysis-series-an-overview-of-fifa-19-players-dataset-e995ea33dd29/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nIntro\n[Efe Buyuk](https://towardsdatascience.com/author/efebuyuk/)\nNovember 24, 20204 min read\n  * [![](../images/003.png)](https://towardsdatascience.com/breaking-down-the-support-vector-machine-svm-algorithm-d2c030d58d42/)\n## [Breaking Down the Support Vector Machine (SVM) Algorithm](https://towardsdatascience.com/breaking-down-the-support-vector-machine-svm-algorithm-d2c030d58d42/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nSo, I was revising machine learning algorithms yesterday; and I observed that SVM is probably a widely used but complicated machine...\n[Satyam Mishra](https://towardsdatascience.com/author/tensorslow/)\nOctober 29, 20205 min read\n  * [![](../images/004.png)](https://towardsdatascience.com/understanding-causal-trees-920177462149/)\n## [Understanding Causal Trees](https://towardsdatascience.com/understanding-causal-trees-920177462149/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nCAUSAL DATA SCIENCE How to use regression trees to estimate heterogeneous treatment effects In causal...\n[Matteo Courthoud](https://towardsdatascience.com/author/matteo.courthoud/)\nFebruary 3, 202315 min read\n  * [![](../images/005.png)](https://towardsdatascience.com/ai-safety-how-do-you-prevent-adversarial-attacks-ede17480a24d-2/)\n## [AI Safety - How Do you Prevent Adversarial Attacks?](https://towardsdatascience.com/ai-safety-how-do-you-prevent-adversarial-attacks-ede17480a24d-2/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nA quick chat with IBM researchers Pin-Yu and Sijia about their recent papers with the two concepts of 'Pruning' and 'Block Changing'\n[Alex Moltzau](https://towardsdatascience.com/author/alexmoltzau/)\nAugust 15, 20190 min read\n  * [![](../images/006.jpeg)](https://towardsdatascience.com/7-ways-to-manipulate-pandas-dataframes-f5ec03fe944c/)\n## [7 Ways to Manipulate Pandas Dataframes](https://towardsdatascience.com/7-ways-to-manipulate-pandas-dataframes-f5ec03fe944c/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nPandas offer a great deal of flexibility.\n[Soner Yıldırım](https://towardsdatascience.com/author/sonery/)\nSeptember 11, 20204 min read\n  * [![](../images/007.jpg)](https://towardsdatascience.com/introduction-to-marketing-mix-modeling-in-python-d0dd81f4e794/)\n## [Introduction to Marketing Mix Modeling in Python](https://towardsdatascience.com/introduction-to-marketing-mix-modeling-in-python-d0dd81f4e794/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nWhich advertising spendings are really driving your sales?\n[Robert Kübler](https://towardsdatascience.com/author/dr-robert-kuebler/)\nSeptember 22, 20218 min read\n  * [![](../images/008.jpeg)](https://towardsdatascience.com/multi-head-attention-formally-explained-and-defined-89dc70ce84bd/)\n## [Multi-Head Attention - Formally Explained and Defined](https://towardsdatascience.com/multi-head-attention-formally-explained-and-defined-89dc70ce84bd/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nA comprehensive and detailed formalization of multi-head attention.\n[Jean Meunier-Pion](https://towardsdatascience.com/author/jmpion/)\nJune 11, 20249 min read\n  * [![](../images/009.jpg)](https://towardsdatascience.com/install-custom-python-libraries-from-private-pypi-on-databricks-6a7669f6e6fd/)\n## [Install custom Python Libraries from private PyPI on Databricks](https://towardsdatascience.com/install-custom-python-libraries-from-private-pypi-on-databricks-6a7669f6e6fd/)\n[](https://towardsdatascience.com/yolov1-paper-walkthrough-the-day-yolo-first-saw-the-world/)\nStep by step guide on how to integrate your private PyPI repositories on Databricks clusters.\n[David Suarez](https://towardsdatascience.com/author/dsu4rez/)\nOctober 4, 202110 min read\n  * [![](../images/010.jpg)](https://towardsdatascience.com/create-a-surfing-web-app-34da6201f57e/)\n## [Create a Surfing Web App](https://towardsdatascience.com/create-a-surfing-web-app-34da6201f57e/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nHow python can help you find the perfect surfboard Businesses pay astronomical amounts on data...\n[Nikki Smit](https://towardsdatascience.com/author/nikkismit10/)\nMay 28, 20215 min read\n\n\n  * [YouTube](https://www.youtube.com/c/TowardsDataScience)\n  * [X](https://x.com/TDataScience)\n  * [LinkedIn](https://www.linkedin.com/company/towards-data-science/)\n  * [Threads](https://www.threads.net/@towardsdatascience)\n  * [Bluesky](https://bsky.app/profile/towardsdatascience.com)\n\n\n[](https://towardsdatascience.com/)\nYour home for data science and AI. The world's leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.\nSubscribe to Our Newsletter[Write For TDS](https://towardsdatascience.com/submissions/)•[About](https://towardsdatascience.com/about-towards-data-science-d691af11cc2f/)•[Advertise](https://contact.towardsdatascience.com/advertise-with-towards-data-science)•[Privacy Policy](https://towardsdatascience.com/privacy-policy/)•[Terms of Use](https://towardsdatascience.com/website-terms-of-use/)\n© Insight Media Group, LLC 2026•[The New Stack](https://thenewstack.io)•[roadmap.sh](https://roadmap.sh)•[Creator Network](https://insightmediagroup.io/creator-network)\n####  Recommended Articles \nClose\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500) How Relevance Models Foreshadowed Transformers for NLP ](https://towardsdatascience.com/how-relevance-models-foreshadowed-transformers-for-nlp/ \"How Relevance Models Foreshadowed Transformers for NLP\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500) Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1 ](https://towardsdatascience.com/javascript-fatigue-you-dont-need-js-to-build-chatgpt/ \"Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500) The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs ](https://towardsdatascience.com/subset-sum-problem-solved-in-linear-time-for-dense-enough-inputs/ \"The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500) Does Your Company Have a Data Strategy? ](https://towardsdatascience.com/does-your-company-have-a-data-strategy-e8944dbec4ae/ \"Does Your Company Have a Data Strategy?\")\n\n\n",
  "metadata": {
    "title": "YOLOv1 Paper Walkthrough: The Day YOLO First Saw the World | Towards Data Science",
    "description": "A detailed walkthrough of the YOLOv1 architecture and its PyTorch implementation from scratch",
    "keywords": null,
    "author": "Muhammad Ardi Putra",
    "og:locale": "en_US",
    "og:type": "article",
    "og:title": "YOLOv1 Paper Walkthrough: The Day YOLO First Saw the World",
    "og:description": "A detailed walkthrough of the YOLOv1 architecture and its PyTorch implementation from scratch",
    "og:url": "https://towardsdatascience.com/yolov1-paper-walkthrough-the-day-yolo-first-saw-the-world/",
    "og:site_name": "Towards Data Science",
    "og:image": "https://assets.insightmediagroup.io/media/wp-content/uploads/2025/12/hassan-MFYmMBUEkmQ-unsplash-scaled-1.jpg",
    "og:image:width": "2560",
    "og:image:height": "1440",
    "og:image:type": "image/jpeg",
    "twitter:card": "summary_large_image",
    "twitter:site": "@TDataScience",
    "twitter:creator": "@TDataScience",
    "twitter:label1": "Written by",
    "twitter:data1": "Muhammad Ardi Putra",
    "twitter:label2": "Est. reading time",
    "twitter:data2": "17 min read",
    "article:published_time": "2025-12-05T09:00:08.000Z",
    "article:modified_time": "2025-12-05T09:00:08.000Z",
    "article:author": "https://towardsdatascience.com/author/muhammad_ardi/"
  },
  "paywall": {
    "listed_paid": false,
    "detected": false,
    "marker": "",
    "public_only": false,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 202,
    "error": ""
  },
  "code_blocks": [
    {
      "language": "txt",
      "file": "attachments/03e30b6796ac/code/block_000.txt",
      "chars": 69
    },
    {
      "language": "txt",
      "file": "attachments/03e30b6796ac/code/block_001.txt",
      "chars": 1205
    },
    {
      "language": "txt",
      "file": "attachments/03e30b6796ac/code/block_002.txt",
      "chars": 369
    },
    {
      "language": "txt",
      "file": "attachments/03e30b6796ac/code/block_003.txt",
      "chars": 212
    },
    {
      "language": "txt",
      "file": "attachments/03e30b6796ac/code/block_004.txt",
      "chars": 1463
    },
    {
      "language": "txt",
      "file": "attachments/03e30b6796ac/code/block_005.txt",
      "chars": 884
    },
    {
      "language": "txt",
      "file": "attachments/03e30b6796ac/code/block_006.txt",
      "chars": 86
    },
    {
      "language": "txt",
      "file": "attachments/03e30b6796ac/code/block_007.txt",
      "chars": 1173
    },
    {
      "language": "txt",
      "file": "attachments/03e30b6796ac/code/block_008.txt",
      "chars": 763
    },
    {
      "language": "txt",
      "file": "attachments/03e30b6796ac/code/block_009.txt",
      "chars": 77
    },
    {
      "language": "txt",
      "file": "attachments/03e30b6796ac/code/block_010.txt",
      "chars": 133
    },
    {
      "language": "txt",
      "file": "attachments/03e30b6796ac/code/block_011.txt",
      "chars": 332
    },
    {
      "language": "txt",
      "file": "attachments/03e30b6796ac/code/block_012.txt",
      "chars": 159
    },
    {
      "language": "txt",
      "file": "attachments/03e30b6796ac/code/block_013.txt",
      "chars": 1316
    }
  ],
  "images": [
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:54:22Z"
    },
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:54:22Z"
    },
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:54:22Z"
    },
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:54:22Z"
    }
  ],
  "audio": [],
  "videos": [
    {
      "url": "https://www.youtube.com/c/TowardsDataScience",
      "kind": "channel_reference",
      "status": "reference_only"
    }
  ],
  "links": [
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/latest/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/editors-pick/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/the-variable/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/shipai/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/submissions/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/artificial-intelligence/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/muhammad_ardi/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/deep-dives/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/deep-learning/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/object-detection/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/python/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/yolo/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/data-analysis-series-an-overview-of-fifa-19-players-dataset-e995ea33dd29/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/data-science/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/efebuyuk/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/breaking-down-the-support-vector-machine-svm-algorithm-d2c030d58d42/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/tensorslow/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/understanding-causal-trees-920177462149/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/matteo.courthoud/"
    },
    {
      "type": "external",
      "href": "https://write.insightmediagroup.io"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/company/towards-data-science/"
    },
    {
      "type": "external",
      "href": "https://x.com/TDataScience"
    },
    {
      "type": "external",
      "href": "https://unsplash.com/photos/a-toy-robot-sitting-on-top-of-a-wooden-table-MFYmMBUEkmQ"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/ai-engineer"
    },
    {
      "type": "external",
      "href": "https://arxiv.org/pdf/1506.02640"
    },
    {
      "type": "external",
      "href": "https://arxiv.org/pdf/1311.2524"
    },
    {
      "type": "external",
      "href": "https://arxiv.org/abs/2506.17733"
    },
    {
      "type": "external",
      "href": "https://arxiv.org/pdf/1505.00853"
    },
    {
      "type": "external",
      "href": "https://github.com/MuhammadArdiPutra/medium_articles/blob/main/The%20Day%20YOLO%20First%20Saw%20the%20World%20-%20YOLOv1.ipynb"
    },
    {
      "type": "external",
      "href": "https://www.facebook.com/sharer/sharer.php?title=YOLOv1+Paper+Walkthrough%3A+The+Day+YOLO+First+Saw+the%C2%A0World&u=https%3A%2F%2Ftowardsdatascience.com%2Fyolov1-paper-walkthrough-the-day-yolo-first-saw-the-world%2F"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/shareArticle?mini=true&title=YOLOv1+Paper+Walkthrough%3A+The+Day+YOLO+First+Saw+the%C2%A0World&url=https%3A%2F%2Ftowardsdatascience.com%2Fyolov1-paper-walkthrough-the-day-yolo-first-saw-the-world%2F"
    },
    {
      "type": "external",
      "href": "https://x.com/share?text=YOLOv1+Paper+Walkthrough%3A+The+Day+YOLO+First+Saw+the%C2%A0World&url=https%3A%2F%2Ftowardsdatascience.com%2Fyolov1-paper-walkthrough-the-day-yolo-first-saw-the-world%2F"
    },
    {
      "type": "external",
      "href": "https://www.youtube.com/c/TowardsDataScience"
    },
    {
      "type": "external",
      "href": "https://www.threads.net/@towardsdatascience"
    },
    {
      "type": "external",
      "href": "https://bsky.app/profile/towardsdatascience.com"
    },
    {
      "type": "external",
      "href": "https://thenewstack.io"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh"
    },
    {
      "type": "external",
      "href": "https://insightmediagroup.io/creator-network"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-20T17:28:30Z",
  "source_url": "https://towardsdatascience.com/yolov1-paper-walkthrough-the-day-yolo-first-saw-the-world/",
  "delivery_status": "unverified",
  "discovery_status": "http_403",
  "missing_reason": "源页面未重新核验:http_403；已按保留正文补采图片",
  "repair_error": "",
  "actual_video_files": [],
  "expected_saved_body_images": 4,
  "image_discovery": "saved_markdown",
  "source_body_markdown": "![Revisit consent button](https://cdn-cookieyes.com/assets/images/revisit.svg)\nWe value your privacy\nWe use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking \"Accept All\", you consent to our use of cookies.\nCustomise Reject All Accept All\nCustomise Consent Preferences ![](https://cdn-cookieyes.com/assets/images/close.svg)\nWe use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.\nThe cookies that are categorised as \"Necessary\" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... Show more\nNecessaryAlways Active\nNecessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.\n  * Cookie\nBCTempID\n  * Duration\n10 minutes\n  * Description\nNo description available.\n\n\n  * Cookie\n__cf_bm\n  * Duration\n1 hour\n  * Description\nThis cookie, set by Cloudflare, is used to support Cloudflare Bot Management. \n\n\n  * Cookie\nAWSALBCORS\n  * Duration\n7 days\n  * Description\nAmazon Web Services set this cookie for load balancing.\n\n\n  * Cookie\n_cfuvid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to track users across sessions to optimize user experience by maintaining session consistency and providing personalized services\n\n\n  * Cookie\nli_gc\n  * Duration\n6 months\n  * Description\nLinkedin set this cookie for storing visitor's consent regarding using cookies for non-essential purposes.\n\n\n  * Cookie\n__hssrc\n  * Duration\nsession\n  * Description\nThis cookie is set by Hubspot whenever it changes the session cookie. The __hssrc cookie set to 1 indicates that the user has restarted the browser, and if the cookie does not exist, it is assumed to be a new session.\n\n\n  * Cookie\n__hssc\n  * Duration\n1 hour\n  * Description\nHubSpot sets this cookie to keep track of sessions and to determine if HubSpot should increment the session number and timestamps in the __hstc cookie.\n\n\n  * Cookie\nwpEmojiSettingsSupports\n  * Duration\nsession\n  * Description\nWordPress sets this cookie when a user interacts with emojis on a WordPress site. It helps determine if the user's browser can display emojis properly.\n\n\n  * Cookie\nBCSessionID\n  * Duration\n1 year 1 month 4 days\n  * Description\nBlueconic sets this cookie as a unique identifier for the BlueConic profile.\n\n\n  * Cookie\n_octo\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nlogged_in\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\n__Secure-YEC\n  * Duration\npast\n  * Description\nYouTube sets this cookie to stores the user's video player preferences using embedded YouTube video\n\n\n  * Cookie\n__eoi\n  * Duration\n6 months\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTGCORS\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\nlogin-status-p\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTG\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\ncsrf_token\n  * Duration\nsession\n  * Description\nNo description available.\n\n\n  * Cookie\ntoken_v2\n  * Duration\n1 day\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nD\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nPHPSESSID\n  * Duration\nsession\n  * Description\nThis cookie is native to PHP applications. The cookie stores and identifies a user's unique session ID to manage user sessions on the website. The cookie is a session cookie and will be deleted when all the browser windows are closed.\n\n\n  * Cookie\nVISITOR_PRIVACY_METADATA\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to store the user's cookie consent state for the current domain. \n\n\n  * Cookie\ncookietest\n  * Duration\nsession\n  * Description\nThe cookietest cookie is typically used to determine whether the user's browser accepts cookies, essential for website functionality and user experience.\n\n\n  * Cookie\n__Host-airtable-session\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\n__Host-airtable-session.sig\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\nm\n  * Duration\n1 year 1 month 4 days\n  * Description\nStripe sets this cookie for fraud prevention purposes. It identifies the device used to access the website, allowing the website to be formatted accordingly.\n\n\n  * Cookie\nBIGipServer*\n  * Duration\nsession\n  * Description\nMarketo sets this cookie to collect information about the user's online activity and build a profile about their interests to provide advertisements relevant to the user. \n\n\n  * Cookie\n__cfruid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to identify trusted web traffic.\n\n\n  * Cookie\n_GRECAPTCHA\n  * Duration\n6 months\n  * Description\nGoogle Recaptcha service sets this cookie to identify bots to protect the website against malicious spam attacks.\n\n\n  * Cookie\n__Secure-YNID\n  * Duration\n6 months\n  * Description\nGoogle cookie used to protect user security and prevent fraud, especially during the login process.\n\n\n  * Cookie\ncookieyes-consent\n  * Duration\n1 year\n  * Description\nCookieYes sets this cookie to remember users' consent preferences so that their preferences are respected on subsequent visits to this site. It does not collect or store any personal information about the site visitors.\n\n\nFunctional\nFunctional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.\n  * Cookie\nlidc\n  * Duration\n1 day\n  * Description\nLinkedIn sets the lidc cookie to facilitate data center selection.\n\n\n  * Cookie\nbrw\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nbrwConsent\n  * Duration\n5 minutes\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nWMF-Uniq\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nloom_anon_comment\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nloom_referral_video\n  * Duration\nsession\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nVISITOR_INFO1_LIVE\n  * Duration\n6 months\n  * Description\nA cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.\n\n\n  * Cookie\nyt-remote-connected-devices\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nytidb::LAST_RESULT_ENTRY_KEY\n  * Duration\nNever Expires\n  * Description\nThe cookie ytidb::LAST_RESULT_ENTRY_KEY is used by YouTube to store the last search result entry that was clicked by the user. This information is used to improve the user experience by providing more relevant search results in the future.\n\n\n  * Cookie\nyt-remote-device-id\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-name\n  * Duration\nsession\n  * Description\nThe yt-remote-session-name cookie is used by YouTube to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\nyt-remote-fast-check-period\n  * Duration\nsession\n  * Description\nThe yt-remote-fast-check-period cookie is used by YouTube to store the user's video player preferences for embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-app\n  * Duration\nsession\n  * Description\nThe yt-remote-session-app cookie is used by YouTube to store user preferences and information about the interface of the embedded YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-available\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-available cookie is used to store the user's preferences regarding whether casting is available on their YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-installed\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-installed cookie is used to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\ncp_session\n  * Duration\n3 months\n  * Description\nCodepen sets this cookie for Help systems found in the website.\n\n\n  * Cookie\nloid\n  * Duration\n1 year 1 month 4 days\n  * Description\nThis cookie is set by the Reddit. The cookie enables the sharing of content from the website onto the social media platform.\n\n\nAnalytics\nAnalytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.\n  * Cookie\n__hstc\n  * Duration\n6 months\n  * Description\nHubspot set this main cookie for tracking visitors. It contains the domain, initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session).\n\n\n  * Cookie\nhubspotutk\n  * Duration\n6 months\n  * Description\nHubSpot sets this cookie to keep track of the visitors to the website. This cookie is passed to HubSpot on form submission and used when deduplicating contacts.\n\n\n  * Cookie\n_ga\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors.\n\n\n  * Cookie\n_ga_*\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to store and count page views.\n\n\n  * Cookie\n__Host-psifi.analyticsTrace\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n__Host-psifi.analyticsTraceV2\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n_gh_sess\n  * Duration\nsession\n  * Description\nGitHub sets this cookie for temporary application and framework state between pages like what step the user is on in a multiple step form.\n\n\n  * Cookie\nYSC\n  * Duration\nsession\n  * Description\nYSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.\n\n\n  * Cookie\najs_anonymous_id\n  * Duration\n1 year\n  * Description\nThis cookie is set by Segment to count the number of people who visit a certain site by tracking if they have visited before.\n\n\n  * Cookie\nvuid\n  * Duration\n1 year 1 month 4 days\n  * Description\nVimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. \n\n\nPerformance\nPerformance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.\n  * Cookie\nAWSALB\n  * Duration\n7 days\n  * Description\nAWSALB is an application load balancer cookie set by Amazon Web Services to map the session to the target.\n\n\n  * Cookie\nacq\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nacq.sig\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nptc\n  * Duration\n2 years\n  * Description\nNo description available.\n\n\nAdvertisement\nAdvertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.\n  * Cookie\nmuc_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to collect user behaviour and interaction data to optimize the website.\n\n\n  * Cookie\nguest_id_marketing\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\nguest_id_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\npersonalization_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to integrate and share features for social media and also store information about how the user uses the website, for tracking and targeting.\n\n\n  * Cookie\nguest_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor. It registers if a user is signed in to the Twitter platform and collects information about ad preferences.\n\n\n  * Cookie\nbcookie\n  * Duration\n1 year\n  * Description\nLinkedIn sets this cookie from LinkedIn share buttons and ad tags to recognize browser IDs.\n\n\n  * Cookie\n__Secure-ROLLOUT_TOKEN\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to manage feature rollout and experimentation. It helps Google control which new features or interface changes are shown to users as part of testing and staged rollouts, ensuring consistent experience for a given user during an experiment.\n\n\n  * Cookie\nyt.innertube::nextId\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nyt.innertube::requests\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nsession_tracker\n  * Duration\nsession\n  * Description\nThis cookie is set by the Reddit. This cookie is used to identify trusted web traffic. It also helps in adverstising on the website.\n\n\n  * Cookie\nedgebucket\n  * Duration\nsession\n  * Description\nReddit sets this cookie to save the information about a log-on Reddit user, for the purpose of advertisement recommendations and updating the content.\n\n\n  * Cookie\ndid\n  * Duration\n1 year\n  * Description\nArbor sets this cookie to show targeted ads to site visitors.This cookie expires after 2 months or 1 year.\n\n\nUncategorised\nOther uncategorised cookies are those that are being analysed and have not been classified into a category as yet.\nNo cookies to display.\nReject All Save My Preferences Accept All\nToggle Search[](https://towardsdatascience.com/)Toggle Mobile Navigation\n[](https://towardsdatascience.com/)\nPublish AI, ML & data-science insights to a global community of data professionals.\nSign in[Submit an Article](https://write.insightmediagroup.io)\n[Latest](https://towardsdatascience.com/latest/)[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Newsletter](https://towardsdatascience.com/tag/the-variable/)[ShipAI](https://towardsdatascience.com/shipai/)\n* * *\n[Write For TDS](https://towardsdatascience.com/submissions/)\n[LinkedIn](https://www.linkedin.com/company/towards-data-science/)[X](https://x.com/TDataScience)Toggle Search\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\n# YOLOv1 Paper Walkthrough: The Day YOLO First Saw the World\nA detailed walkthrough of the YOLOv1 architecture and its PyTorch implementation from scratch\n[Muhammad Ardi Putra](https://towardsdatascience.com/author/muhammad_ardi/)\nDecember 5, 202517 min read\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/12/hassan-MFYmMBUEkmQ-unsplash-scaled-1.jpg)\nPhoto by Hassan on [Unsplash](https://unsplash.com/photos/a-toy-robot-sitting-on-top-of-a-wooden-table-MFYmMBUEkmQ)\n## Introduction\nIf we talk about object detection, one model that likely comes to our mind first is YOLO — well, at least for me, thanks to its popularity in the field of computer vision.\nThe very first version of this model, referred to as YOLOv1, was released back in 2015 in the research paper titled “ _You Only Look Once: Unified, Real-Time Object Detection”_ [1]. Before YOLOv1 was invented, one of the state-of-the-art algorithms for performing object detection was R-CNN (Region-based Convolutional Neural Network), in which it uses multi-stage mechanism to do the task. It initially employs selective search algorithm to create region proposal, then uses CNN-based model to extract the features within all these regions, and finally classifies the detected objects using SVM [2]. Here you can clearly imagine how long the process is just to perform object detection on a single image.\nThe motivation of YOLO in the first place was to improve speed. In fact, not only achieving low computational complexity, but the authors proved that their proposed deep learning model was also able to achieve high accuracy. As this article is written, YOLOv13 has just published several days ago [3]. But let’s just talk about its very first ancestor for now so that you can see the beauty of this model starting from the time it first came out. This article is going to discuss how YOLOv1 works and how to build this neural network architecture from scratch with PyTorch.\n···\nLearn this step by step with the interactive [AI Engineer](https://roadmap.sh/ai-engineer) roadmap.\n## The Underlying Theory Behind YOLOv1\nBefore we get into the architecture, it would be better if we understand the idea behind YOLOv1 in advance. Let’s start with an example. Suppose we have a picture of a cat, and we are about to use it as a training sample of a YOLOv1 model. And so, we need to create a ground truth for that. It is mentioned in the original paper that we need to define the parameter _S_ , which denotes the number of grid cells we are going to divide our image into along each spatial dimension. By default, this parameter is set to 7, so we will have 7×7=49 cells in total. Take a look at Figure 1 below to better understand this idea.\n![](https://assets.insightmediagroup.io/media/max/720/1*BlKApVlI4KWQayl4MHAlfQ.png)\nFigure 1. What the image looks like after being divided into uniform-sized grid cells. The cell (3, 3) is responsible to store the information about the cat [4].\nNext, we need to determine which cell corresponds to the midpoint of the object. In the above case, the cat is located almost exactly at the center of the image, hence the midpoint must lie at cell (3, 3). Later in the inference phase, we can think of this cell as the one responsible to predict the cat. Now taking a closer look at the cell, we need to determine the exact position of the midpoint. Here you can see that along the vertical axis it is located exactly in the middle, but in the horizontal axis it is slightly shifted to the left from the middle. So, if I were to approximate, the coordinate would be (0.4, 0.5). This coordinate value is relative to the cell and is normalized to the range of 0 to 1. It might be worth noting that the (_x_ , _y_) coordinate of the midpoint should neither be less than 0 nor greater than 1, since a value outside this range would mean the midpoint lies in another cell. Meanwhile, the width _w_ and the height _h_ of the bounding box are approximately 2.4 and 3.2, respectively. These numbers are relative to the cell size, meaning that if the object is bigger than the cell, then the value will be greater than 1. Later on, if we were to create a ground truth for an image, we need to store all these _x_ , _y_ , _w_ and _h_ information in the so-called _target vector_.\n### Target Vector\nThe length of the target vector itself is 25 for each cell, in which the first 20 elements (index 0 to 19) store the class of the object in form of one-hot encoding. This is essentially because YOLOv1 was originally trained on PASCAL VOC dataset which has that number of classes. Next, index 20 is used to store the confidence of the bounding box prediction, which in the training phase this is set to 1 whenever there is an object midpoint within the cell. Lastly, the (_x_ , _y_) coordinate of the midpoint are placed at indices 21 and 22, whereas _w_ and _h_ are stored at indices 23 and 24. The illustration in Figure 2 below displays what the target vector for cell (3, 3) looks like.\n![](https://assets.insightmediagroup.io/media/max/1080/1*JdBZ0LjYrOKrkhfhvwPKyg.png)\nFigure 2. The target vector for cell (3, 3) of the image in Figure 1 [5].\nAgain, remember that the above target vector only corresponds to a single cell. To create the ground truth for the entire image, we need to have a bunch of similar vectors concatenated, forming the so-called _target tensor_ as shown in Figure 3. Note that the class probabilities as well as the bounding box confidences, locations, and sizes from all other cells are set to zero because there is no other object appearing within the image.\n![](https://assets.insightmediagroup.io/media/max/1080/1*M8HXIW8SODPiU4H4r73J7g.png)\nFigure 3. How all target vectors from each cell are concatenated. This entire tensor will act as the ground truth of a single image [5].\n### Prediction Vector\nThe _prediction vector_ is quite a bit different. If the target vector consists of 25 elements, the prediction vector consists of 30. This is because by default YOLOv1 predicts two bounding boxes for the same object during inference. Thus, we need 5 additional elements to store the information about the second bounding box generated by the model. Despite predicting two bounding boxes, later we will only take the one that has greater confidence.\n![](https://assets.insightmediagroup.io/media/max/1080/1*b4wFnP5aq5k7fOJbPXtP7A.png)\nFigure 4. The prediction vector has 5 additional elements dedicated for the second bounding box (highlighted in orange) [5].\nThis unique target and prediction vector dimensions required the authors to rethink the loss function. For regression problems, we typically use MAE, MSE or RMSE, whereas for classification tasks we usually use cross entropy loss. But YOLOv1 is more than just a regression and classification problem, considering that we have both continuous (bounding box) and discrete (class) values in the vector representation. Thanks to this reason, the authors created a new loss function specialized for this model as shown in Figure 5. This loss function is quite complex (you see, right?), so I decided to write it in a separate article because there are lots of things to explain about it — stay tuned, I’ll publish it very soon.\n![](https://assets.insightmediagroup.io/media/max/720/1*nxd4oYiWWu6eo74XtFvH7A.png)\nFigure 5. The loss function of YOLOv1 [1].\n···\n## The YOLOv1 Architecture\nJust like typical earlier computer vision models, YOLOv1 uses CNN-based architecture as the backbone of the model. It comprises 24 convolution layers stacked according to the structure in Figure 6. If you take a closer look at the figure, you will notice that the output layer produces a tensor of shape 30×7×7. This dimension indicates that every single cell has its corresponding prediction vector of length 30 containing the class and the bounding box information of the detected object, in which this matches exactly with our previous discussion.\n![](https://assets.insightmediagroup.io/media/max/1080/1*Et86F61LL_WvZE_S3FeFAA.png)\nFigure 6. The architecture of YOLOv1 [1].\nWell, I think I’ve covered all the fundamentals of YOLOv1, so now let’s start implementing the architecture from scratch with PyTorch. Before doing anything, what we need to do first is to import the required modules and initialize the parameters _S_ , _B_ , and _C_. See Codeblock 1 below.\npython\n\n```\n# Codeblock 1\nimport torch\nimport torch.nn as nn\n\nS = 7\nB = 2\nC = 20\n```\n\nThe three parameters I initialized above are the default values given in the paper, in which `S` represents the number of grid cells along the horizontal and vertical axes, `B` denotes the number of bounding boxes generated by each cell, and `C` is the number of classes available in the dataset. Since we use `S=7` and `B=2`, our YOLOv1 will produce7×7×2=98 bounding boxes in total for each image.\n### The Building Block\nNext, we are going to create the `ConvBlock` class, in which it contains a single convolution layer (line `#(1)`), a leaky ReLU activation function (`#(2)`), and an optional maxpooling layer (`#(3)`) as shown in Codeblock 2.\npython\n\n```\n# Codeblock 2\nclass ConvBlock(nn.Module):\n    def __init__(self, \n                 in_channels, \n                 out_channels, \n                 kernel_size, \n                 stride, \n                 padding, \n                 maxpool_flag=False):\n        super().__init__()\n        self.maxpool_flag = maxpool_flag\n        \n        self.conv = nn.Conv2d(in_channels=in_channels,       #(1)\n                              out_channels=out_channels, \n                              kernel_size=kernel_size, \n                              stride=stride, \n                              padding=padding)\n        self.leaky_relu = nn.LeakyReLU(negative_slope=0.1)   #(2)\n        \n        if self.maxpool_flag:\n            self.maxpool = nn.MaxPool2d(kernel_size=2,       #(3)\n                                        stride=2)\n            \n    def forward(self, x):\n        print(f'original\\t: {x.size()}')\n\n        x = self.conv(x)\n        print(f'after conv\\t: {x.size()}')\n        \n        x = self.leaky_relu(x)\n        print(f'after leaky relu: {x.size()}')\n        \n        if self.maxpool_flag:\n            x = self.maxpool(x)\n            print(f'after maxpool\\t: {x.size()}')\n        \n        return x\n```\n\nIn modern architectures, we normally use the _Conv-BN-ReLU_ structure, but at the time YOLOv1 was created, it seems like batch normalization layer was not quite popular just yet, as it came out only several months before YOLOv1. So, I guess this is probably the reason that the authors did not utilize this normalization layer. Instead, it only uses a stack of convolutions and leaky ReLUs throughout the entire network.\nJust a quick refresher, leaky ReLU is an activation function similar to the standard ReLU, except that the negative values are multiplied with a small number instead of being zeroed out. In the case of YOLOv1, we set the multiplier to 0.1 (`#(2)`) so that it can still preserve a little bit amount of information contained in the negative input numbers.\n![](https://assets.insightmediagroup.io/media/max/720/1*ebaH01k-zvWy9JLIF6BRjQ.png)\nFigure 7. ReLU vs Leaky ReLU activation functions [6].\nAs the `ConvBlock` class has been defined, now I am going to test it just to check if it works properly. In Codeblock 3 below I try to implement the very first layer in the network and pass a dummy tensor through it. You can see in the codeblock that `in_channels` is set to 3 (`#(1)`) and `out_channels` is set to 64 (`#(2)`) because we want this initial layer to accept an RGB image as the input and return a 64-channel image. The size of the kernel is 7×7 (`#(3)`), hence we need to set the padding to 3 (`#(5)`). Normally, this configuration allows us to preserve the spatial dimension of the image, but since we use `stride=2` (`#(4)`), this padding size ensures that the image is exactly halved. Next, if you go back to Figure 6, you will notice that some conv layers are followed by a maxpooling layer and some others are not. Since the first convolution utilizes a maxpooling layer, we need to set the `maxpool_flag` parameter to `True` (`#(6)`).\npython\n\n```\n# Codeblock 3\nconvblock = ConvBlock(in_channels=3,       #(1)\n                      out_channels=64,     #(2)\n                      kernel_size=7,       #(3)\n                      stride=2,            #(4)\n                      padding=3,           #(5)\n                      maxpool_flag=True)   #(6)\nx = torch.randn(1, 3, 448, 448)            #(7)\nout = convblock(x)\n```\n\nAfterwards, we can simply generate a tensor of random values with the dimension of 1×3×448×448 (`#(7)`) which simulates a batch of a single RGB image of size 448×448 and then pass it through the network. You can see in the resulting output below that our convolution layer successfully increased the number of channels to 64 and halved the spatial dimension to 224×224. The halving was done once again all the way to 112×112 thanks to the maxpooling layer.\nmarkup\n\n```\n# Codeblock 3 Outputoriginal         : torch.Size([1, 3, 448, 448])after conv       : torch.Size([1, 64, 224, 224])after leaky relu : torch.Size([1, 64, 224, 224])after maxpool    : torch.Size([1, 64, 112, 112])\n```\n\n### The Backbone\nThe next thing we are going to do is to create a sequence of `ConvBlocks` to build the entire backbone of the network. In case you’re still not familiar with the term _backbone_ , in this case it is essentially everything before the two fully-connected layers (refer to Figure 6). Now look at the Codeblock 4a and 4b below to see how I define the `Backbone` class.\npython\n\n```\n# Codeblock 4a\nclass Backbone(nn.Module):\n    def __init__(self):\n        super().__init__()\n        # in_channels, out_channels, kernel_size, stride, padding, maxpool_flag\n        self.stage0 = ConvBlock(3, 64, 7, 2, 3, maxpool_flag=True)      #(1)\n        self.stage1 = ConvBlock(64, 192, 3, 1, 1, maxpool_flag=True)    #(2)\n        \n        self.stage2 = nn.ModuleList([\n            ConvBlock(192, 128, 1, 1, 0), \n            ConvBlock(128, 256, 3, 1, 1), \n            ConvBlock(256, 256, 1, 1, 0),\n            ConvBlock(256, 512, 3, 1, 1, maxpool_flag=True)      #(3)\n        ])\n        \n        \n        self.stage3 = nn.ModuleList([])\n        for _ in range(4):\n            self.stage3.append(ConvBlock(512, 256, 1, 1, 0))\n            self.stage3.append(ConvBlock(256, 512, 3, 1, 1))\n            \n        self.stage3.append(ConvBlock(512, 512, 1, 1, 0))\n        self.stage3.append(ConvBlock(512, 1024, 3, 1, 1, maxpool_flag=True))  #(4)\n        \n        \n        self.stage4 = nn.ModuleList([])\n        for _ in range(2):\n            self.stage4.append(ConvBlock(1024, 512, 1, 1, 0))\n            self.stage4.append(ConvBlock(512, 1024, 3, 1, 1))\n        \n        self.stage4.append(ConvBlock(1024, 1024, 3, 1, 1))\n        self.stage4.append(ConvBlock(1024, 1024, 3, 2, 1))    #(5)\n        \n        \n        self.stage5 = nn.ModuleList([])\n        self.stage5.append(ConvBlock(1024, 1024, 3, 1, 1))\n        self.stage5.append(ConvBlock(1024, 1024, 3, 1, 1))\n```\n\nWhat we do in the above codeblock is to instantiate `ConvBlock` instances according to the architecture given in the paper. There are several things I want to emphasize here. First, the term _stage_ I use in the code is not explicitly mentioned in the paper. However, I decided to use that word to describe the six groups of convolutional layers in Figure 6. Second, notice that we need to set the `maxpool_flag` to `True` for the last `ConvBlock` in the first four groups to perform spatial downsampling (`#(1–4)`). For the fifth group, the downsampling is done by setting the stride of the last convolution layer to 2 (`#(5)`). Third, Figure 6 does not mention the padding size of the convolution layers, so we need to calculate them manually. There is indeed a specific formula to find padding size based on the given kernel size. However, I feel like it is much easier to memorize it. Just keep in mind that if we use kernel of size 7×7, then we need to set the padding to 3 to preserve the spatial dimension. Meanwhile, for 5×5, 3×3 and 1×1 kernels, the padding should be set to 2, 1, and 0, respectively.\nAs all layers in the backbone have been instantiated, we can now connect them all using the `forward()` method below. I don’t think I need to explain anything here since it basically only works by passing the input tensor `x` through the layers sequentially.\npython\n\n```\n# Codeblock 4b\n    def forward(self, x):\n        print(f'original\\t: {x.size()}\\n')\n        \n        x = self.stage0(x)\n        print(f'after stage0\\t: {x.size()}\\n')\n        \n        x = self.stage1(x)\n        print(f'after stage1\\t: {x.size()}\\n')\n        \n        for i in range(len(self.stage2)):\n            x = self.stage2[i](x)\n            print(f'after stage2 #{i}\\t: {x.size()}')\n        \n        print()\n        for i in range(len(self.stage3)):\n            x = self.stage3[i](x)\n            print(f'after stage3 #{i}\\t: {x.size()}')\n        \n        print()\n        for i in range(len(self.stage4)):\n            x = self.stage4[i](x)\n            print(f'after stage4 #{i}\\t: {x.size()}')\n        \n        print()\n        for i in range(len(self.stage5)):\n            x = self.stage5[i](x)\n            print(f'after stage5 #{i}\\t: {x.size()}')\n            \n        return x\n```\n\nNow let’s verify if our implementation is correct by running the following testing code.\npython\n\n```\n# Codeblock 5\nbackbone = Backbone()\nx = torch.randn(1, 3, 448, 448)\nout = backbone(x)\n```\n\nIf you try to run the above codeblock, the following output should appear on your screen. Here you can see that the spatial dimension of the image correctly got reduced after the last `ConvBlock` of each stage. This process continued all the way to the last stage until eventually we obtained a tensor of size 1024×7×7, in which this matches exactly with the illustration in Figure 6.\nmarkup\n\n```\n# Codeblock 5 Outputoriginal        : torch.Size([1, 3, 448, 448])after stage0    : torch.Size([1, 64, 112, 112])after stage1    : torch.Size([1, 192, 56, 56])after stage2 #0 : torch.Size([1, 128, 56, 56])after stage2 #1 : torch.Size([1, 256, 56, 56])after stage2 #2 : torch.Size([1, 256, 56, 56])after stage2 #3 : torch.Size([1, 512, 28, 28])after stage3 #0 : torch.Size([1, 256, 28, 28])after stage3 #1 : torch.Size([1, 512, 28, 28])after stage3 #2 : torch.Size([1, 256, 28, 28])after stage3 #3 : torch.Size([1, 512, 28, 28])after stage3 #4 : torch.Size([1, 256, 28, 28])after stage3 #5 : torch.Size([1, 512, 28, 28])after stage3 #6 : torch.Size([1, 256, 28, 28])after stage3 #7 : torch.Size([1, 512, 28, 28])after stage3 #8 : torch.Size([1, 512, 28, 28])after stage3 #9 : torch.Size([1, 1024, 14, 14])after stage4 #0 : torch.Size([1, 512, 14, 14])after stage4 #1 : torch.Size([1, 1024, 14, 14])after stage4 #2 : torch.Size([1, 512, 14, 14])after stage4 #3 : torch.Size([1, 1024, 14, 14])after stage4 #4 : torch.Size([1, 1024, 14, 14])after stage4 #5 : torch.Size([1, 1024, 7, 7])after stage5 #0 : torch.Size([1, 1024, 7, 7])after stage5 #1 : torch.Size([1, 1024, 7, 7])\n```\n\n### The Fully-Connected Layers\nAfter the backbone is done, we can now move on to the fully-connected part, which I write in Codeblock 6 below. This part of the network is very simple as it mainly only consists of two linear layers. Speaking of the details, it is mentioned in the paper that the authors apply a dropout layer with the rate of 0.5 (`#(3)`) between the first (`#(1)`) and the second (`#(4)`) linear layers. It is important to note that the leaky ReLU activation function is still used (`#(2)`) but only after the first linear layer. This is because the second one acts as the output layer, hence it does not require any activation applied to it.\npython\n\n```\n# Codeblock 6\nclass FullyConnected(nn.Module):\n    def __init__(self):\n        super().__init__()\n        \n        self.linear0 = nn.Linear(in_features=1024*7*7, out_features=4096)   #(1)\n        self.leaky_relu = nn.LeakyReLU(negative_slope=0.1)                  #(2)\n        self.dropout = nn.Dropout(p=0.5)                                    #(3)\n        self.linear1 = nn.Linear(in_features=4096, out_features=(C+B*5)*S*S)#(4)\n    \n    def forward(self, x):\n        print(f'original\\t: {x.size()}')\n        \n        x = self.linear0(x)\n        print(f'after linear0\\t: {x.size()}')\n        \n        x = self.leaky_relu(x)\n        x = self.dropout(x)\n        \n        x = self.linear1(x)\n        print(f'after linear1\\t: {x.size()}')\n        \n        return x\n```\n\nRun the Codeblock 7 below to see how the tensor transforms as it is processed by the stack of linear layers.\npython\n\n```\n# Codeblock 7\nfc = FullyConnected()\nx = torch.randn(1, 1024*7*7)\nout = fc(x)\n```\n\nmarkup\n\n```\n# Codeblock 7 Outputoriginal      : torch.Size([1, 50176])after linear0 : torch.Size([1, 4096])after linear1 : torch.Size([1, 1470])\n```\n\nWe can see in the above output that the `fc` block takes an input of shape 50176, which is essentially the flattened 1024×7×7 tensor. The `linear0` layer works by mapping this input into 4096-dimensional vector, and then the `linear1` layer eventually maps it further to 1470. Later in the post-processing stage we need to reshape it to 30×7×7 so that we can take the bounding box and the object classification results easily. Technically speaking, this reshaping process can be done either internally by the model or outside the model. For the sake of simplicity, I decided to leave the output flattened, meaning the reshaping will be handled externally.\n### Connecting the FC Part to the Backbone\nAt this point we already have our backbone and the fully-connected layers done. Thus, they are now ready to be assembled to construct the entire YOLOv1 architecture. There is not much thing I can explain regarding the following code, as what we do here is only instantiating both parts and connect them in the `forward()` method. Just don’t forget to flatten (`#(1)`) the output of `backbone` to make it compatible with the input of the `fc` block.\npython\n\n```\n# Codeblock 8\nclass YOLOv1(nn.Module):\n    def __init__(self):\n        super().__init__()\n        \n        self.backbone = Backbone()\n        self.fc = FullyConnected()\n        \n    def forward(self, x):\n        x = self.backbone(x)\n        x = torch.flatten(x, start_dim=1)    #(1)\n        x = self.fc(x)\n        \n        return x\n```\n\nIn order to test our model, we can simply instantiate the `YOLOv1` model and pass a dummy tensor that simulates an RGB image of size 448×448 (`#(1)`). After feeding the tensor into the network (`#(2)`), I also try to simulate the post-processing step by reshaping the output tensor to 30×7×7 as shown at line `#(3)`.\npython\n\n```\n# Codeblock 9\nyolov1 = YOLOv1()\nx = torch.randn(1, 3, 448, 448)      #(1)\n\nout = yolov1(x)                      #(2)\nout = out.reshape(-1, C+B*5, S, S)   #(3)\n```\n\nAnd below is what the output looks like after the code above is run. Here you can see that our input tensor successfully flows through all layers within the entire network, indicating that our YOLOv1 model works properly and thus is ready to train.\nmarkup\n\n```\n# Codeblock 9 Outputoriginal        : torch.Size([1, 3, 448, 448])after stage0    : torch.Size([1, 64, 112, 112])after stage1    : torch.Size([1, 192, 56, 56])after stage2 #0 : torch.Size([1, 128, 56, 56])after stage2 #1 : torch.Size([1, 256, 56, 56])after stage2 #2 : torch.Size([1, 256, 56, 56])after stage2 #3 : torch.Size([1, 512, 28, 28])after stage3 #0 : torch.Size([1, 256, 28, 28])after stage3 #1 : torch.Size([1, 512, 28, 28])after stage3 #2 : torch.Size([1, 256, 28, 28])after stage3 #3 : torch.Size([1, 512, 28, 28])after stage3 #4 : torch.Size([1, 256, 28, 28])after stage3 #5 : torch.Size([1, 512, 28, 28])after stage3 #6 : torch.Size([1, 256, 28, 28])after stage3 #7 : torch.Size([1, 512, 28, 28])after stage3 #8 : torch.Size([1, 512, 28, 28])after stage3 #9 : torch.Size([1, 1024, 14, 14])after stage4 #0 : torch.Size([1, 512, 14, 14])after stage4 #1 : torch.Size([1, 1024, 14, 14])after stage4 #2 : torch.Size([1, 512, 14, 14])after stage4 #3 : torch.Size([1, 1024, 14, 14])after stage4 #4 : torch.Size([1, 1024, 14, 14])after stage4 #5 : torch.Size([1, 1024, 7, 7])after stage5 #0 : torch.Size([1, 1024, 7, 7])after stage5 #1 : torch.Size([1, 1024, 7, 7])original        : torch.Size([1, 50176])after linear0   : torch.Size([1, 4096])after linear1   : torch.Size([1, 1470])torch.Size([1, 30, 7, 7])\n```\n\n···\n## Ending\nIt might be worth noting that all the codes I show you throughout this entire article is for the base YOLOv1 architecture. It is mentioned in the paper that the authors also proposed the lite version of this model which they refer to as _Fast YOLO_. This smaller YOLOv1 version offers faster computation time as it only consists of 9 convolution layers instead of 24. Unfortunately, the paper does not provide the implementation details, so I cannot demonstrate you how to implement that one.\nHere I encourage you to play around with the above code. In theory, it is possible to replace the CNN-based backbone with other deep learning models, such as ResNet, ResNeXt, ViT, etc. All you need to do is just to match the output shape of the backbone with the input shape of the fully-connected part. Not only that, I also want you to try training this model from scratch. But if you decided to do so, you might probably want to make this model smaller by reducing the depth (no of convolution layers) or the width (no of kernels) of the model. This is essentially because the authors mentioned that they required around a week just to do the pretraining on ImageNet dataset, not to mention the time for fine tuning on the object detection task.\nAnd well, I think that’s pretty much everything I can explain you about how YOLOv1 works and its architecture. Please let me know if you spot any mistake in this article. Thank you!\n_By the way, the code used in this article is also available on my GitHub repo [7]._\n···\n## References\n[1] Joseph Redmon _et al._ You Only Look Once: Unified, Real-Time Object Detection. Arxiv. <https://arxiv.org/pdf/1506.02640> [Accessed July 5, 2025].\n[2] Ross Girshick _et al._ Rich feature hierarchies for accurate object detection and semantic segmentation. Arxiv. <https://arxiv.org/pdf/1311.2524> [Accessed July 5, 2025].\n[3] Mengqi Lei _et al._ YOLOv13: Real-Time Object Detection with Hypergraph-Enhanced Adaptive Visual Perception. Arxiv. <https://arxiv.org/abs/2506.17733> [Accessed July 5, 2025].\n[4] Image generated by author with Gemini, edited by author.\n[5] Image originally created by author.\n[6] Bing Xu _et al._ Empirical Evaluation of Rectified Activations in Convolutional Network. Arxiv. <https://arxiv.org/pdf/1505.00853> [Accessed July 5, 2025].\n[7] MuhammadArdiPutra. The Day YOLO First Saw the World — YOLOv1. GitHub. <https://github.com/MuhammadArdiPutra/medium_articles/blob/main/The%20Day%20YOLO%20First%20Saw%20the%20World%20-%20YOLOv1.ipynb> [Accessed July 7, 2025].\n## Register Now to Continue Reading\n### Unlock Towards Data Science with a Free Account\nAll articles on Towards Data Science are available to registered users. Create a free account today to access this article and thousands more.\nRegister for freeSign in to your account\n* * *\n![](https://assets.insightmediagroup.io/media/1787657598287_taxhya.jpeg)\nWritten By\n## [Muhammad Ardi Putra](https://towardsdatascience.com/author/muhammad_ardi/)\nDeep learning storyteller\n[See all from Muhammad Ardi Putra](https://towardsdatascience.com/author/muhammad_ardi/)\n[Deep Dives](https://towardsdatascience.com/tag/deep-dives/)[Deep Learning](https://towardsdatascience.com/tag/deep-learning/)[Object Detection](https://towardsdatascience.com/tag/object-detection/)[Python](https://towardsdatascience.com/tag/python/)[Yolo](https://towardsdatascience.com/tag/yolo/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Fyolov1-paper-walkthrough-the-day-yolo-first-saw-the-world%2F&title=YOLOv1%20Paper%20Walkthrough%3A%20The%20Day%20YOLO%20First%20Saw%20the%C2%A0World)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Fyolov1-paper-walkthrough-the-day-yolo-first-saw-the-world%2F&title=YOLOv1%20Paper%20Walkthrough%3A%20The%20Day%20YOLO%20First%20Saw%20the%C2%A0World)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Fyolov1-paper-walkthrough-the-day-yolo-first-saw-the-world%2F&text=YOLOv1%20Paper%20Walkthrough%3A%20The%20Day%20YOLO%20First%20Saw%20the%C2%A0World)\n\n\nTowards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program.\n[Write for TDS](https://towardsdatascience.com/submissions/)\n## Related Articles\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/11/1VTnoJrt7l02BRS373YBkyA.jpeg)](https://towardsdatascience.com/data-analysis-series-an-overview-of-fifa-19-players-dataset-e995ea33dd29/)\n## [Data Analysis Series: An Overview of FIFA 19 Players Dataset](https://towardsdatascience.com/data-analysis-series-an-overview-of-fifa-19-players-dataset-e995ea33dd29/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nIntro\n[Efe Buyuk](https://towardsdatascience.com/author/efebuyuk/)\nNovember 24, 20204 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/10/1Jsdi4EdZDDozpp6ZpIzOIg.png)](https://towardsdatascience.com/breaking-down-the-support-vector-machine-svm-algorithm-d2c030d58d42/)\n## [Breaking Down the Support Vector Machine (SVM) Algorithm](https://towardsdatascience.com/breaking-down-the-support-vector-machine-svm-algorithm-d2c030d58d42/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nSo, I was revising machine learning algorithms yesterday; and I observed that SVM is probably a widely used but complicated machine...\n[Satyam Mishra](https://towardsdatascience.com/author/tensorslow/)\nOctober 29, 20205 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/02/1tw7TZFJcXlehLgYU8obbGQ.png)](https://towardsdatascience.com/understanding-causal-trees-920177462149/)\n## [Understanding Causal Trees](https://towardsdatascience.com/understanding-causal-trees-920177462149/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nCAUSAL DATA SCIENCE How to use regression trees to estimate heterogeneous treatment effects In causal...\n[Matteo Courthoud](https://towardsdatascience.com/author/matteo.courthoud/)\nFebruary 3, 202315 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2019/08/1GjXWopoR9zMlGZAg2Wz2bw.png)](https://towardsdatascience.com/ai-safety-how-do-you-prevent-adversarial-attacks-ede17480a24d-2/)\n## [AI Safety - How Do you Prevent Adversarial Attacks?](https://towardsdatascience.com/ai-safety-how-do-you-prevent-adversarial-attacks-ede17480a24d-2/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nA quick chat with IBM researchers Pin-Yu and Sijia about their recent papers with the two concepts of 'Pruning' and 'Block Changing'\n[Alex Moltzau](https://towardsdatascience.com/author/alexmoltzau/)\nAugust 15, 20190 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/09/0Ij8aNRjzmDRMhTPd.jpeg)](https://towardsdatascience.com/7-ways-to-manipulate-pandas-dataframes-f5ec03fe944c/)\n## [7 Ways to Manipulate Pandas Dataframes](https://towardsdatascience.com/7-ways-to-manipulate-pandas-dataframes-f5ec03fe944c/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nPandas offer a great deal of flexibility.\n[Soner Yıldırım](https://towardsdatascience.com/author/sonery/)\nSeptember 11, 20204 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/09/0VRhnhZwVGyIzBf2g-scaled.jpg)](https://towardsdatascience.com/introduction-to-marketing-mix-modeling-in-python-d0dd81f4e794/)\n## [Introduction to Marketing Mix Modeling in Python](https://towardsdatascience.com/introduction-to-marketing-mix-modeling-in-python-d0dd81f4e794/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nWhich advertising spendings are really driving your sales?\n[Robert Kübler](https://towardsdatascience.com/author/dr-robert-kuebler/)\nSeptember 22, 20218 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/1NN2vLS2NDc392G5liZP5ow.jpeg)](https://towardsdatascience.com/multi-head-attention-formally-explained-and-defined-89dc70ce84bd/)\n## [Multi-Head Attention - Formally Explained and Defined](https://towardsdatascience.com/multi-head-attention-formally-explained-and-defined-89dc70ce84bd/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nA comprehensive and detailed formalization of multi-head attention.\n[Jean Meunier-Pion](https://towardsdatascience.com/author/jmpion/)\nJune 11, 20249 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/10/0sF-mgM_c_80CmuEr-scaled.jpg)](https://towardsdatascience.com/install-custom-python-libraries-from-private-pypi-on-databricks-6a7669f6e6fd/)\n## [Install custom Python Libraries from private PyPI on Databricks](https://towardsdatascience.com/install-custom-python-libraries-from-private-pypi-on-databricks-6a7669f6e6fd/)\n[](https://towardsdatascience.com/yolov1-paper-walkthrough-the-day-yolo-first-saw-the-world/)\nStep by step guide on how to integrate your private PyPI repositories on Databricks clusters.\n[David Suarez](https://towardsdatascience.com/author/dsu4rez/)\nOctober 4, 202110 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/05/0aI6Hog_VFR5JiLML-scaled.jpg)](https://towardsdatascience.com/create-a-surfing-web-app-34da6201f57e/)\n## [Create a Surfing Web App](https://towardsdatascience.com/create-a-surfing-web-app-34da6201f57e/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nHow python can help you find the perfect surfboard Businesses pay astronomical amounts on data...\n[Nikki Smit](https://towardsdatascience.com/author/nikkismit10/)\nMay 28, 20215 min read\n\n\n  * [YouTube](https://www.youtube.com/c/TowardsDataScience)\n  * [X](https://x.com/TDataScience)\n  * [LinkedIn](https://www.linkedin.com/company/towards-data-science/)\n  * [Threads](https://www.threads.net/@towardsdatascience)\n  * [Bluesky](https://bsky.app/profile/towardsdatascience.com)\n\n\n[](https://towardsdatascience.com/)\nYour home for data science and AI. The world's leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.\nSubscribe to Our Newsletter[Write For TDS](https://towardsdatascience.com/submissions/)•[About](https://towardsdatascience.com/about-towards-data-science-d691af11cc2f/)•[Advertise](https://contact.towardsdatascience.com/advertise-with-towards-data-science)•[Privacy Policy](https://towardsdatascience.com/privacy-policy/)•[Terms of Use](https://towardsdatascience.com/website-terms-of-use/)\n© Insight Media Group, LLC 2026•[The New Stack](https://thenewstack.io)•[roadmap.sh](https://roadmap.sh)•[Creator Network](https://insightmediagroup.io/creator-network)\n####  Recommended Articles \nClose\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500) How Relevance Models Foreshadowed Transformers for NLP ](https://towardsdatascience.com/how-relevance-models-foreshadowed-transformers-for-nlp/ \"How Relevance Models Foreshadowed Transformers for NLP\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500) Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1 ](https://towardsdatascience.com/javascript-fatigue-you-dont-need-js-to-build-chatgpt/ \"Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500) The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs ](https://towardsdatascience.com/subset-sum-problem-solved-in-linear-time-for-dense-enough-inputs/ \"The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500) Does Your Company Have a Data Strategy? ](https://towardsdatascience.com/does-your-company-have-a-data-strategy-e8944dbec4ae/ \"Does Your Company Have a Data Strategy?\")\n\n\n",
  "body_base_path": "attachments/03e30b6796ac/pages/",
  "body_markdown_path": "attachments/03e30b6796ac/pages/archived-body.md",
  "local_html": "attachments/03e30b6796ac/pages/archived-body.html",
  "body_source": "prior_capture"
}