{
  "source_file": "0930",
  "source_platform": "Medium",
  "author": "Aqeel Anwar",
  "title_listed": "Difference between AutoEncoder (AE) and Variational AutoEncoder (VAE)",
  "keywords": "AutoEncoder,VAE",
  "domain": "机器学习",
  "content_type": "深度技术解析",
  "is_paid_flag": "部分免费/会员墙",
  "url": "https://towardsdatascience.com/difference-between-autoencoder-ae-and-variational-autoencoder-vae-ed7be1c038f2/",
  "publish_date": "2021-11",
  "corpus_stage": "预训练/SFT",
  "notes": "",
  "id": "2c791ce76bf9",
  "collected_at": "2026-10-01T23:11:02",
  "title": "Difference between AutoEncoder (AE) and Variational AutoEncoder (VAE) | Towards Data Science",
  "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# Difference between AutoEncoder (AE) and Variational AutoEncoder (VAE)\nHow can you compress data or even generate data from random values? That is what Autoencoder and Variational Autoencoder are.\n[Aqeel Anwar](https://towardsdatascience.com/author/aqeel%20anwar/)\nNovember 3, 20218 min read\n> The ability to simplify means to eliminate the unnecessary so that the necessary may speak — **Hans Hofmann**\n# Context— Data compression\nData compression is an essential phase in training a network. The idea is to compress the data so that the same amount of information can be represented by fewer bits. This also helps with the problem of the curse of dimensionality. A dataset with many attributes is different to train with because it tends to overfit the model. Hence dimensionality reduction techniques need to be applied before the dataset can be used for training.\nThis is where the Autoencoder (AE) and Variational Autoencoder (VAE) come into play. They are end-to-end networks that are used to compress the input data. Both Autoencoder and Variational Autoencoder are used to transform the data from a higher to lower-dimensional space, essentially achieving compression.\n# Autoencoder — AE\n## What is it?\nAutoencoder is used to learn efficient embeddings of unlabeled data for a given network configuration. The autoencoder consists of two parts, an encoder, and a decoder. The encoder compresses the data from a higher-dimensional space to a lower-dimensional space (also called the latent space), while the decoder does the opposite i.e., convert the latent space back to higher-dimensional space. The decoder is used to ensure that latent space can capture most of the information from the dataset space, by forcing it to output what was fed as input to the decoder.\n## Block Diagram\nThe block diagram can be seen below.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/03/image-114.png)\nAutoEncoder — Image by Author\nDuring training, the input data x is fed to the encoder function  _**e_theta(x)**_. The input is passed through a series of layers (parameterized by the variable theta) reducing its dimensions to achieve a compressed latent vector  _**z**_. The number of layers, type and size of the layers, and the latent space dimension are user-controlled parameters. Compression is achieved if the dimension of the latent space is less than that of the input space, essentially getting rid of redundant attributes.\nThe decoder  _**d_phi(z)**_ usually (but not necessarily) consists of near-compliment layers of the layers used in the encoder but in reverse order. A near-complement layer of a layer is the one that can be used to undo the operations (to some extent) of the original layer such as transposed conv layer to conv layer, pooling to unpooling, fully connected to fully connected, etc.\n## Loss function\nThe entire encoder-decoder architecture is collectively trained on the loss function which encourages that the input is reconstructed at the output. Hence the loss function is the mean squared error between the encoder input and the decoder output.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/03/image-115.png)\nAutoencoder loss function — Image by Author\nThe idea is to have a very low dimensional latent space so that maximum compression is achieved, but at the same time, the error is small enough. Reducing the dimension of the latent space beyond a certain value will result in a significant loss of information.\nThere are no constraints on the values/distribution of the latent space. It can be anything, as long as it can reconstruct the input when the decoder function is applied to it.\n## Latent space visualization\nBelow is an example of the latent space generated by training the network on an MNIST dataset.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/03/image-116.png)\nLatent space of Autoencoder — Image by Author\nIt can be seen that the same digits tend to cluster themselves in the latent space. Another important thing to note is that there are parts of the latent space that doesn't correspond to any data point. Using those as inputs to the encoder will result in an output that doesn’t look like any digit from the MNIST data. This is what we mean by that the latent space is not regularized. Such a latent space only has a few regions/cluster that has the generative capability, which means that sampling any point in the latent space that belongs within a cluster will generate a variation of the data that the cluster belongs to. But the entire latent space does not have the generative capability. The regions which do not belong to any cluster will generate garbage output. Once the network is trained, and the training data is removed, we have no way of knowing if the output generated by the decoder from a randomly sampled latent vector is valid or not. Hence AE is mainly used for compression.\n> For valid inputs, the AE is able to compress them to fewer bits essentially getting rid of the redundancy (Encoder) but due to non-regularized latent space AE, the decoder can not be used to generate valid input data from latent from vectors sampled from the latent space.\n## Why use AE for compression?\nThe latent space of a linear autoencoder strongly resembles the eigenspace achieved during the principal component analysis of the data. A linear autoencoder with input space dimension  _**n**_ and latent space dimensions set to  _**m <n**_ result will span the same vector space as spanned by the first  _**m**_ eigenvectors of PCA. If AE is similar to PCA, why use AE? The power of AE comes with its non-linearity. Adding non-linearity (such as nonlinear activation functions, and more hidden layers) makes AE capable to learn rather powerful representations of the input data in lower dimensions with much less information loss.\n# Variational AutoEncoders\n## What is it?\nVariational autoencoder addresses the issue of non-regularized latent space in autoencoder and provides the generative capability to the entire space. The encoder in the AE outputs latent vectors. Instead of outputting the vectors in the latent space, the encoder of VAE outputs parameters of a pre-defined distribution in the latent space for every input. The VAE then imposes a constraint on this latent distribution forcing it to be a normal distribution. This constraint makes sure that the latent space is regularized.\n## Block Diagram\nThe block diagram of VAE can be seen below. During training, the input data x is fed to the encoder function  _**e_theta(x)**_. Just like AE, the input is passed through a series of layers (parameterized by the variable theta) reducing its dimensions to achieve a compressed latent vector  _**z**_. However, the latent vector is not the output of the encoder. Instead, the encoder outputs the mean and the standard deviation for each latent variable. The latent vector is then sampled from this mean and standard deviation which is then fed to the decoder to reconstruct the input. The decoder in the VAE works similarly to the one in AE.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/03/image-117.png)\n## Loss function\nThe loss function is defined by the VAE objectives. VAE has two objectives\n  1. Reconstruct the input\n  2. Latent space should be normally distributed\n\n\nHence the training loss of VAE is defined as the sum of these the  _**reconstruction loss**_ and the  _**similarity loss**_. The reconstruction error, just like in AE, is the mean squared loss of the input and reconstructed output. The similarity loss is the KL divergence between the latent space distribution and standard gaussian (zero mean and unit variance). The loss function is then the sum of these two losses.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/03/image-118.png)\nVariational Autoencoder loss function — Image by Author\nAs mentioned before, the latent vector is sampled from the encoder-generated distribution before feeding it to the decoder. This random sampling makes it difficult for backpropagation to happen for the encoder since we can’t trace back errors due to this random sampling. Hence we use a reparameterization trick to model the sampling process which makes it possible for the errors to propagate through the network. The latent vector z is represented as a function of the encoder’s output.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/03/image-119.png)\nThe reparameterization trick is used to represent the latent vector z as a function of the encoder’s output.\n## Latent space visualization\nThe training tries to find a balance between the two losses and ends up with a latent space distribution that looks like the unit norm with clusters grouping similar input data points. The unit norm condition makes sure that the latent space is evenly spread out and does not have significant gaps between clusters. In fact, the clusters of similar-looking data inputs usually overlap in some regions. Below is an example of the latent space generated by training the network on the same MNIST dataset, as was used to visualize the latent space of AE. Note how there are no gaps between clusters and the space resembles the distribution of unit norm.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/03/image-120-1024x768.png)\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/03/image-121-1024x768.png)\nLatent space of Variational Autoencoder — Image by Author\nAn important thing to note is that when the latent vector is sampled from the regions with overlapping clusters, we get morphed data. We get a smooth transition between the decoder's output when we sample the latent space moving from one cluster to the other.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/03/image-122.png)\nLatent space of VAE is regularized — Image by Author\nhttps://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FsV2FOdGqlX0%3Ffeature%3Doembed&display_name=YouTube&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DsV2FOdGqlX0&image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FsV2FOdGqlX0%2Fhqdefault.jpg&key=a19fcc184b9711e1b4764040d3dc5c07&type=text%2Fhtml&schema=youtube\n# Summary\nThis article covered the understanding of Autoencoder (AE) and variational Autoencoder (VAE) which are mainly used for data compression and data generation respectively. VAE addresses the issue of non-regularized latent space of AE which makes it able to generate data from randomly sampled vectors from the latent space. The key summary points of AE and VAE are\n## Autoencoder (AE)\n· Used to generate a compressed transformation of input in a latent space\n· The latent variable is not regularized\n· Picking a random latent variable will generate garbage output\n· The latent variable has a discontinuity\n· Latent variable is deterministic values\n· The latent space lacks the generative capability\n## Variational Autoencoder (VAE)\n· Enforces conditions on the latent variable to be the unit norm\n· The latent variable in the compressed form is mean and variance\n· The latent variable is smooth and continuous\n· A random value of latent variable generates meaningful output at the decoder\n· The input of the decoder is stochastic and is sampled from a gaussian with mean and variance of the output of the encoder.\n· Regularized latent space\n· The latent space has generative capabilities.\n**If this article was helpful to you or you want to learn more about Machine Learning and Data Science, follow**[**Aqeel Anwar**](https://aqeel-anwar.medium.com/)**, or connect with me on**[ _**LinkedIn**_](https://www.linkedin.com/in/aqeelanwarmalik/) _**or**_[ _**Twitter**_](https://twitter.com/_aqeelanwar) _**.**_\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* * *\nAA\nWritten By\n## [Aqeel Anwar](https://towardsdatascience.com/author/aqeel%20anwar/)\n[See all from Aqeel Anwar](https://towardsdatascience.com/author/aqeel%20anwar/)\n[Artificial Intelligence](https://towardsdatascience.com/tag/artificial-intelligence/)[Autoencoder](https://towardsdatascience.com/tag/autoencoder/)[Machine Learning](https://towardsdatascience.com/tag/machine-learning/)[Neural Networks](https://towardsdatascience.com/tag/neural-networks/)[Variational Autoencoder](https://towardsdatascience.com/tag/variational-autoencoder/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Fdifference-between-autoencoder-ae-and-variational-autoencoder-vae-ed7be1c038f2%2F&title=Difference%20between%20AutoEncoder%20\\(AE\\)%20and%20Variational%20AutoEncoder%20\\(VAE\\))\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Fdifference-between-autoencoder-ae-and-variational-autoencoder-vae-ed7be1c038f2%2F&title=Difference%20between%20AutoEncoder%20\\(AE\\)%20and%20Variational%20AutoEncoder%20\\(VAE\\))\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Fdifference-between-autoencoder-ae-and-variational-autoencoder-vae-ed7be1c038f2%2F&text=Difference%20between%20AutoEncoder%20\\(AE\\)%20and%20Variational%20AutoEncoder%20\\(VAE\\))\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/03/0Tdzk4EezAT2eNJyD-scaled.jpg)](https://towardsdatascience.com/apache-spark-on-windows-a-docker-approach-4dd05d8a7147/)\n## [Apache Spark on Windows: A Docker approach](https://towardsdatascience.com/apache-spark-on-windows-a-docker-approach-4dd05d8a7147/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nHow to set-up a Apache Spark development enviroment with minimum effort with Docker for Windows\n[Israel Siqueira](https://towardsdatascience.com/author/israelps/)\nMarch 10, 20216 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/08/15143rJnblUixICQ3V__xvA.jpeg)](https://towardsdatascience.com/learn-git-basics-for-your-ml-project-46ecf03865b/)\n## [Learn Git Basics for your ML Project](https://towardsdatascience.com/learn-git-basics-for-your-ml-project-46ecf03865b/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nGet started with Git and emulate the style of working from real software and machine learning engineers by using version control systems.\n[Yves Boutellier](https://towardsdatascience.com/author/yvesboutellier/)\nAugust 31, 20217 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/08/0fGcbFXywfzsEF2AN-scaled.jpg)](https://towardsdatascience.com/make-your-neural-networks-smaller-pruning-da1fcdb6f206/)\n## [Make Your Neural Networks Smaller: Pruning](https://towardsdatascience.com/make-your-neural-networks-smaller-pruning-da1fcdb6f206/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nPruning is an important tool to make neural networks more economical. Read on to find out how it works.\n[Wilson Wang](https://towardsdatascience.com/author/wilson-wang/)\nAugust 28, 20214 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/03/1M5pCg5RLzy1t6gEYVbnPRg-scaled.jpeg)](https://towardsdatascience.com/fit-vs-predict-vs-fit-predict-in-python-scikit-learn-f15a34a8d39f/)\n## [fit() vs predict() vs fit_predict() in Python scikit-learn](https://towardsdatascience.com/fit-vs-predict-vs-fit-predict-in-python-scikit-learn-f15a34a8d39f/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nWhat's the difference between fit, predict and fit_predict methods in sklearn\n[Giorgos Myrianthous](https://towardsdatascience.com/author/gmyrianthous/)\nMarch 9, 20215 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/12/0w1qP-_spAE_NXdp_.jpg)](https://towardsdatascience.com/pytorch-introduction-building-your-first-linear-model-d868a8681a41/)\n## [PyTorch Introduction - Building your First Linear Model](https://towardsdatascience.com/pytorch-introduction-building-your-first-linear-model-d868a8681a41/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nLearn how to build your first PyTorch model, by using the \"magical\" Linear layer!\n[Ivo Bernardo](https://towardsdatascience.com/author/ivopbernardo/)\nDecember 12, 20230 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/03/19nlE9ERAnIXkKK6QU6EiaQ.png)](https://towardsdatascience.com/detector-classifier-neural-network-architecture-with-tensorflow-fc5dd9dce3e/)\n## [Detector-Classifier Neural Network Architecture with TensorFlow](https://towardsdatascience.com/detector-classifier-neural-network-architecture-with-tensorflow-fc5dd9dce3e/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nThe ever challenging question in training and deploying object detection neural network models - how do I add a new class to my already...\n[Artur Kępka](https://towardsdatascience.com/author/arturkepka/)\nMarch 11, 202111 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/07/0jewbOfkvuY4ub8iw-scaled.jpg)](https://towardsdatascience.com/permutative-language-modeling-explained-9a7743d979b4/)\n## [Permutative Language Modeling, Explained](https://towardsdatascience.com/permutative-language-modeling-explained-9a7743d979b4/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nThe core functionality behind the popular transformer, XLNet, explained\n[Saketh Kotamraju](https://towardsdatascience.com/author/saketh.kotamraju/)\nJuly 1, 20227 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/07/1kRxMVB-G-AjFUjpwhNOXaA-scaled.jpeg)](https://towardsdatascience.com/failed-in-data-science-interview-here-are-some-tips-to-help-you-succeed-2e9a6bb2b307/)\n## [Failed in Data Science Interview? Here Are Some Tips to Help You Succeed](https://towardsdatascience.com/failed-in-data-science-interview-here-are-some-tips-to-help-you-succeed-2e9a6bb2b307/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nBased on 10,000+ hours of experience and many failures!\n[Sharan Kumar Ravindran](https://towardsdatascience.com/author/rsharankumar/)\nJuly 29, 202210 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/11/0uQhoT2C87TDr8EEz.jpg)](https://towardsdatascience.com/the-best-machine-learning-algorithm-for-handwritten-digits-recognition-2c6089ad8f09/)\n## [The Best Machine Learning Algorithm for Handwritten Digits Recognition](https://towardsdatascience.com/the-best-machine-learning-algorithm-for-handwritten-digits-recognition-2c6089ad8f09/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nImplementing Machine Learning Classification Algorithms to Recognize Handwritten Digits\n[Mahnoor Javed](https://towardsdatascience.com/author/mahnoorjaved/)\nNovember 21, 20208 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/3642/image?etag=1780830904480&width=500&height=500) Check Your Biases ](https://towardsdatascience.com/check-your-biases-ba2685a7f799/ \"Check Your Biases\")\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  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/4973/image?etag=1782232567105&width=500&height=500) Machine Learning Tricks, Learning with ChatGPT, and Other Recent Must-Reads ](https://towardsdatascience.com/machine-learning-tricks-learning-with-chatgpt-and-other-recent-must-reads-f277648a1921/ \"Machine Learning Tricks, Learning with ChatGPT, and Other Recent Must-Reads\")\n\n\nword word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word\n  \nmmMwWLliI0fiflO&1  \nmmMwWLliI0fiflO&1  \nmmMwWLliI0fiflO&1  \nmmMwWLliI0fiflO&1  \nmmMwWLliI0fiflO&1  \nmmMwWLliI0fiflO&1  \nmmMwWLliI0fiflO&1\n",
  "metadata": {
    "title": "Difference between AutoEncoder (AE) and Variational AutoEncoder (VAE) | Towards Data Science",
    "description": "How can you compress data or even generate data from random values? That is what Autoencoder and Variational Autoencoder are.",
    "keywords": null,
    "author": "Aqeel Anwar",
    "og:locale": "en_US",
    "og:type": "article",
    "og:title": "Difference between AutoEncoder (AE) and Variational AutoEncoder (VAE)",
    "og:description": "How can you compress data or even generate data from random values? That is what Autoencoder and Variational Autoencoder are.",
    "og:url": "https://towardsdatascience.com/difference-between-autoencoder-ae-and-variational-autoencoder-vae-ed7be1c038f2/",
    "og:site_name": "Towards Data Science",
    "og:image": "https://towardsdatascience.com/images/default-og-image.jpg",
    "og:image:width": "1200",
    "og:image:height": "675",
    "og:image:type": "image/jpeg",
    "twitter:card": "summary_large_image",
    "twitter:site": "@TDataScience",
    "twitter:creator": "@TDataScience",
    "twitter:label1": "Written by",
    "twitter:data1": "Aqeel Anwar",
    "twitter:label2": "Est. reading time",
    "twitter:data2": "8 min read",
    "article:published_time": "2021-11-03T15:21:00.000Z",
    "article:modified_time": "2021-11-03T15:21:00.000Z",
    "article:author": "https://towardsdatascience.com/author/aqeel anwar/"
  },
  "paywall": {
    "listed_paid": true,
    "detected": false,
    "marker": "",
    "public_only": true,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 200,
    "error": "",
    "retried": true
  },
  "code_blocks": [],
  "images": [
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2025/03/image-114.png",
      "alt": "",
      "local_path": "attachments/2c791ce76bf9/images/000.png",
      "bytes": 66496,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2025/03/image-115.png",
      "alt": "",
      "local_path": "attachments/2c791ce76bf9/images/001.png",
      "bytes": 8161,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2025/03/image-116.png",
      "alt": "",
      "local_path": "attachments/2c791ce76bf9/images/002.png",
      "bytes": 178482,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/03/0Tdzk4EezAT2eNJyD-scaled.jpg",
      "alt": "",
      "local_path": "attachments/2c791ce76bf9/images/003.jpg",
      "bytes": 226790,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/08/15143rJnblUixICQ3V__xvA.jpeg",
      "alt": "",
      "local_path": "attachments/2c791ce76bf9/images/004.jpeg",
      "bytes": 49660,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/08/0fGcbFXywfzsEF2AN-scaled.jpg",
      "alt": "",
      "local_path": "attachments/2c791ce76bf9/images/005.jpg",
      "bytes": 226725,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/03/1M5pCg5RLzy1t6gEYVbnPRg-scaled.jpeg",
      "alt": "",
      "local_path": "attachments/2c791ce76bf9/images/006.jpeg",
      "bytes": 140448,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/12/0w1qP-_spAE_NXdp_.jpg",
      "alt": "",
      "local_path": "attachments/2c791ce76bf9/images/007.jpg",
      "bytes": 202153,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/03/19nlE9ERAnIXkKK6QU6EiaQ.png",
      "alt": "",
      "local_path": "attachments/2c791ce76bf9/images/008.png",
      "bytes": 806814,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2022/07/0jewbOfkvuY4ub8iw-scaled.jpg",
      "alt": "",
      "local_path": "attachments/2c791ce76bf9/images/009.jpg",
      "bytes": 430698,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2022/07/1kRxMVB-G-AjFUjpwhNOXaA-scaled.jpeg",
      "alt": "",
      "local_path": "attachments/2c791ce76bf9/images/010.jpeg",
      "bytes": 374475,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2020/11/0uQhoT2C87TDr8EEz.jpg",
      "alt": "",
      "local_path": "attachments/2c791ce76bf9/images/011.jpg",
      "bytes": 114801,
      "downloaded": true
    }
  ],
  "audio": [],
  "videos": [],
  "links": [],
  "retry_at": "2026-10-03T08:00:48",
  "repair_version": 2,
  "repaired_at": "2026-10-14T11:11:49Z",
  "source_url": "https://towardsdatascience.com/difference-between-autoencoder-ae-and-variational-autoencoder-vae-ed7be1c038f2/",
  "delivery_status": "excluded_paid",
  "discovery_status": "excluded_paid",
  "missing_reason": "按原约定排除付费/会员全文"
}