{
  "source_file": "0930",
  "source_platform": "Medium",
  "author": "Muhammad Ardi Putra",
  "title_listed": "SENet Paper Walkthrough: The Channel-Wise Attention",
  "keywords": "",
  "domain": "图像处理",
  "content_type": "深度技术解析",
  "is_paid_flag": "否",
  "url": "https://towardsdatascience.com/the-channel-wise-attention/",
  "publish_date": "2025-08-07",
  "corpus_stage": "",
  "notes": "",
  "id": "7fd7c2cd6fee",
  "collected_at": "2026-10-02T02:45:44",
  "title": "SENet Paper Walkthrough: The Channel-Wise Attention | 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[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\n# SENet Paper Walkthrough: The Channel-Wise Attention\nApplying the Squeeze and Excitation module on ResNeXt using PyTorch\n[Muhammad Ardi Putra](https://towardsdatascience.com/author/muhammad_ardi/)\nAugust 7, 202520 min read\n![](../images/000.jpg)\nPhoto by Clark Van Der Beken on [Unsplash](https://unsplash.com/photos/a-close-up-of-a-row-of-blinds-with-a-sky-background-A1AV-H8ZBaM)\n## Introduction\nWhen we talk about attention in computer vision, one thing that probably comes to your mind first is the one used in the Vision Transformer (ViT) architecture. In fact, that’s not the only attention mechanism we have for image data. There is actually another one called Squeeze and Excitation Network (SENet). If the attention in ViT operates spatially, i.e., assigning weights to different patches of an image, the attention mechanism proposed in SENet operates in channel-wise manner, i.e., assigning weights to different channels. — In this article, we are going to discuss how the Squeeze and Excitation architecture works, how to implement it from scratch, and how to integrate the network into the ResNeXt model.\n···\n## The Squeeze and Excitation Module\nSENet, which was first proposed in a paper titled “ _Squeeze-and-Excitation Networks_ ” by Hu _et al._[1], is not a standalone network like VGG, Inception, or ResNet. Instead, it is actually a building block to be placed on an existing network. In CNN-based models, we assume that pixels spatially close to each other have high correlations, which is the reason that we employ small-sized kernels to capture these correlations. This kind of assumption is basically the _inductive bias_ of CNN. On the other hand, SENet introduces a new inductive bias, where the authors assume that every image channel contributes differently to predicting a specific class. By applying SE modules to a CNN, the model not only relies on spatial patterns but also captures the importance of each channel. To better illustrate this, we can think of an image of fire, where the red channel would theoretically give a higher contribution to the final prediction than the blue and green channels.\nThe structure of the SE module itself is shown in Figure 1. As the name of the network suggests, there are two main steps done in this module: _squeeze_ and _excitation_. The _squeeze_ part corresponds to the operation denoted as _F_sq_ , while the _excitation_ part includes both _F_ex_ and _F_scale_. On the other hand, the _F_tr_ operation, is actually not the part of the SE module. Rather, it represents a transformation function that originally belongs to the model where the SE module is applied. For example, if we were to place this SE module on ResNet, the _F_tr_ operation refers to the stack of convolution layers within the bottleneck block.\n![](../images/001.png)\nFigure 1. The structure of the Squeeze and Excitation module [1].\nTalking more specifically about the _F_sq_ operation, it essentially works by utilizing global average pooling mechanism, where it is used to capture the information from the entire spatial dimension of each channel. By doing so, every channel of the input tensor is going to be represented by a single number, which is basically just the average value of the corresponding channel. The authors refer to this operation as _global information embedding_. Mathematically speaking, this can formally be written in the equation shown in Figure 2, where we basically sum all values across the height _H_ and width _W_ before eventually dividing it with the number of pixels within that channel (_H×W_).\n![](../images/002.png)\nFigure 2. The mathematical expression of the global average pooling mechanism in SE module [1].\nMeanwhile, both excitation and scaling operations are referred to as _adaptive recalibration_ since what they essentially do is to dynamically adjust the weightings of each channel in the input tensor according to its importance. In fact, the diagram in Figure 1 does not completely depict the entire SENet architecture. You can see in the figure that _F_ex_ appears to be a single operation, yet it actually consists of two linear layers each followed by an activation function. See the Figure 3 below for the details.\n![](../images/003.png)\nFigure 3. The mathematical formulation of the _**F_ex**_ operation [1].\nThe two linear layers are denoted as _W_1_ and _W_2_ , whereas _δ_ and _σ_ represent ReLU and sigmoid activation functions, respectively. So, based on this mathematical definition, what we basically need to do later in the implementation is to pass tensor _z_ (the average-pooled tensor) through the first linear layer, followed by the ReLU activation function, the second linear layer, and lastly the sigmoid activation function. Remember that the sigmoid function normalizes input values to be within the range of 0 to 1. In this case, we will perceive the resulting output as the weight of each channel, where a value close to 1 indicates that the corresponding channel contains important information, hence we allow the model to pay more attention to that channel. Otherwise, if the resulting number is close to 0, it indicates that the corresponding channel does not contribute that much to the output.\nIn order to utilize these channel weights, we can perform the _F_scale_ operation, which is basically just a multiplication of the original tensor _u_ and the weight tensor _s_ , as shown in Figure 4 below. By doing this, we essentially retain the values within the important channels while at the same time suppressing the values of the unimportant ones.\n![](../images/body-155f8a7c657c7775b10b.png)\nFigure 4. The scaling process is just a multiplication of the original and the weight tensors [1].\nBy the way sorry for getting a bit too mathy here, lol. But I believe this will help you understand the code later in the implementation section.\n### Where to Put the SE Module\nApplying the SE module on a plain CNN model like VGG is easy, as we can simply place it right after each convolution layer. However, it might not be straightforward in the case of Inception or ResNet thanks to the presence of parallel branches in these two networks. To address this confusion, authors provide a guide to implement the SE module specifically on the two models as shown in Figure 5 below.\n![](../images/body-11b27c0707e699b3ad1a.png)\nFigure 5. Where SE module is placed in Inception and ResNet [1].\nFor the Inception model, instead of placing SE module right after each convolution layer, we pass the input tensor through the entire Inception block (including all the branches inside) and then attach the SE module afterwards. The same approach also works for ResNet, but keep in mind that the summation between the tensor in skip connection and the main flow happens after the main tensor has been processed by the SE module.\nAs I mentioned earlier, the excitation stage essentially consists of two linear layers. If we take a closer look at the above structure, we can see that the output shape of the first linear layer is 1×1×C/_r_. The variable _r_ is called _reduction ratio_ which reduces the dimensionality of the weight tensor before eventually projecting it back to 1×1×C through the second linear layer. The dimensionality reduction done by the first layer acts as a _bottleneck_ operation, which is useful to limit model complexity and to improve generalization. Authors conducted experiments on different _r_ values, and they found that _r_ = 16 produces the best balance between accuracy and complexity.\n![](../images/body-0711b30ddbf892664a22.png)\nFigure 6. Several ways possible to be used to attach SE module in ResNet [1].\nIn addition to implementing the SE module in ResNet, it is seen in Figure 6 that there are actually several ways we can follow to do so. According to the experimental results in Figure 7, it looks like the standard SE, SE-PRE, and SE-Identity blocks obtained similar results, while at the same time all of them outperformed SE-POST by a significant margin. This suggests that the placement of the SE module affects model performance in terms of accuracy. Based on these findings, the authors argue that we are going to obtain good results as long as we apply the SE module before the element-wise summation operation. Later in the coding section, I am going to demonstrate how to implement the standard SE block.\n![](../images/body-394757ee65007456fc92.png)\nFigure 7. Experimental results on different SE module integration strategies [1].\n### More Experimental Results\nThere are actually a lot more experimental results discussed in the paper. One of them is a table displaying accuracy score improvements when SE module is applied to existing CNN-based models. The table I am referring to is displayed in Figure 8 below.\n![](../images/body-67c0b29eb48d109d7ba8.png)\nFigure 8. Experimental results on applying SE module on different models [1][2].\nThe columns highlighted in blue represent the error rates of each model and the ones in pink indicate the computational complexity measured in GFLOPs. The _re-implementation_ column refers to the plain model that the authors implemented themselves, whereas the _SENet_ column represents the same model equipped with SE module. The table clearly shows that both top-1 and top-5 errors decrease when the SE module is applied. It is important to know that although adding the SE module causes the GFLOPs to get higher, yet this increase is considerably marginal compared to the reduction in error rate.\nNext, we can actually reveal interesting insights by printing out the values contained in the SE modules during the inference phase. Let’s take a look at the charts in Figure 9 below to better illustrate this. The _x_ axis of these charts denotes the channel numbers, the _y_ axis represents how much weight does each channel have according to its importance, and the color of the lines indicates the class being predicted.\n![](../images/body-f4187100262c33a51cb1.png)\nFigure 9. What the activation of SE modules looks like in different network depth [1].\nIn shallower layers, the features captured by SE module are _class-agnostic_ , which basically means that it captures generic information required to predict all classes. The charts referred to as (a) and (b), which are the SE modules from ResNet stage 2 and 3, show that there is not much difference in channel activity from one class to another, indicating that these two modules do not capture information regarding a specific class. The case is actually different from the SE modules in deeper layers, i.e., the ones in stage 4 (c) and stage 5 (d). We can see that these two modules adjust channel weights differently depending on the class being predicted. This is essentially the reason that the SE modules in deeper layers are said to be _class-specific_. However, the authors acknowledge that there might be unusual behavior happening in some of the SE modules which happens in the 2nd block of stage 5 (e). Here the SE module does not show meaningful channel recalibration behavior, indicating that it does not contribute as much as the ones we discussed earlier.\n### The Detailed Architecture\nIn this article we are going to implement the _SE-ResNeXt-50 (32×4d)_ model, which in Figure 10 it corresponds to the one in the rightmost column. The ResNeXt model itself is similar to ResNet, except that the group parameter of the second convolution layer within each block is set to 32. If you’re familiar with ResNeXt, this is essentially the simplest yet effective way to implement the so-called _cardinality_. I recommend you read my previous article about ResNeXt if you are not yet familiar with it, which the link is provided at reference number [3] at the end of this article.\nTaking a closer look at the architecture, what differentiates _SE-ResNet-50_ from _ResNet-50_ is solely the presence of SE modules. The same also applies to _SE-ResNeXt-50 (32×4d)_ compared to _ResNeXt-50 (32×4d)_ (not displayed in the table). Notice in the figure below that the models with SE modules have an _fc_ layer attached after the last convolution layer within each block, which the corresponding two numbers indicate the first and second fully-connected layers inside the SE module.\n![](../images/body-cdcf024c31c301834aa4.png)\nFigure 10. The complete architecture of ResNet-50, SE-ResNet-50 and SE-ResNeXt-50 (32×4d) [1].\n···\n## From Scratch Implementation\nRemember that here we are about to integrate the SE module on ResNeXt, so we need to implement both of them from scratch. Technically speaking, it is actually possible to take the ResNeXt architecture directly from PyTorch, then manually attach the SE module on it. However, here I decided to use the ResNeXt implementation from my previous article instead since I feel like it is a lot easier to understand than the one from PyTorch. Note that here I will focus on constructing the SE module and how to attach it to the ResNeXt model rather than explaining the ResNeXt itself since I’ve already covered it in that article [3].\nNow let’s start the code by importing the required modules.\npython\n\n```\n# Codeblock 1\nimport torch\nimport torch.nn as nn\n```\n\n### Squeeze and Excitation Module\nThe following SE module implementation follows the diagram shown in Figure 5 (right). It is worth noting that the `SEModule` class below does not include the skip-connection (curved arrow), as the entire SE module is applied after the initial branching but before the merging (summation).\nThe `__init__()` method of this class accepts two parameters: `num_channels` and `r`, as shown at line `#(1)` in Codeblock 2a. We definitely want this SE module to be usable throughout the entire network. So, we need to set the `num_channels` parameter to be adjustable because the number of output channels varies across ResNeXt blocks at different stages, as shown back in Figure 10. Meanwhile, even though we typically use the same reduction ratio _r_ in the SE modules within the entire network, but it is technically possible for us to use different `r` for different stage, which might probably be an interesting thing to experiment with. So, this is essentially the reason that I also set the `r` parameter to be adjustable.\npython\n\n```\n# Codeblock 2a\nclass SEModule(nn.Module):\n    def __init__(self, num_channels, r):                     #(1)\n        super().__init__()\n        \n        self.global_pooling = nn.AdaptiveAvgPool2d(output_size=(1,1))  #(2)\n        self.fc0 = nn.Linear(in_features=num_channels,       #(3)\n                             out_features=num_channels//r, \n                             bias=False)\n        self.relu = nn.ReLU()                                #(4)\n        self.fc1 = nn.Linear(in_features=num_channels//r,    #(5)\n                             out_features=num_channels, \n                             bias=False)\n        self.sigmoid = nn.Sigmoid()                          #(6)\n```\n\nThere are 5 layers we need to initialize inside the `__init__()` method. I write them down according to the sequence given in Figure 5, i.e., global average pooling layer (`#(2)`), linear layer (`#(3)`), ReLU activation function (`#(4)`), another linear layer (`#(5)`), and sigmoid activation function (`#(6)`). Here you can see that the first linear layer is responsible to perform dimensionality reduction by shrinking the number of channels from `num_channels` to `num_channels//r`, which will then be expanded back to `num_channels` by the second linear layer. Note that we set the bias term of both linear layers to `False`, which essentially means that we will only utilize the weight tensors. The absence of bias terms in the two layers forces the SE module to learn the correlation between one channel to the others rather than just adding fixed adjustments.\nStill with the `SEModule` class, let’s now move on to the `forward()` method to define the flow of the network. You can see at line `#(1)` in Codeblock 2b that we start from a single input `x`, which in the case of ResNeXt it is essentially a tensor produced by the third convolution layer within the same ResNeXt block. As shown in Figure 5, what we need to do next is to branch out the network. Here we directly process the branch using the `global_pooling` layer, which I name the resulting tensor `squeezed` (`#(2)`). The original input tensor `x` itself will be left as is since we are not going to perform any operation on it until the scaling phase. Next, we need to drop the spatial dimension of the `squeezed` tensor using `torch.flatten()` (`#(3)`). This is basically done because we want to process it further with the linear layers at line `#(4)` and `#(5)`, which can only work with a single-dimensional tensor. The spatial dimension is then introduced again at line `#(6)`, allowing us to perform multiplication between `x` (the original tensor) and `excited` (the channel weights) at line `#(7)`. This entire process produces a recalibrated version of `x` which we refer to as `scaled`. Here I print out the tensor dimension after each step so that you can better understand the flow of this SE module.\npython\n\n```\n# Codeblock 2b\n    def forward(self, x):                                  #(1)\n        print(f'original\\t\\t: {x.size()}')\n        \n        squeezed = self.global_pooling(x)                  #(2)\n        print(f'after avgpool\\t\\t: {squeezed.size()}')\n        \n        squeezed = torch.flatten(squeezed, 1)              #(3)\n        print(f'after flatten\\t\\t: {squeezed.size()}')\n        \n        excited = self.relu(self.fc0(squeezed))            #(4)\n        print(f'after fc0-relu\\t\\t: {excited.size()}')\n        \n        excited = self.sigmoid(self.fc1(excited))          #(5)\n        print(f'after fc1-sigmoid\\t: {excited.size()}')\n        \n        excited = excited[:, :, None, None]                #(6)\n        print(f'after reshape\\t\\t: {excited.size()}')\n        \n        scaled = x * excited                               #(7)\n        print(f'after scaling\\t\\t: {scaled.size()}')\n        \n        return scaled\n```\n\nNow we are going to see if we have implemented the network correctly by passing a dummy tensor through it. In Codeblock 3 below, I initialize an SE module and configure it to accept an image tensor of 512 channels and has a reduction ratio of 16 (`#(1)`). If you take a look at the SE-ResNeXt architecture in Figure 10, this SE module basically corresponds to the one in the third stage (which the output size is 28×28). Thus, at line `#(2)` we need to adjust the shape of the dummy tensor accordingly. We then feed this tensor into the network using the code at line `#(3)`.\npython\n\n```\n# Codeblock 3\nsemodule = SEModule(num_channels=512, r=16)    #(1)\nx = torch.randn(1, 512, 28, 28)                #(2)\n\nout = semodule(x)      #(3)\n```\n\nAnd below is what the print functions give us.\nmarkup\n\n```\n# Codeblock 3 Outputoriginal          : torch.Size([1, 512, 28, 28])    #(1)after avgpool     : torch.Size([1, 512, 1, 1])      #(2)after flatten     : torch.Size([1, 512])            #(3)after fc0-relu    : torch.Size([1, 32])             #(4)after fc1-sigmoid : torch.Size([1, 512])            #(5)after reshape     : torch.Size([1, 512, 1, 1])      #(6)after scaling     : torch.Size([1, 512, 28, 28])    #(7)\n```\n\nYou can see that the original tensor shape matches exactly with our dummy tensor, i.e., 1×512×28×28 (`#(1)`). By the way we can ignore the number 1 in the 0th axis since it essentially denotes the batch size, which in this case I assume that we only got a single image in a batch. After being pooled, the spatial dimension collapses to 1×1 since now each channel is represented by a single number (`#(2)`). The purpose of the flatten operation I explained earlier is to drop the two empty axes (`#(3)`) since the subsequent linear layers can only work with single-dimensional tensor. Here you can see that the first linear layer reduces the tensor dimension to 32 thanks to the reduction ratio which we previously set to 16 (`#(4)`). The length of this tensor is then expanded back to 512 by the second linear layer (`#(5)`). Next, we unsqueeze the tensor so that we get our 1×1 spatial dimension back (`#(6)`), allowing us to multiply it with the input tensor (`#(7)`). Based on this detailed flow, you can see that an SE module basically preserves the original tensor dimension, proving that this module can be attached to any CNN-based model without disrupting the original flow of the network.\n#### ResNeXt\nAs we have understood how to implement SE module from scratch, now that I am going to show you how we can attach it on a ResNeXt model. Before doing so, we need to initialize the parameters required to implement the ResNeXt architecture. In the Codeblock 4 below the first four variables are determined according to the _ResNeXt-50 (32×4d)_ variant, whereas the last one (`R`) represents the reduction ratio for the SE modules.\npython\n\n```\n# Codeblock 4\nCARDINALITY  = 32\nNUM_CHANNELS = [3, 64, 256, 512, 1024, 2048]\nNUM_BLOCKS   = [3, 4, 6, 3]\nNUM_CLASSES  = 1000\nR = 16\n```\n\nThe `Block` class defined in Codeblock 5a and 5b is the ResNeXt block from my previous article. There are actually lots of things we do inside the `__init__()` method, but the general idea is that we initialize three convolution layers referred to as `conv0` (`#(1)`), `conv1` (`#(2)`), and `conv2` (`#(3)`) before initializing the SE module at line `#(4)`. We will later configure these layers according to the SE-ResNeXt architecture shown back in Figure 10.\npython\n\n```\n# Codeblock 5a\nclass Block(nn.Module):\n    def __init__(self, \n                 in_channels,\n                 add_channel=False,\n                 channel_multiplier=2,\n                 downsample=False):\n        super().__init__()\n\n        self.add_channel = add_channel\n        self.channel_multiplier = channel_multiplier\n        self.downsample = downsample\n        \n        \n        if self.add_channel:\n            out_channels = in_channels*self.channel_multiplier\n        else:\n            out_channels = in_channels\n        \n        mid_channels = out_channels//2\n        \n        \n        if self.downsample:\n            stride = 2\n        else:\n            stride = 1\n            \n\n        if self.add_channel or self.downsample:\n            self.projection = nn.Conv2d(in_channels=in_channels,\n                                        out_channels=out_channels, \n                                        kernel_size=1, \n                                        stride=stride, \n                                        padding=0, \n                                        bias=False)\n            nn.init.kaiming_normal_(self.projection.weight, nonlinearity='relu')\n            self.bn_proj = nn.BatchNorm2d(num_features=out_channels)\n\n        self.conv0 = nn.Conv2d(in_channels=in_channels,       #(1)\n                               out_channels=mid_channels,\n                               kernel_size=1, \n                               stride=1, \n                               padding=0, \n                               bias=False)\n        nn.init.kaiming_normal_(self.conv0.weight, nonlinearity='relu')\n        self.bn0 = nn.BatchNorm2d(num_features=mid_channels)\n\n        self.conv1 = nn.Conv2d(in_channels=mid_channels,      #(2)\n                               out_channels=mid_channels, \n                               kernel_size=3, \n                               stride=stride,\n                               padding=1, \n                               bias=False, \n                               groups=CARDINALITY)\n        nn.init.kaiming_normal_(self.conv1.weight, nonlinearity='relu')\n        self.bn1 = nn.BatchNorm2d(num_features=mid_channels)\n\n        self.conv2 = nn.Conv2d(in_channels=mid_channels,      #(3)\n                               out_channels=out_channels,\n                               kernel_size=1, \n                               stride=1, \n                               padding=0, \n                               bias=False)\n        nn.init.kaiming_normal_(self.conv2.weight, nonlinearity='relu')\n        self.bn2 = nn.BatchNorm2d(num_features=out_channels)\n        \n        self.relu = nn.ReLU()\n        \n        self.semodule = SEModule(num_channels=out_channels, r=R)    #(4)\n```\n\nThe `forward()` method itself is generally also the same as the original ResNeXt model, except that here we need to put the SE module right before the element-wise summation as shown at line `#(1)` in the Codeblock 5b below. Remember that this implementation follows the standard SE block architecture in Figure 6 (b).\npython\n\n```\n# Codeblock 5b\n    def forward(self, x):\n        print(f'original\\t\\t: {x.size()}')\n        \n        if self.add_channel or self.downsample:\n            residual = self.bn_proj(self.projection(x))\n            print(f'after projection\\t: {residual.size()}')\n        else:\n            residual = x\n            print(f'no projection\\t\\t: {residual.size()}')\n        \n        x = self.conv0(x)\n        x = self.bn0(x)\n        x = self.relu(x)\n        print(f'after conv0-bn0-relu\\t: {x.size()}')\n\n        x = self.conv1(x)\n        x = self.bn1(x)\n        x = self.relu(x)\n        print(f'after conv1-bn1-relu\\t: {x.size()}')\n        \n        x = self.conv2(x)\n        x = self.bn2(x)\n        print(f'after conv2-bn2\\t\\t: {x.size()}')\n        \n        x = self.semodule(x)      #(1)\n        print(f'after semodule\\t\\t: {x.size()}')\n        \n        x = x + residual\n        x = self.relu(x)\n        print(f'after summation\\t\\t: {x.size()}')\n        \n        return x\n```\n\nWith the above implementation, every time we instantiate a `Block` object we will have a ResNeXt block which is already equipped with an SE module. Now we are going to test the above class to see if we have implemented it correctly. Here I am going to simulate a ResNeXt block within the third stage. The `add_channel` and `downsample` parameters are set to `False` since we want to preserve both the number of channels and the spatial dimension of the input tensor.  \n\npython\n\n```\n# Codeblock 6\nblock = Block(in_channels=512, add_channel=False, downsample=False)\nx = torch.randn(1, 512, 28, 28)\n\nout = block(x)\n```\n\nBelow is what the output looks like. Here you can see that our first convolution layer successfully reduced the number of channels from 512 to 256 (`#(1)`), which is then expanded back to its original dimension by the third convolution layer (`#(2)`). Afterwards, the tensor goes through the SE block which the resulting output size is the same as its input, just like what we saw earlier in Codeblock 3 (`#(3)`). As the processing with SE module is done, we can finally perform the element-wise summation between the tensor from the main branch and the one from the skip-connection (`#(4)`).\nmarkup\n\n```\noriginal             : torch.Size([1, 512, 28, 28])no projection        : torch.Size([1, 512, 28, 28])after conv0-bn0-relu : torch.Size([1, 256, 28, 28])    #(1)after conv1-bn1-relu : torch.Size([1, 256, 28, 28])after conv2-bn2      : torch.Size([1, 512, 28, 28])    #(2)after semodule       : torch.Size([1, 512, 28, 28])    #(3)after summation      : torch.Size([1, 512, 28, 28])    #(4)\n```\n\nAnd below is how I implement the entire architecture. What we essentially need to do is just to stack multiple SE-ResNeXt blocks according to the architecture in Figure 10. In fact, the `SEResNeXt` class in Codeblock 7 is exactly the same as the `ResNeXt` class in my previous article [3] (I literally copy-pasted it) since what makes SE-ResNeXt different from the original ResNeXt is only the presence of SE module within the `Block` class we discussed earlier.\npython\n\n```\n# Codeblock 7\nclass SEResNeXt(nn.Module):\n    def __init__(self):\n        super().__init__()\n\n        # conv1 stage\n        self.resnext_conv1 = nn.Conv2d(in_channels=NUM_CHANNELS[0],\n                                       out_channels=NUM_CHANNELS[1],\n                                       kernel_size=7,\n                                       stride=2,\n                                       padding=3, \n                                       bias=False)\n        nn.init.kaiming_normal_(self.resnext_conv1.weight, \n                                nonlinearity='relu')\n        self.resnext_bn1 = nn.BatchNorm2d(num_features=NUM_CHANNELS[1])\n        self.relu = nn.ReLU()\n        self.resnext_maxpool1 = nn.MaxPool2d(kernel_size=3,\n                                             stride=2, \n                                             padding=1)\n\n        # conv2 stage\n        self.resnext_conv2 = nn.ModuleList([\n            Block(in_channels=NUM_CHANNELS[1],\n                  add_channel=True,\n                  channel_multiplier=4,\n                  downsample=False)\n        ])\n        for _ in range(NUM_BLOCKS[0]-1):\n            self.resnext_conv2.append(Block(in_channels=NUM_CHANNELS[2]))\n\n        # conv3 stage\n        self.resnext_conv3 = nn.ModuleList([Block(in_channels=NUM_CHANNELS[2],\n                                                  add_channel=True, \n                                                  downsample=True)])\n        for _ in range(NUM_BLOCKS[1]-1):\n            self.resnext_conv3.append(Block(in_channels=NUM_CHANNELS[3]))\n            \n            \n        # conv4 stage\n        self.resnext_conv4 = nn.ModuleList([Block(in_channels=NUM_CHANNELS[3],\n                                                  add_channel=True, \n                                                  downsample=True)])\n        \n        for _ in range(NUM_BLOCKS[2]-1):\n            self.resnext_conv4.append(Block(in_channels=NUM_CHANNELS[4]))\n            \n            \n        # conv5 stage\n        self.resnext_conv5 = nn.ModuleList([Block(in_channels=NUM_CHANNELS[4],\n                                                  add_channel=True, \n                                                  downsample=True)])\n        \n        for _ in range(NUM_BLOCKS[3]-1):\n            self.resnext_conv5.append(Block(in_channels=NUM_CHANNELS[5]))\n \n       \n        self.avgpool = nn.AdaptiveAvgPool2d(output_size=(1,1))\n\n        self.fc = nn.Linear(in_features=NUM_CHANNELS[5],\n                            out_features=NUM_CLASSES)\n        \n\n    def forward(self, x):\n        print(f'original\\t\\t: {x.size()}')\n        \n        x = self.relu(self.resnext_bn1(self.resnext_conv1(x)))\n        print(f'after resnext_conv1\\t: {x.size()}')\n        \n        x = self.resnext_maxpool1(x)\n        print(f'after resnext_maxpool1\\t: {x.size()}')\n        \n        for i, block in enumerate(self.resnext_conv2):\n            x = block(x)\n            print(f'after resnext_conv2 #{i}\\t: {x.size()}')\n            \n        for i, block in enumerate(self.resnext_conv3):\n            x = block(x)\n            print(f'after resnext_conv3 #{i}\\t: {x.size()}')\n            \n        for i, block in enumerate(self.resnext_conv4):\n            x = block(x)\n            print(f'after resnext_conv4 #{i}\\t: {x.size()}')\n            \n        for i, block in enumerate(self.resnext_conv5):\n            x = block(x)\n            print(f'after resnext_conv5 #{i}\\t: {x.size()}')\n        \n        x = self.avgpool(x)\n        print(f'after avgpool\\t\\t: {x.size()}')\n        \n        x = torch.flatten(x, start_dim=1)\n        print(f'after flatten\\t\\t: {x.size()}')\n        \n        x = self.fc(x)\n        print(f'after fc\\t\\t: {x.size()}')\n        \n        return x\n```\n\nAs the entire _SE-ResNeXt-50 (32×4d)_ architecture is completed, now that we are going to test it by passing through a tensor of size 1×3×224×224 through the network, simulating a single RGB image of size 224×224. You can see in the output of the Codeblock 8 below that it seems like model works properly since the tensor successfully passed through all layers within the `seresnext` model without returning any error. Thus, I believe this model is now ready to be trained. By the way don’t forget to change the number of neurons in the output channel according to the number of classes in your dataset if you want to actually train this model.\npython\n\n```\n# Codeblock 8\nseresnext = SEResNeXt()\nx = torch.randn(1, 3, 224, 224)\n\nout = seresnext(x)\n```\n\nmarkup\n\n```\n# Codeblock 8 Outputoriginal               : torch.Size([1, 3, 224, 224])after resnext_conv1    : torch.Size([1, 64, 112, 112])after resnext_maxpool1 : torch.Size([1, 64, 56, 56])after resnext_conv2 #0 : torch.Size([1, 256, 56, 56])after resnext_conv2 #1 : torch.Size([1, 256, 56, 56])after resnext_conv2 #2 : torch.Size([1, 256, 56, 56])after resnext_conv3 #0 : torch.Size([1, 512, 28, 28])after resnext_conv3 #1 : torch.Size([1, 512, 28, 28])after resnext_conv3 #2 : torch.Size([1, 512, 28, 28])after resnext_conv3 #3 : torch.Size([1, 512, 28, 28])after resnext_conv4 #0 : torch.Size([1, 1024, 14, 14])after resnext_conv4 #1 : torch.Size([1, 1024, 14, 14])after resnext_conv4 #2 : torch.Size([1, 1024, 14, 14])after resnext_conv4 #3 : torch.Size([1, 1024, 14, 14])after resnext_conv4 #4 : torch.Size([1, 1024, 14, 14])after resnext_conv4 #5 : torch.Size([1, 1024, 14, 14])after resnext_conv5 #0 : torch.Size([1, 2048, 7, 7])after resnext_conv5 #1 : torch.Size([1, 2048, 7, 7])after resnext_conv5 #2 : torch.Size([1, 2048, 7, 7])after avgpool          : torch.Size([1, 2048, 1, 1])after flatten          : torch.Size([1, 2048])after fc               : torch.Size([1, 1000])\n```\n\nAdditionally, we can also print out the number of parameters this model has using the following code. Here you can see that the codeblock returns 27,543,848. This number of parameters is slightly higher than the original ResNeXt model counterpart, which only has 25,028,904 parameters as mentioned in my previous article as well as the official PyTorch documentation [4]. Such an increase in the model size definitely makes sense since the ResNeXt blocks throughout the entire network now have more layers thanks to the presence of SE modules.\npython\n\n```\n# Codeblock 9\ndef count_parameters(model):\n    return sum([params.numel() for params in model.parameters()])\n\ncount_parameters(seresnext)\n```\n\nmarkup\n\n```\n# Codeblock 9 Output27543848\n```\n\n···\n## Ending\nAnd that’s pretty much everything about the Squeeze and Excitation module. I do encourage you to explore from here by training this model on your own dataset so that you will see whether the findings presented in the paper also apply to your case. Not only that, I think it would also be interesting if you try to implement SE module on other neural network architectures like VGG or Inception by yourself.\nI hope you learn something new today. Thanks for reading!\n_By the way you can also find the code used in this article in my GitHub repo [5]._\n···\n[1] Jie Hu _et al._ Squeeze and Excitation Networks. Arxiv. <https://arxiv.org/abs/1709.01507> [Accessed March 17, 2025].\n[2] Image originally created by author.\n[3] Taking ResNet to the Next Level. Towards Data Science. <https://towardsdatascience.com/taking-resnet-to-the-next-level/> [Accessed July 22, 2025].\n[4] Resnext50_32x4d. PyTorch. <https://pytorch.org/vision/main/models/generated/torchvision.models.resnext50_32x4d.html#torchvision.models.resnext50_32x4d> [Accessed March 17, 2025].\n[5] MuhammadArdiPutra. The Channel-Wise Attention — Squeeze and Excitation. GitHub. <https://github.com/MuhammadArdiPutra/medium_articles/blob/main/The%20Channel-Wise%20Attention%20-%20Squeeze%20and%20Excitation.ipynb> [Accessed April 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/)[Computer Vision](https://towardsdatascience.com/tag/computer-vision/)[Machine Learning](https://towardsdatascience.com/tag/machine-learning/)[Neural Network](https://towardsdatascience.com/tag/neural-network/)[Pytorch](https://towardsdatascience.com/tag/pytorch/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Fthe-channel-wise-attention%2F&title=SENet%20Paper%20Walkthrough%3A%20The%20Channel-Wise%20Attention)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Fthe-channel-wise-attention%2F&title=SENet%20Paper%20Walkthrough%3A%20The%20Channel-Wise%20Attention)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Fthe-channel-wise-attention%2F&text=SENet%20Paper%20Walkthrough%3A%20The%20Channel-Wise%20Attention)\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/004.jpg)](https://towardsdatascience.com/understanding-probability-models-and-axioms-c0f498972b80/)\n## [Understanding Probability Models and Axioms](https://towardsdatascience.com/understanding-probability-models-and-axioms-c0f498972b80/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nWhy even care about sample space, events, and probability measures?\n[Marvin Lanhenke](https://towardsdatascience.com/author/marvinlanhenke/)\nDecember 18, 20217 min read\n  * [![](../images/005.png)](https://towardsdatascience.com/nlp-splitting-text-into-sentences-7bbce222ef17/)\n## [NLP: Splitting Text into Sentences](https://towardsdatascience.com/nlp-splitting-text-into-sentences-7bbce222ef17/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nLanguage agnostic model for transforming text into sentences\n[Moran Beladev](https://towardsdatascience.com/author/moranbeladev90/)\nAugust 1, 20214 min read\n  * [![](../images/006.jpg)](https://towardsdatascience.com/how-to-better-deploy-your-machine-learning-model-6f179483a289/)\n## [How to Better Deploy Your Machine Learning Model](https://towardsdatascience.com/how-to-better-deploy-your-machine-learning-model-6f179483a289/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nMy argument against homemade solutions and an alternative proposal\n[Amine Elhattami](https://towardsdatascience.com/author/amine-elhattami/)\nMarch 24, 20226 min read\n  * [![](../images/007.png)](https://towardsdatascience.com/a-unified-view-of-graph-neural-networks-12b40e8fdac5/)\n## [A unified view of Graph Neural Networks](https://towardsdatascience.com/a-unified-view-of-graph-neural-networks-12b40e8fdac5/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nGraph attention, graph convolution, network propagation are all special cases of message passing in graph neural networks.\n[Remy Lau](https://towardsdatascience.com/author/remylau961/)\nJune 27, 20213 min read\n  * [![](../images/008.jpg)](https://towardsdatascience.com/the-math-behind-recurrent-neural-networks-2de4e0098ab8/)\n## [The Math Behind Recurrent Neural Networks](https://towardsdatascience.com/the-math-behind-recurrent-neural-networks-2de4e0098ab8/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nDive into RNNs, the backbone of time series, understand their mathematics, implement them from scratch, and explore their applications\n[Cristian Leo](https://towardsdatascience.com/author/cristianleo120/)\nApril 27, 202423 min read\n  * [![](../images/009.png)](https://towardsdatascience.com/part-1-building-a-deep-q-network-to-play-gridworld-deepminds-deep-q-networks-78842007c631/)\n## [Part 1 - Building a deep Q-network to play Gridworld - DeepMind's deep Q-networks](https://towardsdatascience.com/part-1-building-a-deep-q-network-to-play-gridworld-deepminds-deep-q-networks-78842007c631/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nIn this article let's build a Deep Q-network similar to the DeepMind's Atari agent to play Gridworld problem. We will build virtually the...\n[NandaKishore Joshi](https://towardsdatascience.com/author/nandakishorej8/)\nDecember 5, 202115 min read\n  * [![](../images/body-63beb50f664a055ed739.jpg)](https://towardsdatascience.com/fine-tuning-pre-trained-model-vgg-16-1277268c537f/)\n## [Fine-Tuning Pre-trained Model VGG-16](https://towardsdatascience.com/fine-tuning-pre-trained-model-vgg-16-1277268c537f/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nIn my previous article, I explored using the pre-trained model VGG-16 as a feature extractor for transfer learning on the RAVDESS Audio...\n[Muriel Kosaka](https://towardsdatascience.com/author/murielsayaka/)\nNovember 10, 20204 min read\n  * [![](../images/011.jpg)](https://towardsdatascience.com/the-importance-of-branding-in-data-science-467b2d2b1e7f/)\n## [The Importance of Branding in Data Science](https://towardsdatascience.com/the-importance-of-branding-in-data-science-467b2d2b1e7f/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nRecently, One topic in-particular has been reoccurring in my discussions with friends. The importance of branding! I was not going to...\n[Kurtis Pykes](https://towardsdatascience.com/author/kurtispykes/)\nOctober 13, 20208 min read\n  * [![](../images/012.jpg)](https://towardsdatascience.com/top-python-libraries-for-image-augmentation-in-computer-vision-2566bed0533e/)\n## [Top Python libraries for Image Augmentation in Computer Vision](https://towardsdatascience.com/top-python-libraries-for-image-augmentation-in-computer-vision-2566bed0533e/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nFeaturing the best augmentation libraries (along with sample codes) for your next computer vision project\n[Kenneth Leung](https://towardsdatascience.com/author/kennethleungty/)\nAugust 2, 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": "SENet Paper Walkthrough: The Channel-Wise Attention | Towards Data Science",
    "description": "Applying the Squeeze and Excitation module on ResNeXt using PyTorch",
    "keywords": null,
    "author": "Muhammad Ardi Putra",
    "og:locale": "en_US",
    "og:type": "article",
    "og:title": "SENet Paper Walkthrough: The Channel-Wise Attention",
    "og:description": "Applying the Squeeze and Excitation module on ResNeXt using PyTorch",
    "og:url": "https://towardsdatascience.com/the-channel-wise-attention/",
    "og:site_name": "Towards Data Science",
    "og:image": "https://assets.insightmediagroup.io/media/wp-content/uploads/2025/08/clark-van-der-beken-A1AV-H8ZBaM-unsplash-scaled-1.jpg",
    "og:image:width": "2560",
    "og:image:height": "1707",
    "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": "20 min read",
    "article:published_time": "2025-08-07T11:14:23.000Z",
    "article:modified_time": "2025-08-07T11:14:23.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/7fd7c2cd6fee/code/block_000.txt",
      "chars": 49
    },
    {
      "language": "txt",
      "file": "attachments/7fd7c2cd6fee/code/block_001.txt",
      "chars": 683
    },
    {
      "language": "txt",
      "file": "attachments/7fd7c2cd6fee/code/block_002.txt",
      "chars": 919
    },
    {
      "language": "txt",
      "file": "attachments/7fd7c2cd6fee/code/block_003.txt",
      "chars": 147
    },
    {
      "language": "txt",
      "file": "attachments/7fd7c2cd6fee/code/block_004.txt",
      "chars": 413
    },
    {
      "language": "txt",
      "file": "attachments/7fd7c2cd6fee/code/block_005.txt",
      "chars": 132
    },
    {
      "language": "txt",
      "file": "attachments/7fd7c2cd6fee/code/block_006.txt",
      "chars": 2719
    },
    {
      "language": "txt",
      "file": "attachments/7fd7c2cd6fee/code/block_007.txt",
      "chars": 962
    },
    {
      "language": "txt",
      "file": "attachments/7fd7c2cd6fee/code/block_008.txt",
      "chars": 130
    },
    {
      "language": "txt",
      "file": "attachments/7fd7c2cd6fee/code/block_009.txt",
      "chars": 390
    },
    {
      "language": "txt",
      "file": "attachments/7fd7c2cd6fee/code/block_010.txt",
      "chars": 3717
    },
    {
      "language": "txt",
      "file": "attachments/7fd7c2cd6fee/code/block_011.txt",
      "chars": 90
    },
    {
      "language": "txt",
      "file": "attachments/7fd7c2cd6fee/code/block_012.txt",
      "chars": 1175
    },
    {
      "language": "txt",
      "file": "attachments/7fd7c2cd6fee/code/block_013.txt",
      "chars": 138
    },
    {
      "language": "txt",
      "file": "attachments/7fd7c2cd6fee/code/block_014.txt",
      "chars": 29
    }
  ],
  "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:55:56Z"
    },
    {
      "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:55:56Z"
    },
    {
      "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:55:56Z"
    },
    {
      "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:55:56Z"
    }
  ],
  "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/deep-learning/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/muhammad_ardi/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/taking-resnet-to-the-next-level/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/deep-dives/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/computer-vision/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/machine-learning/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/neural-network/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/pytorch/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/understanding-probability-models-and-axioms-c0f498972b80/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/artificial-intelligence/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/marvinlanhenke/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/nlp-splitting-text-into-sentences-7bbce222ef17/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/moranbeladev90/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/how-to-better-deploy-your-machine-learning-model-6f179483a289/"
    },
    {
      "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-close-up-of-a-row-of-blinds-with-a-sky-background-A1AV-H8ZBaM"
    },
    {
      "type": "external",
      "href": "https://arxiv.org/abs/1709.01507"
    },
    {
      "type": "external",
      "href": "https://pytorch.org/vision/main/models/generated/torchvision.models.resnext50_32x4d.html"
    },
    {
      "type": "external",
      "href": "https://github.com/MuhammadArdiPutra/medium_articles/blob/main/The%20Channel-Wise%20Attention%20-%20Squeeze%20and%20Excitation.ipynb"
    },
    {
      "type": "external",
      "href": "https://www.facebook.com/sharer/sharer.php?title=SENet+Paper+Walkthrough%3A+The+Channel-Wise+Attention&u=https%3A%2F%2Ftowardsdatascience.com%2Fthe-channel-wise-attention%2F"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/shareArticle?mini=true&title=SENet+Paper+Walkthrough%3A+The+Channel-Wise+Attention&url=https%3A%2F%2Ftowardsdatascience.com%2Fthe-channel-wise-attention%2F"
    },
    {
      "type": "external",
      "href": "https://x.com/share?text=SENet+Paper+Walkthrough%3A+The+Channel-Wise+Attention&url=https%3A%2F%2Ftowardsdatascience.com%2Fthe-channel-wise-attention%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:34Z",
  "source_url": "https://towardsdatascience.com/the-channel-wise-attention/",
  "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[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\n# SENet Paper Walkthrough: The Channel-Wise Attention\nApplying the Squeeze and Excitation module on ResNeXt using PyTorch\n[Muhammad Ardi Putra](https://towardsdatascience.com/author/muhammad_ardi/)\nAugust 7, 202520 min read\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/08/clark-van-der-beken-A1AV-H8ZBaM-unsplash-scaled-1.jpg)\nPhoto by Clark Van Der Beken on [Unsplash](https://unsplash.com/photos/a-close-up-of-a-row-of-blinds-with-a-sky-background-A1AV-H8ZBaM)\n## Introduction\nWhen we talk about attention in computer vision, one thing that probably comes to your mind first is the one used in the Vision Transformer (ViT) architecture. In fact, that’s not the only attention mechanism we have for image data. There is actually another one called Squeeze and Excitation Network (SENet). If the attention in ViT operates spatially, i.e., assigning weights to different patches of an image, the attention mechanism proposed in SENet operates in channel-wise manner, i.e., assigning weights to different channels. — In this article, we are going to discuss how the Squeeze and Excitation architecture works, how to implement it from scratch, and how to integrate the network into the ResNeXt model.\n···\n## The Squeeze and Excitation Module\nSENet, which was first proposed in a paper titled “ _Squeeze-and-Excitation Networks_ ” by Hu _et al._[1], is not a standalone network like VGG, Inception, or ResNet. Instead, it is actually a building block to be placed on an existing network. In CNN-based models, we assume that pixels spatially close to each other have high correlations, which is the reason that we employ small-sized kernels to capture these correlations. This kind of assumption is basically the _inductive bias_ of CNN. On the other hand, SENet introduces a new inductive bias, where the authors assume that every image channel contributes differently to predicting a specific class. By applying SE modules to a CNN, the model not only relies on spatial patterns but also captures the importance of each channel. To better illustrate this, we can think of an image of fire, where the red channel would theoretically give a higher contribution to the final prediction than the blue and green channels.\nThe structure of the SE module itself is shown in Figure 1. As the name of the network suggests, there are two main steps done in this module: _squeeze_ and _excitation_. The _squeeze_ part corresponds to the operation denoted as _F_sq_ , while the _excitation_ part includes both _F_ex_ and _F_scale_. On the other hand, the _F_tr_ operation, is actually not the part of the SE module. Rather, it represents a transformation function that originally belongs to the model where the SE module is applied. For example, if we were to place this SE module on ResNet, the _F_tr_ operation refers to the stack of convolution layers within the bottleneck block.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/08/1y028apFGDw8zyEtv7FwBjw.png)\nFigure 1. The structure of the Squeeze and Excitation module [1].\nTalking more specifically about the _F_sq_ operation, it essentially works by utilizing global average pooling mechanism, where it is used to capture the information from the entire spatial dimension of each channel. By doing so, every channel of the input tensor is going to be represented by a single number, which is basically just the average value of the corresponding channel. The authors refer to this operation as _global information embedding_. Mathematically speaking, this can formally be written in the equation shown in Figure 2, where we basically sum all values across the height _H_ and width _W_ before eventually dividing it with the number of pixels within that channel (_H×W_).\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/08/1DrSp88UaiXusNZVlQQ1G0g.png)\nFigure 2. The mathematical expression of the global average pooling mechanism in SE module [1].\nMeanwhile, both excitation and scaling operations are referred to as _adaptive recalibration_ since what they essentially do is to dynamically adjust the weightings of each channel in the input tensor according to its importance. In fact, the diagram in Figure 1 does not completely depict the entire SENet architecture. You can see in the figure that _F_ex_ appears to be a single operation, yet it actually consists of two linear layers each followed by an activation function. See the Figure 3 below for the details.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/08/1sWSvZ4V97F2i4Udkb9EBAg.png)\nFigure 3. The mathematical formulation of the _**F_ex**_ operation [1].\nThe two linear layers are denoted as _W_1_ and _W_2_ , whereas _δ_ and _σ_ represent ReLU and sigmoid activation functions, respectively. So, based on this mathematical definition, what we basically need to do later in the implementation is to pass tensor _z_ (the average-pooled tensor) through the first linear layer, followed by the ReLU activation function, the second linear layer, and lastly the sigmoid activation function. Remember that the sigmoid function normalizes input values to be within the range of 0 to 1. In this case, we will perceive the resulting output as the weight of each channel, where a value close to 1 indicates that the corresponding channel contains important information, hence we allow the model to pay more attention to that channel. Otherwise, if the resulting number is close to 0, it indicates that the corresponding channel does not contribute that much to the output.\nIn order to utilize these channel weights, we can perform the _F_scale_ operation, which is basically just a multiplication of the original tensor _u_ and the weight tensor _s_ , as shown in Figure 4 below. By doing this, we essentially retain the values within the important channels while at the same time suppressing the values of the unimportant ones.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/08/1xbswm8kSGIp83kgMaQhUng.png)\nFigure 4. The scaling process is just a multiplication of the original and the weight tensors [1].\nBy the way sorry for getting a bit too mathy here, lol. But I believe this will help you understand the code later in the implementation section.\n### Where to Put the SE Module\nApplying the SE module on a plain CNN model like VGG is easy, as we can simply place it right after each convolution layer. However, it might not be straightforward in the case of Inception or ResNet thanks to the presence of parallel branches in these two networks. To address this confusion, authors provide a guide to implement the SE module specifically on the two models as shown in Figure 5 below.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/08/1-ss7zP8Yv3yGAu_EsgufYw.png)\nFigure 5. Where SE module is placed in Inception and ResNet [1].\nFor the Inception model, instead of placing SE module right after each convolution layer, we pass the input tensor through the entire Inception block (including all the branches inside) and then attach the SE module afterwards. The same approach also works for ResNet, but keep in mind that the summation between the tensor in skip connection and the main flow happens after the main tensor has been processed by the SE module.\nAs I mentioned earlier, the excitation stage essentially consists of two linear layers. If we take a closer look at the above structure, we can see that the output shape of the first linear layer is 1×1×C/_r_. The variable _r_ is called _reduction ratio_ which reduces the dimensionality of the weight tensor before eventually projecting it back to 1×1×C through the second linear layer. The dimensionality reduction done by the first layer acts as a _bottleneck_ operation, which is useful to limit model complexity and to improve generalization. Authors conducted experiments on different _r_ values, and they found that _r_ = 16 produces the best balance between accuracy and complexity.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/08/18KLGG9TZBZdHwSoWkaZo0g.png)\nFigure 6. Several ways possible to be used to attach SE module in ResNet [1].\nIn addition to implementing the SE module in ResNet, it is seen in Figure 6 that there are actually several ways we can follow to do so. According to the experimental results in Figure 7, it looks like the standard SE, SE-PRE, and SE-Identity blocks obtained similar results, while at the same time all of them outperformed SE-POST by a significant margin. This suggests that the placement of the SE module affects model performance in terms of accuracy. Based on these findings, the authors argue that we are going to obtain good results as long as we apply the SE module before the element-wise summation operation. Later in the coding section, I am going to demonstrate how to implement the standard SE block.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/08/1OYd78VKEMTTSLK1U64BFtA.png)\nFigure 7. Experimental results on different SE module integration strategies [1].\n### More Experimental Results\nThere are actually a lot more experimental results discussed in the paper. One of them is a table displaying accuracy score improvements when SE module is applied to existing CNN-based models. The table I am referring to is displayed in Figure 8 below.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/08/1Kab-T4PKcE7Ly1OdprDPrQ.png)\nFigure 8. Experimental results on applying SE module on different models [1][2].\nThe columns highlighted in blue represent the error rates of each model and the ones in pink indicate the computational complexity measured in GFLOPs. The _re-implementation_ column refers to the plain model that the authors implemented themselves, whereas the _SENet_ column represents the same model equipped with SE module. The table clearly shows that both top-1 and top-5 errors decrease when the SE module is applied. It is important to know that although adding the SE module causes the GFLOPs to get higher, yet this increase is considerably marginal compared to the reduction in error rate.\nNext, we can actually reveal interesting insights by printing out the values contained in the SE modules during the inference phase. Let’s take a look at the charts in Figure 9 below to better illustrate this. The _x_ axis of these charts denotes the channel numbers, the _y_ axis represents how much weight does each channel have according to its importance, and the color of the lines indicates the class being predicted.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/08/1pVpxfk3W-U8YUZsvxb4EJw.png)\nFigure 9. What the activation of SE modules looks like in different network depth [1].\nIn shallower layers, the features captured by SE module are _class-agnostic_ , which basically means that it captures generic information required to predict all classes. The charts referred to as (a) and (b), which are the SE modules from ResNet stage 2 and 3, show that there is not much difference in channel activity from one class to another, indicating that these two modules do not capture information regarding a specific class. The case is actually different from the SE modules in deeper layers, i.e., the ones in stage 4 (c) and stage 5 (d). We can see that these two modules adjust channel weights differently depending on the class being predicted. This is essentially the reason that the SE modules in deeper layers are said to be _class-specific_. However, the authors acknowledge that there might be unusual behavior happening in some of the SE modules which happens in the 2nd block of stage 5 (e). Here the SE module does not show meaningful channel recalibration behavior, indicating that it does not contribute as much as the ones we discussed earlier.\n### The Detailed Architecture\nIn this article we are going to implement the _SE-ResNeXt-50 (32×4d)_ model, which in Figure 10 it corresponds to the one in the rightmost column. The ResNeXt model itself is similar to ResNet, except that the group parameter of the second convolution layer within each block is set to 32. If you’re familiar with ResNeXt, this is essentially the simplest yet effective way to implement the so-called _cardinality_. I recommend you read my previous article about ResNeXt if you are not yet familiar with it, which the link is provided at reference number [3] at the end of this article.\nTaking a closer look at the architecture, what differentiates _SE-ResNet-50_ from _ResNet-50_ is solely the presence of SE modules. The same also applies to _SE-ResNeXt-50 (32×4d)_ compared to _ResNeXt-50 (32×4d)_ (not displayed in the table). Notice in the figure below that the models with SE modules have an _fc_ layer attached after the last convolution layer within each block, which the corresponding two numbers indicate the first and second fully-connected layers inside the SE module.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/08/1p9IGCKUudAEXj8znFK3aZw.png)\nFigure 10. The complete architecture of ResNet-50, SE-ResNet-50 and SE-ResNeXt-50 (32×4d) [1].\n···\n## From Scratch Implementation\nRemember that here we are about to integrate the SE module on ResNeXt, so we need to implement both of them from scratch. Technically speaking, it is actually possible to take the ResNeXt architecture directly from PyTorch, then manually attach the SE module on it. However, here I decided to use the ResNeXt implementation from my previous article instead since I feel like it is a lot easier to understand than the one from PyTorch. Note that here I will focus on constructing the SE module and how to attach it to the ResNeXt model rather than explaining the ResNeXt itself since I’ve already covered it in that article [3].\nNow let’s start the code by importing the required modules.\npython\n\n```\n# Codeblock 1\nimport torch\nimport torch.nn as nn\n```\n\n### Squeeze and Excitation Module\nThe following SE module implementation follows the diagram shown in Figure 5 (right). It is worth noting that the `SEModule` class below does not include the skip-connection (curved arrow), as the entire SE module is applied after the initial branching but before the merging (summation).\nThe `__init__()` method of this class accepts two parameters: `num_channels` and `r`, as shown at line `#(1)` in Codeblock 2a. We definitely want this SE module to be usable throughout the entire network. So, we need to set the `num_channels` parameter to be adjustable because the number of output channels varies across ResNeXt blocks at different stages, as shown back in Figure 10. Meanwhile, even though we typically use the same reduction ratio _r_ in the SE modules within the entire network, but it is technically possible for us to use different `r` for different stage, which might probably be an interesting thing to experiment with. So, this is essentially the reason that I also set the `r` parameter to be adjustable.\npython\n\n```\n# Codeblock 2a\nclass SEModule(nn.Module):\n    def __init__(self, num_channels, r):                     #(1)\n        super().__init__()\n        \n        self.global_pooling = nn.AdaptiveAvgPool2d(output_size=(1,1))  #(2)\n        self.fc0 = nn.Linear(in_features=num_channels,       #(3)\n                             out_features=num_channels//r, \n                             bias=False)\n        self.relu = nn.ReLU()                                #(4)\n        self.fc1 = nn.Linear(in_features=num_channels//r,    #(5)\n                             out_features=num_channels, \n                             bias=False)\n        self.sigmoid = nn.Sigmoid()                          #(6)\n```\n\nThere are 5 layers we need to initialize inside the `__init__()` method. I write them down according to the sequence given in Figure 5, i.e., global average pooling layer (`#(2)`), linear layer (`#(3)`), ReLU activation function (`#(4)`), another linear layer (`#(5)`), and sigmoid activation function (`#(6)`). Here you can see that the first linear layer is responsible to perform dimensionality reduction by shrinking the number of channels from `num_channels` to `num_channels//r`, which will then be expanded back to `num_channels` by the second linear layer. Note that we set the bias term of both linear layers to `False`, which essentially means that we will only utilize the weight tensors. The absence of bias terms in the two layers forces the SE module to learn the correlation between one channel to the others rather than just adding fixed adjustments.\nStill with the `SEModule` class, let’s now move on to the `forward()` method to define the flow of the network. You can see at line `#(1)` in Codeblock 2b that we start from a single input `x`, which in the case of ResNeXt it is essentially a tensor produced by the third convolution layer within the same ResNeXt block. As shown in Figure 5, what we need to do next is to branch out the network. Here we directly process the branch using the `global_pooling` layer, which I name the resulting tensor `squeezed` (`#(2)`). The original input tensor `x` itself will be left as is since we are not going to perform any operation on it until the scaling phase. Next, we need to drop the spatial dimension of the `squeezed` tensor using `torch.flatten()` (`#(3)`). This is basically done because we want to process it further with the linear layers at line `#(4)` and `#(5)`, which can only work with a single-dimensional tensor. The spatial dimension is then introduced again at line `#(6)`, allowing us to perform multiplication between `x` (the original tensor) and `excited` (the channel weights) at line `#(7)`. This entire process produces a recalibrated version of `x` which we refer to as `scaled`. Here I print out the tensor dimension after each step so that you can better understand the flow of this SE module.\npython\n\n```\n# Codeblock 2b\n    def forward(self, x):                                  #(1)\n        print(f'original\\t\\t: {x.size()}')\n        \n        squeezed = self.global_pooling(x)                  #(2)\n        print(f'after avgpool\\t\\t: {squeezed.size()}')\n        \n        squeezed = torch.flatten(squeezed, 1)              #(3)\n        print(f'after flatten\\t\\t: {squeezed.size()}')\n        \n        excited = self.relu(self.fc0(squeezed))            #(4)\n        print(f'after fc0-relu\\t\\t: {excited.size()}')\n        \n        excited = self.sigmoid(self.fc1(excited))          #(5)\n        print(f'after fc1-sigmoid\\t: {excited.size()}')\n        \n        excited = excited[:, :, None, None]                #(6)\n        print(f'after reshape\\t\\t: {excited.size()}')\n        \n        scaled = x * excited                               #(7)\n        print(f'after scaling\\t\\t: {scaled.size()}')\n        \n        return scaled\n```\n\nNow we are going to see if we have implemented the network correctly by passing a dummy tensor through it. In Codeblock 3 below, I initialize an SE module and configure it to accept an image tensor of 512 channels and has a reduction ratio of 16 (`#(1)`). If you take a look at the SE-ResNeXt architecture in Figure 10, this SE module basically corresponds to the one in the third stage (which the output size is 28×28). Thus, at line `#(2)` we need to adjust the shape of the dummy tensor accordingly. We then feed this tensor into the network using the code at line `#(3)`.\npython\n\n```\n# Codeblock 3\nsemodule = SEModule(num_channels=512, r=16)    #(1)\nx = torch.randn(1, 512, 28, 28)                #(2)\n\nout = semodule(x)      #(3)\n```\n\nAnd below is what the print functions give us.\nmarkup\n\n```\n# Codeblock 3 Outputoriginal          : torch.Size([1, 512, 28, 28])    #(1)after avgpool     : torch.Size([1, 512, 1, 1])      #(2)after flatten     : torch.Size([1, 512])            #(3)after fc0-relu    : torch.Size([1, 32])             #(4)after fc1-sigmoid : torch.Size([1, 512])            #(5)after reshape     : torch.Size([1, 512, 1, 1])      #(6)after scaling     : torch.Size([1, 512, 28, 28])    #(7)\n```\n\nYou can see that the original tensor shape matches exactly with our dummy tensor, i.e., 1×512×28×28 (`#(1)`). By the way we can ignore the number 1 in the 0th axis since it essentially denotes the batch size, which in this case I assume that we only got a single image in a batch. After being pooled, the spatial dimension collapses to 1×1 since now each channel is represented by a single number (`#(2)`). The purpose of the flatten operation I explained earlier is to drop the two empty axes (`#(3)`) since the subsequent linear layers can only work with single-dimensional tensor. Here you can see that the first linear layer reduces the tensor dimension to 32 thanks to the reduction ratio which we previously set to 16 (`#(4)`). The length of this tensor is then expanded back to 512 by the second linear layer (`#(5)`). Next, we unsqueeze the tensor so that we get our 1×1 spatial dimension back (`#(6)`), allowing us to multiply it with the input tensor (`#(7)`). Based on this detailed flow, you can see that an SE module basically preserves the original tensor dimension, proving that this module can be attached to any CNN-based model without disrupting the original flow of the network.\n#### ResNeXt\nAs we have understood how to implement SE module from scratch, now that I am going to show you how we can attach it on a ResNeXt model. Before doing so, we need to initialize the parameters required to implement the ResNeXt architecture. In the Codeblock 4 below the first four variables are determined according to the _ResNeXt-50 (32×4d)_ variant, whereas the last one (`R`) represents the reduction ratio for the SE modules.\npython\n\n```\n# Codeblock 4\nCARDINALITY  = 32\nNUM_CHANNELS = [3, 64, 256, 512, 1024, 2048]\nNUM_BLOCKS   = [3, 4, 6, 3]\nNUM_CLASSES  = 1000\nR = 16\n```\n\nThe `Block` class defined in Codeblock 5a and 5b is the ResNeXt block from my previous article. There are actually lots of things we do inside the `__init__()` method, but the general idea is that we initialize three convolution layers referred to as `conv0` (`#(1)`), `conv1` (`#(2)`), and `conv2` (`#(3)`) before initializing the SE module at line `#(4)`. We will later configure these layers according to the SE-ResNeXt architecture shown back in Figure 10.\npython\n\n```\n# Codeblock 5a\nclass Block(nn.Module):\n    def __init__(self, \n                 in_channels,\n                 add_channel=False,\n                 channel_multiplier=2,\n                 downsample=False):\n        super().__init__()\n\n        self.add_channel = add_channel\n        self.channel_multiplier = channel_multiplier\n        self.downsample = downsample\n        \n        \n        if self.add_channel:\n            out_channels = in_channels*self.channel_multiplier\n        else:\n            out_channels = in_channels\n        \n        mid_channels = out_channels//2\n        \n        \n        if self.downsample:\n            stride = 2\n        else:\n            stride = 1\n            \n\n        if self.add_channel or self.downsample:\n            self.projection = nn.Conv2d(in_channels=in_channels,\n                                        out_channels=out_channels, \n                                        kernel_size=1, \n                                        stride=stride, \n                                        padding=0, \n                                        bias=False)\n            nn.init.kaiming_normal_(self.projection.weight, nonlinearity='relu')\n            self.bn_proj = nn.BatchNorm2d(num_features=out_channels)\n\n        self.conv0 = nn.Conv2d(in_channels=in_channels,       #(1)\n                               out_channels=mid_channels,\n                               kernel_size=1, \n                               stride=1, \n                               padding=0, \n                               bias=False)\n        nn.init.kaiming_normal_(self.conv0.weight, nonlinearity='relu')\n        self.bn0 = nn.BatchNorm2d(num_features=mid_channels)\n\n        self.conv1 = nn.Conv2d(in_channels=mid_channels,      #(2)\n                               out_channels=mid_channels, \n                               kernel_size=3, \n                               stride=stride,\n                               padding=1, \n                               bias=False, \n                               groups=CARDINALITY)\n        nn.init.kaiming_normal_(self.conv1.weight, nonlinearity='relu')\n        self.bn1 = nn.BatchNorm2d(num_features=mid_channels)\n\n        self.conv2 = nn.Conv2d(in_channels=mid_channels,      #(3)\n                               out_channels=out_channels,\n                               kernel_size=1, \n                               stride=1, \n                               padding=0, \n                               bias=False)\n        nn.init.kaiming_normal_(self.conv2.weight, nonlinearity='relu')\n        self.bn2 = nn.BatchNorm2d(num_features=out_channels)\n        \n        self.relu = nn.ReLU()\n        \n        self.semodule = SEModule(num_channels=out_channels, r=R)    #(4)\n```\n\nThe `forward()` method itself is generally also the same as the original ResNeXt model, except that here we need to put the SE module right before the element-wise summation as shown at line `#(1)` in the Codeblock 5b below. Remember that this implementation follows the standard SE block architecture in Figure 6 (b).\npython\n\n```\n# Codeblock 5b\n    def forward(self, x):\n        print(f'original\\t\\t: {x.size()}')\n        \n        if self.add_channel or self.downsample:\n            residual = self.bn_proj(self.projection(x))\n            print(f'after projection\\t: {residual.size()}')\n        else:\n            residual = x\n            print(f'no projection\\t\\t: {residual.size()}')\n        \n        x = self.conv0(x)\n        x = self.bn0(x)\n        x = self.relu(x)\n        print(f'after conv0-bn0-relu\\t: {x.size()}')\n\n        x = self.conv1(x)\n        x = self.bn1(x)\n        x = self.relu(x)\n        print(f'after conv1-bn1-relu\\t: {x.size()}')\n        \n        x = self.conv2(x)\n        x = self.bn2(x)\n        print(f'after conv2-bn2\\t\\t: {x.size()}')\n        \n        x = self.semodule(x)      #(1)\n        print(f'after semodule\\t\\t: {x.size()}')\n        \n        x = x + residual\n        x = self.relu(x)\n        print(f'after summation\\t\\t: {x.size()}')\n        \n        return x\n```\n\nWith the above implementation, every time we instantiate a `Block` object we will have a ResNeXt block which is already equipped with an SE module. Now we are going to test the above class to see if we have implemented it correctly. Here I am going to simulate a ResNeXt block within the third stage. The `add_channel` and `downsample` parameters are set to `False` since we want to preserve both the number of channels and the spatial dimension of the input tensor.  \n\npython\n\n```\n# Codeblock 6\nblock = Block(in_channels=512, add_channel=False, downsample=False)\nx = torch.randn(1, 512, 28, 28)\n\nout = block(x)\n```\n\nBelow is what the output looks like. Here you can see that our first convolution layer successfully reduced the number of channels from 512 to 256 (`#(1)`), which is then expanded back to its original dimension by the third convolution layer (`#(2)`). Afterwards, the tensor goes through the SE block which the resulting output size is the same as its input, just like what we saw earlier in Codeblock 3 (`#(3)`). As the processing with SE module is done, we can finally perform the element-wise summation between the tensor from the main branch and the one from the skip-connection (`#(4)`).\nmarkup\n\n```\noriginal             : torch.Size([1, 512, 28, 28])no projection        : torch.Size([1, 512, 28, 28])after conv0-bn0-relu : torch.Size([1, 256, 28, 28])    #(1)after conv1-bn1-relu : torch.Size([1, 256, 28, 28])after conv2-bn2      : torch.Size([1, 512, 28, 28])    #(2)after semodule       : torch.Size([1, 512, 28, 28])    #(3)after summation      : torch.Size([1, 512, 28, 28])    #(4)\n```\n\nAnd below is how I implement the entire architecture. What we essentially need to do is just to stack multiple SE-ResNeXt blocks according to the architecture in Figure 10. In fact, the `SEResNeXt` class in Codeblock 7 is exactly the same as the `ResNeXt` class in my previous article [3] (I literally copy-pasted it) since what makes SE-ResNeXt different from the original ResNeXt is only the presence of SE module within the `Block` class we discussed earlier.\npython\n\n```\n# Codeblock 7\nclass SEResNeXt(nn.Module):\n    def __init__(self):\n        super().__init__()\n\n        # conv1 stage\n        self.resnext_conv1 = nn.Conv2d(in_channels=NUM_CHANNELS[0],\n                                       out_channels=NUM_CHANNELS[1],\n                                       kernel_size=7,\n                                       stride=2,\n                                       padding=3, \n                                       bias=False)\n        nn.init.kaiming_normal_(self.resnext_conv1.weight, \n                                nonlinearity='relu')\n        self.resnext_bn1 = nn.BatchNorm2d(num_features=NUM_CHANNELS[1])\n        self.relu = nn.ReLU()\n        self.resnext_maxpool1 = nn.MaxPool2d(kernel_size=3,\n                                             stride=2, \n                                             padding=1)\n\n        # conv2 stage\n        self.resnext_conv2 = nn.ModuleList([\n            Block(in_channels=NUM_CHANNELS[1],\n                  add_channel=True,\n                  channel_multiplier=4,\n                  downsample=False)\n        ])\n        for _ in range(NUM_BLOCKS[0]-1):\n            self.resnext_conv2.append(Block(in_channels=NUM_CHANNELS[2]))\n\n        # conv3 stage\n        self.resnext_conv3 = nn.ModuleList([Block(in_channels=NUM_CHANNELS[2],\n                                                  add_channel=True, \n                                                  downsample=True)])\n        for _ in range(NUM_BLOCKS[1]-1):\n            self.resnext_conv3.append(Block(in_channels=NUM_CHANNELS[3]))\n            \n            \n        # conv4 stage\n        self.resnext_conv4 = nn.ModuleList([Block(in_channels=NUM_CHANNELS[3],\n                                                  add_channel=True, \n                                                  downsample=True)])\n        \n        for _ in range(NUM_BLOCKS[2]-1):\n            self.resnext_conv4.append(Block(in_channels=NUM_CHANNELS[4]))\n            \n            \n        # conv5 stage\n        self.resnext_conv5 = nn.ModuleList([Block(in_channels=NUM_CHANNELS[4],\n                                                  add_channel=True, \n                                                  downsample=True)])\n        \n        for _ in range(NUM_BLOCKS[3]-1):\n            self.resnext_conv5.append(Block(in_channels=NUM_CHANNELS[5]))\n \n       \n        self.avgpool = nn.AdaptiveAvgPool2d(output_size=(1,1))\n\n        self.fc = nn.Linear(in_features=NUM_CHANNELS[5],\n                            out_features=NUM_CLASSES)\n        \n\n    def forward(self, x):\n        print(f'original\\t\\t: {x.size()}')\n        \n        x = self.relu(self.resnext_bn1(self.resnext_conv1(x)))\n        print(f'after resnext_conv1\\t: {x.size()}')\n        \n        x = self.resnext_maxpool1(x)\n        print(f'after resnext_maxpool1\\t: {x.size()}')\n        \n        for i, block in enumerate(self.resnext_conv2):\n            x = block(x)\n            print(f'after resnext_conv2 #{i}\\t: {x.size()}')\n            \n        for i, block in enumerate(self.resnext_conv3):\n            x = block(x)\n            print(f'after resnext_conv3 #{i}\\t: {x.size()}')\n            \n        for i, block in enumerate(self.resnext_conv4):\n            x = block(x)\n            print(f'after resnext_conv4 #{i}\\t: {x.size()}')\n            \n        for i, block in enumerate(self.resnext_conv5):\n            x = block(x)\n            print(f'after resnext_conv5 #{i}\\t: {x.size()}')\n        \n        x = self.avgpool(x)\n        print(f'after avgpool\\t\\t: {x.size()}')\n        \n        x = torch.flatten(x, start_dim=1)\n        print(f'after flatten\\t\\t: {x.size()}')\n        \n        x = self.fc(x)\n        print(f'after fc\\t\\t: {x.size()}')\n        \n        return x\n```\n\nAs the entire _SE-ResNeXt-50 (32×4d)_ architecture is completed, now that we are going to test it by passing through a tensor of size 1×3×224×224 through the network, simulating a single RGB image of size 224×224. You can see in the output of the Codeblock 8 below that it seems like model works properly since the tensor successfully passed through all layers within the `seresnext` model without returning any error. Thus, I believe this model is now ready to be trained. By the way don’t forget to change the number of neurons in the output channel according to the number of classes in your dataset if you want to actually train this model.\npython\n\n```\n# Codeblock 8\nseresnext = SEResNeXt()\nx = torch.randn(1, 3, 224, 224)\n\nout = seresnext(x)\n```\n\nmarkup\n\n```\n# Codeblock 8 Outputoriginal               : torch.Size([1, 3, 224, 224])after resnext_conv1    : torch.Size([1, 64, 112, 112])after resnext_maxpool1 : torch.Size([1, 64, 56, 56])after resnext_conv2 #0 : torch.Size([1, 256, 56, 56])after resnext_conv2 #1 : torch.Size([1, 256, 56, 56])after resnext_conv2 #2 : torch.Size([1, 256, 56, 56])after resnext_conv3 #0 : torch.Size([1, 512, 28, 28])after resnext_conv3 #1 : torch.Size([1, 512, 28, 28])after resnext_conv3 #2 : torch.Size([1, 512, 28, 28])after resnext_conv3 #3 : torch.Size([1, 512, 28, 28])after resnext_conv4 #0 : torch.Size([1, 1024, 14, 14])after resnext_conv4 #1 : torch.Size([1, 1024, 14, 14])after resnext_conv4 #2 : torch.Size([1, 1024, 14, 14])after resnext_conv4 #3 : torch.Size([1, 1024, 14, 14])after resnext_conv4 #4 : torch.Size([1, 1024, 14, 14])after resnext_conv4 #5 : torch.Size([1, 1024, 14, 14])after resnext_conv5 #0 : torch.Size([1, 2048, 7, 7])after resnext_conv5 #1 : torch.Size([1, 2048, 7, 7])after resnext_conv5 #2 : torch.Size([1, 2048, 7, 7])after avgpool          : torch.Size([1, 2048, 1, 1])after flatten          : torch.Size([1, 2048])after fc               : torch.Size([1, 1000])\n```\n\nAdditionally, we can also print out the number of parameters this model has using the following code. Here you can see that the codeblock returns 27,543,848. This number of parameters is slightly higher than the original ResNeXt model counterpart, which only has 25,028,904 parameters as mentioned in my previous article as well as the official PyTorch documentation [4]. Such an increase in the model size definitely makes sense since the ResNeXt blocks throughout the entire network now have more layers thanks to the presence of SE modules.\npython\n\n```\n# Codeblock 9\ndef count_parameters(model):\n    return sum([params.numel() for params in model.parameters()])\n\ncount_parameters(seresnext)\n```\n\nmarkup\n\n```\n# Codeblock 9 Output27543848\n```\n\n···\n## Ending\nAnd that’s pretty much everything about the Squeeze and Excitation module. I do encourage you to explore from here by training this model on your own dataset so that you will see whether the findings presented in the paper also apply to your case. Not only that, I think it would also be interesting if you try to implement SE module on other neural network architectures like VGG or Inception by yourself.\nI hope you learn something new today. Thanks for reading!\n_By the way you can also find the code used in this article in my GitHub repo [5]._\n···\n[1] Jie Hu _et al._ Squeeze and Excitation Networks. Arxiv. <https://arxiv.org/abs/1709.01507> [Accessed March 17, 2025].\n[2] Image originally created by author.\n[3] Taking ResNet to the Next Level. Towards Data Science. <https://towardsdatascience.com/taking-resnet-to-the-next-level/> [Accessed July 22, 2025].\n[4] Resnext50_32x4d. PyTorch. <https://pytorch.org/vision/main/models/generated/torchvision.models.resnext50_32x4d.html#torchvision.models.resnext50_32x4d> [Accessed March 17, 2025].\n[5] MuhammadArdiPutra. The Channel-Wise Attention — Squeeze and Excitation. GitHub. <https://github.com/MuhammadArdiPutra/medium_articles/blob/main/The%20Channel-Wise%20Attention%20-%20Squeeze%20and%20Excitation.ipynb> [Accessed April 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/)[Computer Vision](https://towardsdatascience.com/tag/computer-vision/)[Machine Learning](https://towardsdatascience.com/tag/machine-learning/)[Neural Network](https://towardsdatascience.com/tag/neural-network/)[Pytorch](https://towardsdatascience.com/tag/pytorch/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Fthe-channel-wise-attention%2F&title=SENet%20Paper%20Walkthrough%3A%20The%20Channel-Wise%20Attention)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Fthe-channel-wise-attention%2F&title=SENet%20Paper%20Walkthrough%3A%20The%20Channel-Wise%20Attention)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Fthe-channel-wise-attention%2F&text=SENet%20Paper%20Walkthrough%3A%20The%20Channel-Wise%20Attention)\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/2021/12/0S-fQ7kmjq6OY0GUb-scaled.jpg)](https://towardsdatascience.com/understanding-probability-models-and-axioms-c0f498972b80/)\n## [Understanding Probability Models and Axioms](https://towardsdatascience.com/understanding-probability-models-and-axioms-c0f498972b80/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nWhy even care about sample space, events, and probability measures?\n[Marvin Lanhenke](https://towardsdatascience.com/author/marvinlanhenke/)\nDecember 18, 20217 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/08/1OjK0I3yl04ZU_JD94LQpHw.png)](https://towardsdatascience.com/nlp-splitting-text-into-sentences-7bbce222ef17/)\n## [NLP: Splitting Text into Sentences](https://towardsdatascience.com/nlp-splitting-text-into-sentences-7bbce222ef17/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nLanguage agnostic model for transforming text into sentences\n[Moran Beladev](https://towardsdatascience.com/author/moranbeladev90/)\nAugust 1, 20214 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/03/0BhRYpPxSTbULL2u3-scaled.jpg)](https://towardsdatascience.com/how-to-better-deploy-your-machine-learning-model-6f179483a289/)\n## [How to Better Deploy Your Machine Learning Model](https://towardsdatascience.com/how-to-better-deploy-your-machine-learning-model-6f179483a289/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nMy argument against homemade solutions and an alternative proposal\n[Amine Elhattami](https://towardsdatascience.com/author/amine-elhattami/)\nMarch 24, 20226 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/06/11nkWNfZ_n0_IVJWujZHd1w.png)](https://towardsdatascience.com/a-unified-view-of-graph-neural-networks-12b40e8fdac5/)\n## [A unified view of Graph Neural Networks](https://towardsdatascience.com/a-unified-view-of-graph-neural-networks-12b40e8fdac5/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nGraph attention, graph convolution, network propagation are all special cases of message passing in graph neural networks.\n[Remy Lau](https://towardsdatascience.com/author/remylau961/)\nJune 27, 20213 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/04/0YbZVpYFdO34asvop.jpg)](https://towardsdatascience.com/the-math-behind-recurrent-neural-networks-2de4e0098ab8/)\n## [The Math Behind Recurrent Neural Networks](https://towardsdatascience.com/the-math-behind-recurrent-neural-networks-2de4e0098ab8/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nDive into RNNs, the backbone of time series, understand their mathematics, implement them from scratch, and explore their applications\n[Cristian Leo](https://towardsdatascience.com/author/cristianleo120/)\nApril 27, 202423 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/12/1OmWXAXvxY3BV3oGxmFS7EA.png)](https://towardsdatascience.com/part-1-building-a-deep-q-network-to-play-gridworld-deepminds-deep-q-networks-78842007c631/)\n## [Part 1 - Building a deep Q-network to play Gridworld - DeepMind's deep Q-networks](https://towardsdatascience.com/part-1-building-a-deep-q-network-to-play-gridworld-deepminds-deep-q-networks-78842007c631/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nIn this article let's build a Deep Q-network similar to the DeepMind's Atari agent to play Gridworld problem. We will build virtually the...\n[NandaKishore Joshi](https://towardsdatascience.com/author/nandakishorej8/)\nDecember 5, 202115 min read\n  * [![](https://towardsdatascience.com/images/fallback-image.jpg)](https://towardsdatascience.com/fine-tuning-pre-trained-model-vgg-16-1277268c537f/)\n## [Fine-Tuning Pre-trained Model VGG-16](https://towardsdatascience.com/fine-tuning-pre-trained-model-vgg-16-1277268c537f/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nIn my previous article, I explored using the pre-trained model VGG-16 as a feature extractor for transfer learning on the RAVDESS Audio...\n[Muriel Kosaka](https://towardsdatascience.com/author/murielsayaka/)\nNovember 10, 20204 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/10/0OWrYWTEMht51ngWD-scaled.jpg)](https://towardsdatascience.com/the-importance-of-branding-in-data-science-467b2d2b1e7f/)\n## [The Importance of Branding in Data Science](https://towardsdatascience.com/the-importance-of-branding-in-data-science-467b2d2b1e7f/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nRecently, One topic in-particular has been reoccurring in my discussions with friends. The importance of branding! I was not going to...\n[Kurtis Pykes](https://towardsdatascience.com/author/kurtispykes/)\nOctober 13, 20208 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/08/0IMWlQD91jd04ISqN-scaled.jpg)](https://towardsdatascience.com/top-python-libraries-for-image-augmentation-in-computer-vision-2566bed0533e/)\n## [Top Python libraries for Image Augmentation in Computer Vision](https://towardsdatascience.com/top-python-libraries-for-image-augmentation-in-computer-vision-2566bed0533e/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nFeaturing the best augmentation libraries (along with sample codes) for your next computer vision project\n[Kenneth Leung](https://towardsdatascience.com/author/kennethleungty/)\nAugust 2, 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/7fd7c2cd6fee/pages/",
  "body_markdown_path": "attachments/7fd7c2cd6fee/pages/archived-body.md",
  "local_html": "attachments/7fd7c2cd6fee/pages/archived-body.html",
  "body_source": "prior_capture"
}