Encoder-decoder architecture with variational inference and amortized posterior approximation.
In a previous section we have seen that VAE helps us define the latent space. The ‘right’ latent space is the one that makes the distribution p(z∣θ) the most likely to produce x. We are therefore introducing a stage that complements the aforementioned generative model or decoder given by p(x∣z;θ)p(z∣θ).This stage is called the recognition model or encoder and is given by p(z∣x;θ). The premise is this: the posterior p(z∣x;θ) will result into a much more meaningful and compact latent space z than the prior p(z∣θ). This encoding though, calls for sampling from a posterior that is itself intractable. We then need to use an approximation to such distribution: q(z∣x;ϕ) and we call this the inference model that approximates the recognition model and help us optimize the marginal likelihood.The VAE encoder-decoder spaces are shown below. The picture shows the more compact space that is defined by the encoder.VAE spaces and distributions (from here)The architecture of VAE includes four main components as shown below:VAE Architecture (from here)Similar to the generative model, the inference model can be, in general, a PGM of the form:q(z∣x;ϕ)=∏j=1Mq(zj∣Pa(zj),x;ϕ)and this, similarly to the generative model, can be parametrized with a DNNenc(ϕ). More specifically we obtain the approximation using the following construction:(μ,logΣ)=DNNenc(x,ϕ)q(z∣x;ϕ)=N(z;μ,diag(Σ))The DNNenc implements amortized variational inference, that is, it estimates the posterior parameters over a batch of datapoints and this offers significant boost in the parameter learning.With the encoder defined, the next question is how to train its parameters ϕ jointly with the decoder parameters θ when the true posterior p(z∣x;θ) is intractable. The answer is the Evidence Lower Bound (ELBO) — a tractable surrogate for the marginal log-likelihood that is derived from the KL divergence between q and the true posterior. The derivation and its consequences for joint optimization are covered in the Optimization and the ELBO page.
{"docsConfig":{"theme":"aspen","$schema":"https://mintlify.com/docs.json","name":"aegean.ai","description":"Engineering AI Agents - Comprehensive courses on deep learning, computer vision, robotics, and AI systems","colors":{"primary":"#2196C8","light":"#5CADD8","dark":"#1565B0"},"logo":{"light":"https://mintcdn.com/aegeanaiinc/ai8d4zdsUnwq_5J6/logo.png?fit=max\u0026auto=format\u0026n=ai8d4zdsUnwq_5J6\u0026q=85\u0026s=fe5e281c1569f8468ff85157bd7d9dc3","dark":"https://mintcdn.com/aegeanaiinc/ai8d4zdsUnwq_5J6/logo-dark.png?fit=max\u0026auto=format\u0026n=ai8d4zdsUnwq_5J6\u0026q=85\u0026s=6a455ae676293280c72ec43f2ac544b4","href":"/"},"favicon":"https://mintcdn.com/aegeanaiinc/0dr6ajwzGFHGACv0/favicon.png?fit=max\u0026auto=format\u0026n=0dr6ajwzGFHGACv0\u0026q=85\u0026s=c0348644679947ce971abb8037adb632","appearance":{"default":"system","strict":false},"navbar":{"links":[{"href":"https://github.com/aegean-ai","label":"GitHub"},{"href":"https://www.linkedin.com/company/aegean-ai/","label":"LinkedIn"}]},"footer":{"socials":{"github":"https://github.com/aegean-ai","linkedin":"https://www.linkedin.com/company/aegean-ai","x":"https://x.com/aegeanai"},"links":[{"header":"Products","items":[{"label":"Auraison","href":"https://n8n.aegeanai.com"}]},{"header":"Courses","items":[{"label":"AI Foundations","href":"/courses/ai/index"},{"label":"Computer Vision","href":"/courses/cv/index"},{"label":"Robotics","href":"/courses/robotics/index"}]},{"header":"Resources","items":[{"label":"Use These Docs","href":"/use-these-docs"},{"label":"GitHub","href":"https://github.com/aegean-ai"},{"label":"Blog","href":"/blog"},{"label":"RSS Feed","href":"/rss.xml"}]},{"header":"Company","items":[{"label":"About","href":"/about"},{"label":"Careers","href":"/careers/virtual-internships/index"},{"label":"Contact","href":"https://forms.gle/W3z4NTC883mNY5Kr8"},{"label":"Privacy Policy","href":"/privacy"}]}]},"styling":{"eyebrows":"section","latex":true},"integrations":{"ga4":{"measurementId":"G-EHRC22H65X"},"posthog":{"apiKey":"phc_J5w6esvspb1vh8O3MegWoaUYiq1zzWYuv7GTfjgui6F","sessionRecording":true}},"contextual":{"options":["claude","perplexity","mcp","cursor","vscode",{"title":"Report an issue","description":"Tell us about an error on this page","icon":"bug","href":{"base":"https://github.com/aegean-ai/eaia-feedback/issues/new","query":[{"key":"template","value":"page-issue.yml"},{"key":"page","value":"$path"}]}}],"display":"header"},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"aegeanaiinc","hasAudioNarration":false,"actualSubdomain":"aegeanaiinc","customDomains":["aegean.ai"],"gitSource":{"type":"github","owner":"aegean-ai","repo":"eaia","deployBranch":"prod","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6ad92a50d495d58d39db645f","collectionId":"95d0db87-6d4e-467e-b329-8939d6748db9","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6ad92a50d495d58d39db645f"},"feedback":{"agentFeedback":true},"entitlements":{},"buildId":"6ad92a50d495d58d39db645f","clientVersion":"0.0.3926","searchFilterCounts":[{"language":"default","tag":"Book","count":266},{"language":"default","tag":"Perception","count":55},{"language":"default","tag":"Products","count":52},{"language":"default","tag":"Courses","count":42},{"language":"default","tag":"Applications","count":39},{"language":"default","tag":"Robotics Systems","count":29},{"language":"default","tag":"Manufacturing QC","count":27},{"language":"default","tag":"LLM","count":24},{"language":"default","tag":"Foundations","count":22},{"language":"default","tag":"Physical AI","count":21}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableAskAiSearchBar":true},"hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-v7-file-tree","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"pause-universal-search-reconcile","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"per-site-search-delta","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-private-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-nav-generations","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-agent-model-picker","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"isAtlas":false,"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":"[class*=Header],[class*=Navbar],[class*=header],[class*=navbar],header,nav{padding-top:1.5rem!important;padding-bottom:1.5rem!important}[class*=Brand] img,[class*=Logo] img,[class*=brand] img,[class*=logo] img,a[href=\"/\"] img:first-child,a[href=\"/\"]>img,header img[alt*=logo i],header img[src*=logo i],nav img[alt*=logo i],nav img[src*=logo i]{height:40px!important;max-height:40px!important;width:auto!important}#navbar #sidebar-title,[class*=SiteName],[class*=site-name],[class*=siteName],a[href=\"/\"]>span,header #sidebar-title,header [class*=Logo] span,header [class*=brand] span,header [class*=logo] span,nav [class*=Logo] span,nav [class*=logo] span{font-size:1.35rem!important;font-weight:600!important}a code,a[href] code{color:inherit!important;text-decoration:none!important;padding:0!important}.callout a,.callout b,.callout em,.callout i,.callout p,.callout strong,[class*=callout] a,[class*=callout] b,[class*=callout] em,[class*=callout] i,[class*=callout] p,[class*=callout] strong{font-size:inherit!important;color:inherit!important}.callout li,.callout ol,.callout ul,[class*=callout] li,[class*=callout] ol,[class*=callout] ul{font-size:inherit!important;color:inherit!important;line-height:inherit!important}.mermaid{text-align:center;display:flex;justify-content:center}.mermaid .labelBkg{background-color:#fff!important;border:1px solid #2f6868!important;border-radius:4px!important;padding:0 4px!important}.mermaid .labelBkg:not(:has(p)){display:none!important}.mermaid .edgeLabel{color:#1c3c3c!important}.dark .mermaid .labelBkg{background-color:#1c3c3c!important;border-color:#84c4c0!important}.dark .mermaid .edgeLabel{color:#84c4c0!important}.mermaid .node circle,.mermaid .node polygon,.mermaid .node rect{fill:none!important;stroke:#9ca3af!important;stroke-width:2px!important;rx:12px;ry:12px;transition:stroke .2s ease,filter .2s ease,stroke-width .2s ease}.mermaid .node .nodeLabel,.mermaid .node .nodeLabel p{font-family:inherit!important}.mermaid .node .nodeLabel p{color:#fff!important}.mermaid .node:hover circle,.mermaid .node:hover polygon,.mermaid .node:hover rect,.mermaid a:hover .node circle,.mermaid a:hover .node polygon,.mermaid a:hover .node rect{stroke:#2196c8!important;stroke-width:3px!important;filter:drop-shadow(0 0 8px rgba(33,150,200,.5));cursor:pointer}.mermaid .cluster rect{rx:12px!important;ry:12px!important}.content table td,.content table th,.markdown table td,.markdown table th,.prose table td,.prose table th,[class*=prose] table td,[class*=prose] table th,article table td,article table th{vertical-align:middle!important;line-height:1.5!important}#pagination{display:none}#banner a{color:inherit!important;text-decoration:none!important}.compact-first-col [data-table-wrapper]{overflow-x:visible!important}.compact-first-col table{table-layout:auto!important;width:100%!important}.compact-first-col table td,.compact-first-col table th{min-width:0!important}.compact-first-col table td:first-child,.compact-first-col table th:first-child{width:1%!important;white-space:nowrap!important}.home-page~:is(.callout, [data-callout-type]){display:none!important}#sidebar .sidebar-group-header,#sidebar button[class*=group],#sidebar-content .sidebar-group-header,#sidebar-content button,.sidebar-group-header,[class*=SidebarGroupHeader],[class*=sidebar-group-header],[class^=sidebar_group]>button,[class^=sidebar_group]>div:first-child,aside button{font-size:14px!important;font-weight:400!important;letter-spacing:normal!important;line-height:1.4!important;padding-top:.5rem!important;padding-bottom:.25rem!important;margin:0!important;text-transform:none!important}.sidebar-group:first-child .sidebar-group-header{padding-top:0!important}.sidebar-nav-group-divider{display:none!important}.sidebar-group{margin:0!important;padding:0!important}#sidebar-content{gap:0!important}#sidebar svg,.sidebar-group svg{width:18px!important;height:18px!important;min-width:18px!important;min-height:18px!important}.sidebar-group-header svg,.sidebar-group-icon svg{width:20px!important;height:20px!important;min-width:20px!important;min-height:20px!important}.dark .prose img,.dark [class*=Frame] img,.dark article img,.dark figure img{background-color:#f8f9fa!important;border-radius:8px!important;padding:12px!important}.dark .prose img.no-dark-bg,.dark article img.no-dark-bg,.dark img.no-dark-bg{background-color:transparent!important;border-radius:0!important;padding:0!important}.preview-card{display:flex;flex-direction:column;background:rgba(255,255,255,.03);border-radius:16px;overflow:hidden;transition:background .2s ease,box-shadow .2s ease;text-decoration:none!important;color:inherit!important}.preview-card:hover{background:rgba(255,255,255,.06);box-shadow:0 4px 20px rgba(0,0,0,.3)}.preview-card iframe{width:100%;border:0;border-radius:8px 8px 0 0;display:block}.preview-card-caption{padding:14px 18px 16px}.preview-card-caption h3{font-size:17px!important;font-weight:600!important;margin:0 0 6px!important;line-height:1.4!important}.preview-card-caption p{font-size:13px!important;opacity:.6;margin:0!important;line-height:1.5!important}.preview-card-tags{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}.preview-card-tag{background:rgba(255,255,255,.05);border:0;border-radius:16px;padding:2px 10px;font-size:11px;cursor:default}.preview-card{border:1px solid rgba(0,0,0,.08)}.dark .preview-card{border:1px solid rgba(255,255,255,.06)}.dark .preview-card img{background-color:transparent!important;padding:0!important}.preview-card-tag{color:rgba(0,0,0,.4);background:rgba(0,0,0,.05)}.dark .preview-card-tag{color:rgba(255,255,255,.5);background:rgba(255,255,255,.05)}.katex,.katex *{line-height:normal}.katex .delimsizing.size1{font-size:1em}.katex .delimsizing.size2{font-size:1.2em}.katex .delimsizing.size3{font-size:1.8em}.katex .delimsizing.size4{font-size:2.4em}.katex-display>.katex{overflow-y:hidden}.page-authors{display:flex;flex-wrap:wrap;gap:2px 18px;margin:-4px 0 28px;font-size:14px;line-height:1.5;opacity:.6}.page-author-affiliation::before{content:\" · \"}"}],"page":{"pagePath":"aiml-common/lectures/vae/vae-architecture","slug":"/aiml-common/lectures/vae/vae-architecture","pageMetadata":{"title":"VAE architecture","sidebarTitle":"Architecture","description":"Encoder-decoder architecture with variational inference and amortized posterior approximation.","href":"/aiml-common/lectures/vae/vae-architecture/index"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Encoder-decoder architecture with variational inference and amortized posterior approximation.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,annotation:`annotation`,code:`code`,em:`em`,hr:`hr`,math:`math`,mi:`mi`,mn:`mn`,mo:`mo`,mrow:`mrow`,msub:`msub`,msubsup:`msubsup`,msup:`msup`,mtext:`mtext`,p:`p`,semantics:`semantics`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,..._provideComponents(),...props.components},{Callout,Heading,OptimizedImage,Table}=_components;if(!Callout)_missingMdxReference(`Callout`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!OptimizedImage)_missingMdxReference(`OptimizedImage`,true);if(!Table)_missingMdxReference(`Table`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`In a previous section we have seen that VAE helps us define the latent space. The ‘right’ latent space is the one that makes the distribution `,_jsxs(_components.span,{className:`katex`,children:[_jsx(_components.span,{className:`katex-mathml`,children:_jsx(_components.math,{xmlns:`http://www.w3.org/1998/Math/MathML`,children:_jsxs(_components.semantics,{children:[_jsxs(_components.mrow,{children:[_jsx(_components.mi,{children:`p`}),_jsx(_components.mo,{stretchy:`false`,children:`(`}),_jsx(_components.mi,{mathvariant:`bold`,children:`z`}),_jsx(_components.mi,{mathvariant:`normal`,children:`∣`}),_jsx(_components.mi,{mathvariant:`bold`,children:`θ`}),_jsx(_components.mo,{stretchy:`false`,children:`)`})]}),_jsx(_components.annotation,{encoding:`application/x-tex`,children:`p(\\\\mathbf z| \\\\mathbf \\\\theta)`})]})})}),_jsx(_components.span,{className:`katex-html`,\"aria-hidden\":`true`,children:_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`1em`,verticalAlign:`-0.25em`}}),_jsx(_components.span,{className:`mord mathnormal`,children:`p`}),_jsx(_components.span,{className:`mopen`,children:`(`}),_jsx(_components.span,{className:`mord mathbf`,children:`z`}),_jsx(_components.span,{className:`mord`,children:`∣`}),_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.0278em`},children:`θ`}),_jsx(_components.span,{className:`mclose`,children:`)`})]})})]}),` the most likely to produce `,_jsxs(_components.span,{className:`katex`,children:[_jsx(_components.span,{className:`katex-mathml`,children:_jsx(_components.math,{xmlns:`http://www.w3.org/1998/Math/MathML`,children:_jsxs(_components.semantics,{children:[_jsx(_components.mrow,{children:_jsx(_components.mi,{mathvariant:`bold`,children:`x`})}),_jsx(_components.annotation,{encoding:`application/x-tex`,children:`\\\\mathbf x`})]})})}),_jsx(_components.span,{className:`katex-html`,\"aria-hidden\":`true`,children:_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`0.4444em`}}),_jsx(_components.span,{className:`mord mathbf`,children:`x`})]})})]}),`. We are therefore introducing a stage that complements the aforementioned `,_jsx(_components.em,{children:`generative model or decoder`}),` given by `,_jsxs(_components.span,{className:`katex`,children:[_jsx(_components.span,{className:`katex-mathml`,children:_jsx(_components.math,{xmlns:`http://www.w3.org/1998/Math/MathML`,children:_jsxs(_components.semantics,{children:[_jsxs(_components.mrow,{children:[_jsx(_components.mi,{children:`p`}),_jsx(_components.mo,{stretchy:`false`,children:`(`}),_jsx(_components.mi,{mathvariant:`bold`,children:`x`}),_jsx(_components.mi,{mathvariant:`normal`,children:`∣`}),_jsx(_components.mi,{mathvariant:`bold`,children:`z`}),_jsx(_components.mo,{separator:`true`,children:`;`}),_jsx(_components.mi,{mathvariant:`bold`,children:`θ`}),_jsx(_components.mo,{stretchy:`false`,children:`)`}),_jsx(_components.mi,{children:`p`}),_jsx(_components.mo,{stretchy:`false`,children:`(`}),_jsx(_components.mi,{mathvariant:`bold`,children:`z`}),_jsx(_components.mi,{mathvariant:`normal`,children:`∣`}),_jsx(_components.mi,{children:`θ`}),_jsx(_components.mo,{stretchy:`false`,children:`)`})]}),_jsx(_components.annotation,{encoding:`application/x-tex`,children:`p(\\\\mathbf x| \\\\mathbf z ; \\\\mathbf \\\\theta) p(\\\\mathbf z | \\\\theta)`})]})})}),_jsx(_components.span,{className:`katex-html`,\"aria-hidden\":`true`,children:_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`1em`,verticalAlign:`-0.25em`}}),_jsx(_components.span,{className:`mord mathnormal`,children:`p`}),_jsx(_components.span,{className:`mopen`,children:`(`}),_jsx(_components.span,{className:`mord mathbf`,children:`x`}),_jsx(_components.span,{className:`mord`,children:`∣`}),_jsx(_components.span,{className:`mord mathbf`,children:`z`}),_jsx(_components.span,{className:`mpunct`,children:`;`}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.1667em`}}),_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.0278em`},children:`θ`}),_jsx(_components.span,{className:`mclose`,children:`)`}),_jsx(_components.span,{className:`mord mathnormal`,children:`p`}),_jsx(_components.span,{className:`mopen`,children:`(`}),_jsx(_components.span,{className:`mord mathbf`,children:`z`}),_jsx(_components.span,{className:`mord`,children:`∣`}),_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.0278em`},children:`θ`}),_jsx(_components.span,{className:`mclose`,children:`)`})]})})]}),`.`]}),`\n`,_jsxs(_components.p,{children:[`This stage is called the `,_jsx(_components.em,{children:`recognition model or encoder`}),` and is given by `,_jsxs(_components.span,{className:`katex`,children:[_jsx(_components.span,{className:`katex-mathml`,children:_jsx(_components.math,{xmlns:`http://www.w3.org/1998/Math/MathML`,children:_jsxs(_components.semantics,{children:[_jsxs(_components.mrow,{children:[_jsx(_components.mi,{children:`p`}),_jsx(_components.mo,{stretchy:`false`,children:`(`}),_jsx(_components.mi,{mathvariant:`bold`,children:`z`}),_jsx(_components.mi,{mathvariant:`normal`,children:`∣`}),_jsx(_components.mi,{mathvariant:`bold`,children:`x`}),_jsx(_components.mo,{separator:`true`,children:`;`}),_jsx(_components.mi,{mathvariant:`bold`,children:`θ`}),_jsx(_components.mo,{stretchy:`false`,children:`)`})]}),_jsx(_components.annotation,{encoding:`application/x-tex`,children:`p(\\\\mathbf z| \\\\mathbf x ; \\\\mathbf \\\\theta)`})]})})}),_jsx(_components.span,{className:`katex-html`,\"aria-hidden\":`true`,children:_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`1em`,verticalAlign:`-0.25em`}}),_jsx(_components.span,{className:`mord mathnormal`,children:`p`}),_jsx(_components.span,{className:`mopen`,children:`(`}),_jsx(_components.span,{className:`mord mathbf`,children:`z`}),_jsx(_components.span,{className:`mord`,children:`∣`}),_jsx(_components.span,{className:`mord mathbf`,children:`x`}),_jsx(_components.span,{className:`mpunct`,children:`;`}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.1667em`}}),_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.0278em`},children:`θ`}),_jsx(_components.span,{className:`mclose`,children:`)`})]})})]}),`. The premise is this: the posterior `,_jsxs(_components.span,{className:`katex`,children:[_jsx(_components.span,{className:`katex-mathml`,children:_jsx(_components.math,{xmlns:`http://www.w3.org/1998/Math/MathML`,children:_jsxs(_components.semantics,{children:[_jsxs(_components.mrow,{children:[_jsx(_components.mi,{children:`p`}),_jsx(_components.mo,{stretchy:`false`,children:`(`}),_jsx(_components.mi,{mathvariant:`bold`,children:`z`}),_jsx(_components.mi,{mathvariant:`normal`,children:`∣`}),_jsx(_components.mi,{mathvariant:`bold`,children:`x`}),_jsx(_components.mo,{separator:`true`,children:`;`}),_jsx(_components.mi,{mathvariant:`bold`,children:`θ`}),_jsx(_components.mo,{stretchy:`false`,children:`)`})]}),_jsx(_components.annotation,{encoding:`application/x-tex`,children:`p(\\\\mathbf z | \\\\mathbf x ; \\\\mathbf \\\\theta)`})]})})}),_jsx(_components.span,{className:`katex-html`,\"aria-hidden\":`true`,children:_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`1em`,verticalAlign:`-0.25em`}}),_jsx(_components.span,{className:`mord mathnormal`,children:`p`}),_jsx(_components.span,{className:`mopen`,children:`(`}),_jsx(_components.span,{className:`mord mathbf`,children:`z`}),_jsx(_components.span,{className:`mord`,children:`∣`}),_jsx(_components.span,{className:`mord mathbf`,children:`x`}),_jsx(_components.span,{className:`mpunct`,children:`;`}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.1667em`}}),_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.0278em`},children:`θ`}),_jsx(_components.span,{className:`mclose`,children:`)`})]})})]}),` will result into a much more meaningful and compact latent space `,_jsxs(_components.span,{className:`katex`,children:[_jsx(_components.span,{className:`katex-mathml`,children:_jsx(_components.math,{xmlns:`http://www.w3.org/1998/Math/MathML`,children:_jsxs(_components.semantics,{children:[_jsx(_components.mrow,{children:_jsx(_components.mi,{mathvariant:`bold`,children:`z`})}),_jsx(_components.annotation,{encoding:`application/x-tex`,children:`\\\\mathbf z`})]})})}),_jsx(_components.span,{className:`katex-html`,\"aria-hidden\":`true`,children:_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`0.4444em`}}),_jsx(_components.span,{className:`mord mathbf`,children:`z`})]})})]}),` than the prior `,_jsxs(_components.span,{className:`katex`,children:[_jsx(_components.span,{className:`katex-mathml`,children:_jsx(_components.math,{xmlns:`http://www.w3.org/1998/Math/MathML`,children:_jsxs(_components.semantics,{children:[_jsxs(_components.mrow,{children:[_jsx(_components.mi,{children:`p`}),_jsx(_components.mo,{stretchy:`false`,children:`(`}),_jsx(_components.mi,{mathvariant:`bold`,children:`z`}),_jsx(_components.mi,{mathvariant:`normal`,children:`∣`}),_jsx(_components.mi,{mathvariant:`bold`,children:`θ`}),_jsx(_components.mo,{stretchy:`false`,children:`)`})]}),_jsx(_components.annotation,{encoding:`application/x-tex`,children:`p(\\\\mathbf z | \\\\mathbf \\\\theta)`})]})})}),_jsx(_components.span,{className:`katex-html`,\"aria-hidden\":`true`,children:_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`1em`,verticalAlign:`-0.25em`}}),_jsx(_components.span,{className:`mord mathnormal`,children:`p`}),_jsx(_components.span,{className:`mopen`,children:`(`}),_jsx(_components.span,{className:`mord mathbf`,children:`z`}),_jsx(_components.span,{className:`mord`,children:`∣`}),_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.0278em`},children:`θ`}),_jsx(_components.span,{className:`mclose`,children:`)`})]})})]}),`. This encoding though, calls for sampling from a posterior that is itself intractable. We then need to use an approximation to such distribution: `,_jsxs(_components.span,{className:`katex`,children:[_jsx(_components.span,{className:`katex-mathml`,children:_jsx(_components.math,{xmlns:`http://www.w3.org/1998/Math/MathML`,children:_jsxs(_components.semantics,{children:[_jsxs(_components.mrow,{children:[_jsx(_components.mi,{children:`q`}),_jsx(_components.mo,{stretchy:`false`,children:`(`}),_jsx(_components.mi,{mathvariant:`bold`,children:`z`}),_jsx(_components.mi,{mathvariant:`normal`,children:`∣`}),_jsx(_components.mi,{mathvariant:`bold`,children:`x`}),_jsx(_components.mo,{separator:`true`,children:`;`}),_jsx(_components.mi,{mathvariant:`bold`,children:`ϕ`}),_jsx(_components.mo,{stretchy:`false`,children:`)`})]}),_jsx(_components.annotation,{encoding:`application/x-tex`,children:`q(\\\\mathbf z| \\\\mathbf x ; \\\\mathbf \\\\phi)`})]})})}),_jsx(_components.span,{className:`katex-html`,\"aria-hidden\":`true`,children:_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`1em`,verticalAlign:`-0.25em`}}),_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.0359em`},children:`q`}),_jsx(_components.span,{className:`mopen`,children:`(`}),_jsx(_components.span,{className:`mord mathbf`,children:`z`}),_jsx(_components.span,{className:`mord`,children:`∣`}),_jsx(_components.span,{className:`mord mathbf`,children:`x`}),_jsx(_components.span,{className:`mpunct`,children:`;`}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.1667em`}}),_jsx(_components.span,{className:`mord mathnormal`,children:`ϕ`}),_jsx(_components.span,{className:`mclose`,children:`)`})]})})]}),` and we call this the `,_jsx(_components.em,{children:`inference model`}),` that approximates the recognition model and help us optimize the marginal likelihood.`]}),`\n`,_jsx(_components.p,{children:`The VAE encoder-decoder spaces are shown below. The picture shows the more compact space that is defined by the encoder.`}),`\n`,_jsx(OptimizedImage,{src:`https://mintcdn.com/aegeanaiinc/ujIi1nHYG46RQ4C-/aiml-common/lectures/vae/vae-architecture/images/vae-spaces.png?fit=max\u0026auto=format\u0026n=ujIi1nHYG46RQ4C-\u0026q=85\u0026s=f0f4d82af4eefe3e3cd427c6b47e376f`,alt:`vae`,\"data-og-width\":`671`,width:`671`,\"data-og-height\":`785`,height:`785`,\"data-path\":`aiml-common/lectures/vae/vae-architecture/images/vae-spaces.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/aegeanaiinc/ujIi1nHYG46RQ4C-/aiml-common/lectures/vae/vae-architecture/images/vae-spaces.png?w=280\u0026fit=max\u0026auto=format\u0026n=ujIi1nHYG46RQ4C-\u0026q=85\u0026s=025733c9f18dadca892de9fb51e386c3 280w, https://mintcdn.com/aegeanaiinc/ujIi1nHYG46RQ4C-/aiml-common/lectures/vae/vae-architecture/images/vae-spaces.png?w=560\u0026fit=max\u0026auto=format\u0026n=ujIi1nHYG46RQ4C-\u0026q=85\u0026s=9a719ec898906854996f6dc926c1a179 560w, https://mintcdn.com/aegeanaiinc/ujIi1nHYG46RQ4C-/aiml-common/lectures/vae/vae-architecture/images/vae-spaces.png?w=840\u0026fit=max\u0026auto=format\u0026n=ujIi1nHYG46RQ4C-\u0026q=85\u0026s=a1fe2500e5d5dfd0cc2ebcb58acc69c7 840w, https://mintcdn.com/aegeanaiinc/ujIi1nHYG46RQ4C-/aiml-common/lectures/vae/vae-architecture/images/vae-spaces.png?w=1100\u0026fit=max\u0026auto=format\u0026n=ujIi1nHYG46RQ4C-\u0026q=85\u0026s=a65149c4493bb7be366eabd39d51af4f 1100w, https://mintcdn.com/aegeanaiinc/ujIi1nHYG46RQ4C-/aiml-common/lectures/vae/vae-architecture/images/vae-spaces.png?w=1650\u0026fit=max\u0026auto=format\u0026n=ujIi1nHYG46RQ4C-\u0026q=85\u0026s=ad72aca41d5ca90758df27fdc5071557 1650w, https://mintcdn.com/aegeanaiinc/ujIi1nHYG46RQ4C-/aiml-common/lectures/vae/vae-architecture/images/vae-spaces.png?w=2500\u0026fit=max\u0026auto=format\u0026n=ujIi1nHYG46RQ4C-\u0026q=85\u0026s=37424d2b350da8a85588f17da34cb8cc 2500w`}),`\n`,_jsx(_components.p,{children:_jsxs(_components.em,{children:[`VAE spaces and distributions (from `,_jsx(_components.a,{href:`https://arxiv.org/pdf/1906.02691.pdf`,children:`here`}),`)`]})}),`\n`,_jsx(_components.p,{children:`The architecture of VAE includes four main components as shown below:`}),`\n`,_jsx(OptimizedImage,{src:`https://mintcdn.com/aegeanaiinc/ujIi1nHYG46RQ4C-/aiml-common/lectures/vae/vae-architecture/images/vae-architecture.png?fit=max\u0026auto=format\u0026n=ujIi1nHYG46RQ4C-\u0026q=85\u0026s=f8ec0caeda0fd938e55635b86facb68f`,alt:`vae`,\"data-og-width\":`655`,width:`655`,\"data-og-height\":`281`,height:`281`,\"data-path\":`aiml-common/lectures/vae/vae-architecture/images/vae-architecture.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/aegeanaiinc/ujIi1nHYG46RQ4C-/aiml-common/lectures/vae/vae-architecture/images/vae-architecture.png?w=280\u0026fit=max\u0026auto=format\u0026n=ujIi1nHYG46RQ4C-\u0026q=85\u0026s=3002c29a5378d43329747fe2c01d0fd5 280w, https://mintcdn.com/aegeanaiinc/ujIi1nHYG46RQ4C-/aiml-common/lectures/vae/vae-architecture/images/vae-architecture.png?w=560\u0026fit=max\u0026auto=format\u0026n=ujIi1nHYG46RQ4C-\u0026q=85\u0026s=a38b63d5aa8394b895559e6485aa94dd 560w, https://mintcdn.com/aegeanaiinc/ujIi1nHYG46RQ4C-/aiml-common/lectures/vae/vae-architecture/images/vae-architecture.png?w=840\u0026fit=max\u0026auto=format\u0026n=ujIi1nHYG46RQ4C-\u0026q=85\u0026s=67dc7e5593ca2313e79b6dbbefe6fdea 840w, https://mintcdn.com/aegeanaiinc/ujIi1nHYG46RQ4C-/aiml-common/lectures/vae/vae-architecture/images/vae-architecture.png?w=1100\u0026fit=max\u0026auto=format\u0026n=ujIi1nHYG46RQ4C-\u0026q=85\u0026s=456770014285683e017f346d6cf380c7 1100w, https://mintcdn.com/aegeanaiinc/ujIi1nHYG46RQ4C-/aiml-common/lectures/vae/vae-architecture/images/vae-architecture.png?w=1650\u0026fit=max\u0026auto=format\u0026n=ujIi1nHYG46RQ4C-\u0026q=85\u0026s=14c02cf1ffff39b2c09c67f1e92c288d 1650w, https://mintcdn.com/aegeanaiinc/ujIi1nHYG46RQ4C-/aiml-common/lectures/vae/vae-architecture/images/vae-architecture.png?w=2500\u0026fit=max\u0026auto=format\u0026n=ujIi1nHYG46RQ4C-\u0026q=85\u0026s=b3899ec87daeae3f40c9196fa82b8482 2500w`}),`\n`,_jsx(_components.p,{children:_jsxs(_components.em,{children:[`VAE Architecture (from `,_jsx(_components.a,{href:`https://arxiv.org/pdf/1906.02691.pdf`,children:`here`}),`)`]})}),`\n`,_jsx(_components.p,{children:`Similar to the generative model, the inference model can be, in general, a PGM of the form:`}),`\n`,_jsx(_components.p,{children:_jsxs(_components.span,{className:`katex`,children:[_jsx(_components.span,{className:`katex-mathml`,children:_jsx(_components.math,{xmlns:`http://www.w3.org/1998/Math/MathML`,children:_jsxs(_components.semantics,{children:[_jsxs(_components.mrow,{children:[_jsx(_components.mi,{children:`q`}),_jsx(_components.mo,{stretchy:`false`,children:`(`}),_jsx(_components.mi,{mathvariant:`bold`,children:`z`}),_jsx(_components.mi,{mathvariant:`normal`,children:`∣`}),_jsx(_components.mi,{mathvariant:`bold`,children:`x`}),_jsx(_components.mo,{separator:`true`,children:`;`}),_jsx(_components.mi,{mathvariant:`bold`,children:`ϕ`}),_jsx(_components.mo,{stretchy:`false`,children:`)`}),_jsx(_components.mo,{children:`=`}),_jsxs(_components.msubsup,{children:[_jsx(_components.mo,{children:`∏`}),_jsxs(_components.mrow,{children:[_jsx(_components.mi,{children:`j`}),_jsx(_components.mo,{children:`=`}),_jsx(_components.mn,{children:`1`})]}),_jsx(_components.mi,{children:`M`})]}),_jsx(_components.mi,{children:`q`}),_jsx(_components.mo,{stretchy:`false`,children:`(`}),_jsxs(_components.msub,{children:[_jsx(_components.mi,{mathvariant:`bold`,children:`z`}),_jsx(_components.mi,{children:`j`})]}),_jsx(_components.mi,{mathvariant:`normal`,children:`∣`}),_jsx(_components.mi,{children:`P`}),_jsx(_components.mi,{children:`a`}),_jsx(_components.mo,{stretchy:`false`,children:`(`}),_jsxs(_components.msub,{children:[_jsx(_components.mi,{mathvariant:`bold`,children:`z`}),_jsx(_components.mi,{children:`j`})]}),_jsx(_components.mo,{stretchy:`false`,children:`)`}),_jsx(_components.mo,{separator:`true`,children:`,`}),_jsx(_components.mi,{mathvariant:`bold`,children:`x`}),_jsx(_components.mo,{separator:`true`,children:`;`}),_jsx(_components.mi,{mathvariant:`bold`,children:`ϕ`}),_jsx(_components.mo,{stretchy:`false`,children:`)`})]}),_jsx(_components.annotation,{encoding:`application/x-tex`,children:`q(\\\\mathbf z | \\\\mathbf x ; \\\\mathbf \\\\phi) = \\\\prod_{j=1}^M q(\\\\mathbf z_j | Pa(\\\\mathbf z_j), \\\\mathbf x ; \\\\mathbf \\\\phi)`})]})})}),_jsxs(_components.span,{className:`katex-html`,\"aria-hidden\":`true`,children:[_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`1em`,verticalAlign:`-0.25em`}}),_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.0359em`},children:`q`}),_jsx(_components.span,{className:`mopen`,children:`(`}),_jsx(_components.span,{className:`mord mathbf`,children:`z`}),_jsx(_components.span,{className:`mord`,children:`∣`}),_jsx(_components.span,{className:`mord mathbf`,children:`x`}),_jsx(_components.span,{className:`mpunct`,children:`;`}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.1667em`}}),_jsx(_components.span,{className:`mord mathnormal`,children:`ϕ`}),_jsx(_components.span,{className:`mclose`,children:`)`}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.2778em`}}),_jsx(_components.span,{className:`mrel`,children:`=`}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.2778em`}})]}),_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`1.417em`,verticalAlign:`-0.4358em`}}),_jsxs(_components.span,{className:`mop`,children:[_jsx(_components.span,{className:`mop op-symbol small-op`,style:{position:`relative`,top:`0em`},children:`∏`}),_jsx(_components.span,{className:`msupsub`,children:_jsxs(_components.span,{className:`vlist-t vlist-t2`,children:[_jsxs(_components.span,{className:`vlist-r`,children:[_jsxs(_components.span,{className:`vlist`,style:{height:`0.9812em`},children:[_jsxs(_components.span,{style:{top:`-2.4003em`,marginLeft:`0em`,marginRight:`0.05em`},children:[_jsx(_components.span,{className:`pstrut`,style:{height:`2.7em`}}),_jsx(_components.span,{className:`sizing reset-size6 size3 mtight`,children:_jsxs(_components.span,{className:`mord mtight`,children:[_jsx(_components.span,{className:`mord mathnormal mtight`,style:{marginRight:`0.0572em`},children:`j`}),_jsx(_components.span,{className:`mrel mtight`,children:`=`}),_jsx(_components.span,{className:`mord mtight`,children:`1`})]})})]}),_jsxs(_components.span,{style:{top:`-3.2029em`,marginRight:`0.05em`},children:[_jsx(_components.span,{className:`pstrut`,style:{height:`2.7em`}}),_jsx(_components.span,{className:`sizing reset-size6 size3 mtight`,children:_jsx(_components.span,{className:`mord mathnormal mtight`,style:{marginRight:`0.109em`},children:`M`})})]})]}),_jsx(_components.span,{className:`vlist-s`,children:``})]}),_jsx(_components.span,{className:`vlist-r`,children:_jsx(_components.span,{className:`vlist`,style:{height:`0.4358em`},children:_jsx(_components.span,{})})})]})})]}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.1667em`}}),_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.0359em`},children:`q`}),_jsx(_components.span,{className:`mopen`,children:`(`}),_jsxs(_components.span,{className:`mord`,children:[_jsx(_components.span,{className:`mord mathbf`,children:`z`}),_jsx(_components.span,{className:`msupsub`,children:_jsxs(_components.span,{className:`vlist-t vlist-t2`,children:[_jsxs(_components.span,{className:`vlist-r`,children:[_jsx(_components.span,{className:`vlist`,style:{height:`0.3117em`},children:_jsxs(_components.span,{style:{top:`-2.55em`,marginLeft:`0em`,marginRight:`0.05em`},children:[_jsx(_components.span,{className:`pstrut`,style:{height:`2.7em`}}),_jsx(_components.span,{className:`sizing reset-size6 size3 mtight`,children:_jsx(_components.span,{className:`mord mathnormal mtight`,style:{marginRight:`0.0572em`},children:`j`})})]})}),_jsx(_components.span,{className:`vlist-s`,children:``})]}),_jsx(_components.span,{className:`vlist-r`,children:_jsx(_components.span,{className:`vlist`,style:{height:`0.2861em`},children:_jsx(_components.span,{})})})]})})]}),_jsx(_components.span,{className:`mord`,children:`∣`}),_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.1389em`},children:`P`}),_jsx(_components.span,{className:`mord mathnormal`,children:`a`}),_jsx(_components.span,{className:`mopen`,children:`(`}),_jsxs(_components.span,{className:`mord`,children:[_jsx(_components.span,{className:`mord mathbf`,children:`z`}),_jsx(_components.span,{className:`msupsub`,children:_jsxs(_components.span,{className:`vlist-t vlist-t2`,children:[_jsxs(_components.span,{className:`vlist-r`,children:[_jsx(_components.span,{className:`vlist`,style:{height:`0.3117em`},children:_jsxs(_components.span,{style:{top:`-2.55em`,marginLeft:`0em`,marginRight:`0.05em`},children:[_jsx(_components.span,{className:`pstrut`,style:{height:`2.7em`}}),_jsx(_components.span,{className:`sizing reset-size6 size3 mtight`,children:_jsx(_components.span,{className:`mord mathnormal mtight`,style:{marginRight:`0.0572em`},children:`j`})})]})}),_jsx(_components.span,{className:`vlist-s`,children:``})]}),_jsx(_components.span,{className:`vlist-r`,children:_jsx(_components.span,{className:`vlist`,style:{height:`0.2861em`},children:_jsx(_components.span,{})})})]})})]}),_jsx(_components.span,{className:`mclose`,children:`)`}),_jsx(_components.span,{className:`mpunct`,children:`,`}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.1667em`}}),_jsx(_components.span,{className:`mord mathbf`,children:`x`}),_jsx(_components.span,{className:`mpunct`,children:`;`}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.1667em`}}),_jsx(_components.span,{className:`mord mathnormal`,children:`ϕ`}),_jsx(_components.span,{className:`mclose`,children:`)`})]})]})]})}),`\n`,_jsxs(_components.p,{children:[`and this, similarly to the generative model, can be parametrized with a `,_jsxs(_components.span,{className:`katex`,children:[_jsx(_components.span,{className:`katex-mathml`,children:_jsx(_components.math,{xmlns:`http://www.w3.org/1998/Math/MathML`,children:_jsxs(_components.semantics,{children:[_jsxs(_components.mrow,{children:[_jsx(_components.mi,{children:`D`}),_jsx(_components.mi,{children:`N`}),_jsxs(_components.msub,{children:[_jsx(_components.mi,{children:`N`}),_jsxs(_components.mrow,{children:[_jsx(_components.mi,{children:`e`}),_jsx(_components.mi,{children:`n`}),_jsx(_components.mi,{children:`c`})]})]}),_jsx(_components.mo,{stretchy:`false`,children:`(`}),_jsx(_components.mi,{children:`ϕ`}),_jsx(_components.mo,{stretchy:`false`,children:`)`})]}),_jsx(_components.annotation,{encoding:`application/x-tex`,children:`DNN_{enc}(\\\\phi)`})]})})}),_jsx(_components.span,{className:`katex-html`,\"aria-hidden\":`true`,children:_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`1em`,verticalAlign:`-0.25em`}}),_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.0278em`},children:`D`}),_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.109em`},children:`N`}),_jsxs(_components.span,{className:`mord`,children:[_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.109em`},children:`N`}),_jsx(_components.span,{className:`msupsub`,children:_jsxs(_components.span,{className:`vlist-t vlist-t2`,children:[_jsxs(_components.span,{className:`vlist-r`,children:[_jsx(_components.span,{className:`vlist`,style:{height:`0.1514em`},children:_jsxs(_components.span,{style:{top:`-2.55em`,marginLeft:`-0.109em`,marginRight:`0.05em`},children:[_jsx(_components.span,{className:`pstrut`,style:{height:`2.7em`}}),_jsx(_components.span,{className:`sizing reset-size6 size3 mtight`,children:_jsxs(_components.span,{className:`mord mtight`,children:[_jsx(_components.span,{className:`mord mathnormal mtight`,children:`e`}),_jsx(_components.span,{className:`mord mathnormal mtight`,children:`n`}),_jsx(_components.span,{className:`mord mathnormal mtight`,children:`c`})]})})]})}),_jsx(_components.span,{className:`vlist-s`,children:``})]}),_jsx(_components.span,{className:`vlist-r`,children:_jsx(_components.span,{className:`vlist`,style:{height:`0.15em`},children:_jsx(_components.span,{})})})]})})]}),_jsx(_components.span,{className:`mopen`,children:`(`}),_jsx(_components.span,{className:`mord mathnormal`,children:`ϕ`}),_jsx(_components.span,{className:`mclose`,children:`)`})]})})]}),`. More specifically we obtain the approximation using the following construction:`]}),`\n`,_jsxs(_components.p,{children:[_jsxs(_components.span,{className:`katex`,children:[_jsx(_components.span,{className:`katex-mathml`,children:_jsx(_components.math,{xmlns:`http://www.w3.org/1998/Math/MathML`,children:_jsxs(_components.semantics,{children:[_jsxs(_components.mrow,{children:[_jsx(_components.mo,{stretchy:`false`,children:`(`}),_jsx(_components.mi,{mathvariant:`bold`,children:`μ`}),_jsx(_components.mo,{separator:`true`,children:`,`}),_jsx(_components.mi,{children:`log`}),_jsx(_components.mo,{children:``}),_jsx(_components.mi,{mathvariant:`bold`,children:`Σ`}),_jsx(_components.mo,{stretchy:`false`,children:`)`}),_jsx(_components.mo,{children:`=`}),_jsx(_components.mi,{children:`D`}),_jsx(_components.mi,{children:`N`}),_jsxs(_components.msub,{children:[_jsx(_components.mi,{children:`N`}),_jsxs(_components.mrow,{children:[_jsx(_components.mi,{children:`e`}),_jsx(_components.mi,{children:`n`}),_jsx(_components.mi,{children:`c`})]})]}),_jsx(_components.mo,{stretchy:`false`,children:`(`}),_jsx(_components.mi,{mathvariant:`bold`,children:`x`}),_jsx(_components.mo,{separator:`true`,children:`,`}),_jsx(_components.mi,{mathvariant:`bold`,children:`ϕ`}),_jsx(_components.mo,{stretchy:`false`,children:`)`})]}),_jsx(_components.annotation,{encoding:`application/x-tex`,children:` (\\\\mathbf \\\\mu, \\\\log \\\\mathbf \\\\Sigma ) = DNN_{enc}(\\\\mathbf x, \\\\mathbf \\\\phi)`})]})})}),_jsxs(_components.span,{className:`katex-html`,\"aria-hidden\":`true`,children:[_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`1em`,verticalAlign:`-0.25em`}}),_jsx(_components.span,{className:`mopen`,children:`(`}),_jsx(_components.span,{className:`mord mathnormal`,children:`μ`}),_jsx(_components.span,{className:`mpunct`,children:`,`}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.1667em`}}),_jsxs(_components.span,{className:`mop`,children:[`lo`,_jsx(_components.span,{style:{marginRight:`0.0139em`},children:`g`})]}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.1667em`}}),_jsx(_components.span,{className:`mord mathbf`,children:`Σ`}),_jsx(_components.span,{className:`mclose`,children:`)`}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.2778em`}}),_jsx(_components.span,{className:`mrel`,children:`=`}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.2778em`}})]}),_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`1em`,verticalAlign:`-0.25em`}}),_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.0278em`},children:`D`}),_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.109em`},children:`N`}),_jsxs(_components.span,{className:`mord`,children:[_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.109em`},children:`N`}),_jsx(_components.span,{className:`msupsub`,children:_jsxs(_components.span,{className:`vlist-t vlist-t2`,children:[_jsxs(_components.span,{className:`vlist-r`,children:[_jsx(_components.span,{className:`vlist`,style:{height:`0.1514em`},children:_jsxs(_components.span,{style:{top:`-2.55em`,marginLeft:`-0.109em`,marginRight:`0.05em`},children:[_jsx(_components.span,{className:`pstrut`,style:{height:`2.7em`}}),_jsx(_components.span,{className:`sizing reset-size6 size3 mtight`,children:_jsxs(_components.span,{className:`mord mtight`,children:[_jsx(_components.span,{className:`mord mathnormal mtight`,children:`e`}),_jsx(_components.span,{className:`mord mathnormal mtight`,children:`n`}),_jsx(_components.span,{className:`mord mathnormal mtight`,children:`c`})]})})]})}),_jsx(_components.span,{className:`vlist-s`,children:``})]}),_jsx(_components.span,{className:`vlist-r`,children:_jsx(_components.span,{className:`vlist`,style:{height:`0.15em`},children:_jsx(_components.span,{})})})]})})]}),_jsx(_components.span,{className:`mopen`,children:`(`}),_jsx(_components.span,{className:`mord mathbf`,children:`x`}),_jsx(_components.span,{className:`mpunct`,children:`,`}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.1667em`}}),_jsx(_components.span,{className:`mord mathnormal`,children:`ϕ`}),_jsx(_components.span,{className:`mclose`,children:`)`})]})]})]}),`\n`,_jsxs(_components.span,{className:`katex`,children:[_jsx(_components.span,{className:`katex-mathml`,children:_jsx(_components.math,{xmlns:`http://www.w3.org/1998/Math/MathML`,children:_jsxs(_components.semantics,{children:[_jsxs(_components.mrow,{children:[_jsx(_components.mi,{children:`q`}),_jsx(_components.mo,{stretchy:`false`,children:`(`}),_jsx(_components.mi,{mathvariant:`bold`,children:`z`}),_jsx(_components.mi,{mathvariant:`normal`,children:`∣`}),_jsx(_components.mi,{mathvariant:`bold`,children:`x`}),_jsx(_components.mo,{separator:`true`,children:`;`}),_jsx(_components.mi,{mathvariant:`bold`,children:`ϕ`}),_jsx(_components.mo,{stretchy:`false`,children:`)`}),_jsx(_components.mo,{children:`=`}),_jsx(_components.mi,{children:`N`}),_jsx(_components.mo,{stretchy:`false`,children:`(`}),_jsx(_components.mi,{mathvariant:`bold`,children:`z`}),_jsx(_components.mo,{separator:`true`,children:`;`}),_jsx(_components.mi,{mathvariant:`bold`,children:`μ`}),_jsx(_components.mo,{separator:`true`,children:`,`}),_jsx(_components.mtext,{mathvariant:`sans-serif`,children:`diag`}),_jsx(_components.mo,{stretchy:`false`,children:`(`}),_jsx(_components.mi,{mathvariant:`bold`,children:`Σ`}),_jsx(_components.mo,{stretchy:`false`,children:`)`}),_jsx(_components.mo,{stretchy:`false`,children:`)`})]}),_jsx(_components.annotation,{encoding:`application/x-tex`,children:`q(\\\\mathbf z| \\\\mathbf x ; \\\\mathbf \\\\phi) = N(\\\\mathbf z; \\\\mathbf \\\\mu, \\\\textsf{diag}(\\\\mathbf \\\\Sigma))`})]})})}),_jsxs(_components.span,{className:`katex-html`,\"aria-hidden\":`true`,children:[_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`1em`,verticalAlign:`-0.25em`}}),_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.0359em`},children:`q`}),_jsx(_components.span,{className:`mopen`,children:`(`}),_jsx(_components.span,{className:`mord mathbf`,children:`z`}),_jsx(_components.span,{className:`mord`,children:`∣`}),_jsx(_components.span,{className:`mord mathbf`,children:`x`}),_jsx(_components.span,{className:`mpunct`,children:`;`}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.1667em`}}),_jsx(_components.span,{className:`mord mathnormal`,children:`ϕ`}),_jsx(_components.span,{className:`mclose`,children:`)`}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.2778em`}}),_jsx(_components.span,{className:`mrel`,children:`=`}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.2778em`}})]}),_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`1em`,verticalAlign:`-0.25em`}}),_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.109em`},children:`N`}),_jsx(_components.span,{className:`mopen`,children:`(`}),_jsx(_components.span,{className:`mord mathbf`,children:`z`}),_jsx(_components.span,{className:`mpunct`,children:`;`}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.1667em`}}),_jsx(_components.span,{className:`mord mathnormal`,children:`μ`}),_jsx(_components.span,{className:`mpunct`,children:`,`}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.1667em`}}),_jsx(_components.span,{className:`mord text`,children:_jsx(_components.span,{className:`mord textsf`,children:`diag`})}),_jsx(_components.span,{className:`mopen`,children:`(`}),_jsx(_components.span,{className:`mord mathbf`,children:`Σ`}),_jsx(_components.span,{className:`mclose`,children:`))`})]})]})]})]}),`\n`,_jsxs(_components.p,{children:[`The `,_jsxs(_components.span,{className:`katex`,children:[_jsx(_components.span,{className:`katex-mathml`,children:_jsx(_components.math,{xmlns:`http://www.w3.org/1998/Math/MathML`,children:_jsxs(_components.semantics,{children:[_jsxs(_components.mrow,{children:[_jsx(_components.mi,{children:`D`}),_jsx(_components.mi,{children:`N`}),_jsxs(_components.msub,{children:[_jsx(_components.mi,{children:`N`}),_jsxs(_components.mrow,{children:[_jsx(_components.mi,{children:`e`}),_jsx(_components.mi,{children:`n`}),_jsx(_components.mi,{children:`c`})]})]})]}),_jsx(_components.annotation,{encoding:`application/x-tex`,children:`DNN_{enc}`})]})})}),_jsx(_components.span,{className:`katex-html`,\"aria-hidden\":`true`,children:_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`0.8333em`,verticalAlign:`-0.15em`}}),_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.0278em`},children:`D`}),_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.109em`},children:`N`}),_jsxs(_components.span,{className:`mord`,children:[_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.109em`},children:`N`}),_jsx(_components.span,{className:`msupsub`,children:_jsxs(_components.span,{className:`vlist-t vlist-t2`,children:[_jsxs(_components.span,{className:`vlist-r`,children:[_jsx(_components.span,{className:`vlist`,style:{height:`0.1514em`},children:_jsxs(_components.span,{style:{top:`-2.55em`,marginLeft:`-0.109em`,marginRight:`0.05em`},children:[_jsx(_components.span,{className:`pstrut`,style:{height:`2.7em`}}),_jsx(_components.span,{className:`sizing reset-size6 size3 mtight`,children:_jsxs(_components.span,{className:`mord mtight`,children:[_jsx(_components.span,{className:`mord mathnormal mtight`,children:`e`}),_jsx(_components.span,{className:`mord mathnormal mtight`,children:`n`}),_jsx(_components.span,{className:`mord mathnormal mtight`,children:`c`})]})})]})}),_jsx(_components.span,{className:`vlist-s`,children:``})]}),_jsx(_components.span,{className:`vlist-r`,children:_jsx(_components.span,{className:`vlist`,style:{height:`0.15em`},children:_jsx(_components.span,{})})})]})})]})]})})]}),` implements amortized variational inference, that is, it estimates the posterior parameters over a batch of datapoints and this offers significant boost in the parameter learning.`]}),`\n`,_jsxs(_components.p,{children:[`With the encoder defined, the next question is how to train its parameters `,_jsxs(_components.span,{className:`katex`,children:[_jsx(_components.span,{className:`katex-mathml`,children:_jsx(_components.math,{xmlns:`http://www.w3.org/1998/Math/MathML`,children:_jsxs(_components.semantics,{children:[_jsx(_components.mrow,{children:_jsx(_components.mi,{children:`ϕ`})}),_jsx(_components.annotation,{encoding:`application/x-tex`,children:`\\\\phi`})]})})}),_jsx(_components.span,{className:`katex-html`,\"aria-hidden\":`true`,children:_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`0.8889em`,verticalAlign:`-0.1944em`}}),_jsx(_components.span,{className:`mord mathnormal`,children:`ϕ`})]})})]}),` jointly with the decoder parameters `,_jsxs(_components.span,{className:`katex`,children:[_jsx(_components.span,{className:`katex-mathml`,children:_jsx(_components.math,{xmlns:`http://www.w3.org/1998/Math/MathML`,children:_jsxs(_components.semantics,{children:[_jsx(_components.mrow,{children:_jsx(_components.mi,{children:`θ`})}),_jsx(_components.annotation,{encoding:`application/x-tex`,children:`\\\\theta`})]})})}),_jsx(_components.span,{className:`katex-html`,\"aria-hidden\":`true`,children:_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`0.6944em`}}),_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.0278em`},children:`θ`})]})})]}),` when the true posterior `,_jsxs(_components.span,{className:`katex`,children:[_jsx(_components.span,{className:`katex-mathml`,children:_jsx(_components.math,{xmlns:`http://www.w3.org/1998/Math/MathML`,children:_jsxs(_components.semantics,{children:[_jsxs(_components.mrow,{children:[_jsx(_components.mi,{children:`p`}),_jsx(_components.mo,{stretchy:`false`,children:`(`}),_jsx(_components.mi,{mathvariant:`bold`,children:`z`}),_jsx(_components.mi,{mathvariant:`normal`,children:`∣`}),_jsx(_components.mi,{mathvariant:`bold`,children:`x`}),_jsx(_components.mo,{separator:`true`,children:`;`}),_jsx(_components.mi,{mathvariant:`bold`,children:`θ`}),_jsx(_components.mo,{stretchy:`false`,children:`)`})]}),_jsx(_components.annotation,{encoding:`application/x-tex`,children:`p(\\\\mathbf z | \\\\mathbf x; \\\\mathbf \\\\theta)`})]})})}),_jsx(_components.span,{className:`katex-html`,\"aria-hidden\":`true`,children:_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`1em`,verticalAlign:`-0.25em`}}),_jsx(_components.span,{className:`mord mathnormal`,children:`p`}),_jsx(_components.span,{className:`mopen`,children:`(`}),_jsx(_components.span,{className:`mord mathbf`,children:`z`}),_jsx(_components.span,{className:`mord`,children:`∣`}),_jsx(_components.span,{className:`mord mathbf`,children:`x`}),_jsx(_components.span,{className:`mpunct`,children:`;`}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.1667em`}}),_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.0278em`},children:`θ`}),_jsx(_components.span,{className:`mclose`,children:`)`})]})})]}),` is intractable. The answer is the `,_jsx(_components.strong,{children:`Evidence Lower Bound (ELBO)`}),` — a tractable surrogate for the marginal log-likelihood that is derived from the KL divergence between `,_jsxs(_components.span,{className:`katex`,children:[_jsx(_components.span,{className:`katex-mathml`,children:_jsx(_components.math,{xmlns:`http://www.w3.org/1998/Math/MathML`,children:_jsxs(_components.semantics,{children:[_jsx(_components.mrow,{children:_jsx(_components.mi,{children:`q`})}),_jsx(_components.annotation,{encoding:`application/x-tex`,children:`q`})]})})}),_jsx(_components.span,{className:`katex-html`,\"aria-hidden\":`true`,children:_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`0.625em`,verticalAlign:`-0.1944em`}}),_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.0359em`},children:`q`})]})})]}),` and the true posterior. The derivation and its consequences for joint optimization are covered in the `,_jsx(_components.a,{href:`/aiml-common/lectures/vae/elbo-optimization/index`,children:`Optimization and the ELBO`}),` page.`]}),`\n`,_jsx(Heading,{level:`2`,id:`pytorch-reference`,children:`PyTorch reference`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`PyTorch class`}),_jsx(_components.th,{children:`Description`})]})}),_jsx(_components.tbody,{children:_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.a,{href:`https://docs.pytorch.org/docs/2.12/generated/torch.nn.Linear.html`,children:_jsx(_components.code,{children:`nn.Linear`})})}),_jsxs(_components.td,{children:[`Applies an affine linear transformation to the incoming data: `,_jsxs(_components.span,{className:`katex`,children:[_jsx(_components.span,{className:`katex-mathml`,children:_jsx(_components.math,{xmlns:`http://www.w3.org/1998/Math/MathML`,children:_jsxs(_components.semantics,{children:[_jsxs(_components.mrow,{children:[_jsx(_components.mi,{children:`y`}),_jsx(_components.mo,{children:`=`}),_jsx(_components.mi,{children:`x`}),_jsxs(_components.msup,{children:[_jsx(_components.mi,{children:`A`}),_jsx(_components.mi,{children:`T`})]}),_jsx(_components.mo,{children:`+`}),_jsx(_components.mi,{children:`b`})]}),_jsx(_components.annotation,{encoding:`application/x-tex`,children:`y = xA^T + b`})]})})}),_jsxs(_components.span,{className:`katex-html`,\"aria-hidden\":`true`,children:[_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`0.625em`,verticalAlign:`-0.1944em`}}),_jsx(_components.span,{className:`mord mathnormal`,style:{marginRight:`0.0359em`},children:`y`}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.2778em`}}),_jsx(_components.span,{className:`mrel`,children:`=`}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.2778em`}})]}),_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`0.9247em`,verticalAlign:`-0.0833em`}}),_jsx(_components.span,{className:`mord mathnormal`,children:`x`}),_jsxs(_components.span,{className:`mord`,children:[_jsx(_components.span,{className:`mord mathnormal`,children:`A`}),_jsx(_components.span,{className:`msupsub`,children:_jsx(_components.span,{className:`vlist-t`,children:_jsx(_components.span,{className:`vlist-r`,children:_jsx(_components.span,{className:`vlist`,style:{height:`0.8413em`},children:_jsxs(_components.span,{style:{top:`-3.063em`,marginRight:`0.05em`},children:[_jsx(_components.span,{className:`pstrut`,style:{height:`2.7em`}}),_jsx(_components.span,{className:`sizing reset-size6 size3 mtight`,children:_jsx(_components.span,{className:`mord mathnormal mtight`,style:{marginRight:`0.1389em`},children:`T`})})]})})})})})]}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.2222em`}}),_jsx(_components.span,{className:`mbin`,children:`+`}),_jsx(_components.span,{className:`mspace`,style:{marginRight:`0.2222em`}})]}),_jsxs(_components.span,{className:`base`,children:[_jsx(_components.span,{className:`strut`,style:{height:`0.6944em`}}),_jsx(_components.span,{className:`mord mathnormal`,children:`b`})]})]})]}),`.`]})]})})]}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Callout,{icon:`bug`,iconType:`regular`,children:_jsxs(_components.p,{children:[`Found an error on this page? `,_jsx(_components.a,{href:`https://github.com/aegean-ai/eaia-feedback/issues/new?template=page-issue.yml\u0026page=/aiml-common/lectures/vae/vae-architecture`,children:`Report an issue`}),`.`]})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"VAE architecture","sidebarTitle":"Architecture","description":"Encoder-decoder architecture with variational inference and amortized posterior approximation.","href":"/aiml-common/lectures/vae/vae-architecture/index"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"PyTorch reference","slug":"pytorch-reference","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":["/_mintlify/custom/aegeanaiinc/d160583580826147/aiml-common/lectures/planning/task-planning/pddl/blocksworld/blocksWorldViz.js","/_mintlify/custom/aegeanaiinc/0663393b76c10385/osano.js"],"subdomain":"aegeanaiinc","siteName":"aegean.ai","title":"VAE architecture - aegean.ai","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-07T14:03:34.490Z","originalFileLocation":"aiml-common/lectures/vae/vae-architecture/index.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Encoder-decoder architecture with variational inference and amortized posterior approximation.\">\u003cmeta data-mint-head name=\"application-name\" content=\"aegean.ai\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/aegeanaiinc/6M9Gi5GgxBzndhcq/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/aegeanaiinc/6M9Gi5GgxBzndhcq/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/aegeanaiinc/6M9Gi5GgxBzndhcq/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/aegeanaiinc/6M9Gi5GgxBzndhcq/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/aegeanaiinc/6M9Gi5GgxBzndhcq/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/aegeanaiinc/6M9Gi5GgxBzndhcq/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/aegeanaiinc/6M9Gi5GgxBzndhcq/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/aegeanaiinc/6M9Gi5GgxBzndhcq/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/aegeanaiinc/6M9Gi5GgxBzndhcq/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"VAE architecture - aegean.ai\">\u003cmeta data-mint-head property=\"og:description\" content=\"Encoder-decoder architecture with variational inference and amortized posterior approximation.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"aegean.ai\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://aegean.ai/aiml-common/lectures/vae/vae-architecture\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://aegeanaiinc.mintlify.app/_mintlify/api/og/v2?division=Variational+Autoencoders\u0026amp;title=VAE+architecture\u0026amp;description=Encoder-decoder+architecture+with+variational+inference+and+amortized+posterior+approximation.\u0026amp;theme=2046057d19b3e219a8da908d\u0026amp;signature=3dc1c5d1e597dfac4b1779a3508a0bf5a5c2a5847c1ffa6354bfddab5a124cb6\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"VAE architecture - aegean.ai\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Encoder-decoder architecture with variational inference and amortized posterior approximation.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://aegeanaiinc.mintlify.app/_mintlify/api/og/v2?division=Variational+Autoencoders\u0026amp;title=VAE+architecture\u0026amp;description=Encoder-decoder+architecture+with+variational+inference+and+amortized+posterior+approximation.\u0026amp;theme=2046057d19b3e219a8da908d\u0026amp;signature=3dc1c5d1e597dfac4b1779a3508a0bf5a5c2a5847c1ffa6354bfddab5a124cb6\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/aegeanaiinc/6M9Gi5GgxBzndhcq/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"aegean.ai\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#2196C8\">\u003clink data-mint-head rel=\"canonical\" href=\"https://aegean.ai/aiml-common/lectures/vae/vae-architecture\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/aiml-common/lectures/vae/vae-architecture.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://aegean.ai/#organization\",\"name\":\"aegean.ai\",\"url\":\"https://aegean.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/aegeanaiinc/ai8d4zdsUnwq_5J6/logo.png?fit=max\u0026auto=format\u0026n=ai8d4zdsUnwq_5J6\u0026q=85\u0026s=fe5e281c1569f8468ff85157bd7d9dc3\"}},{\"@type\":\"WebSite\",\"@id\":\"https://aegean.ai#website\",\"name\":\"aegean.ai\",\"url\":\"https://aegean.ai\",\"publisher\":{\"@id\":\"https://aegean.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://aegean.ai/aiml-common/lectures/vae/vae-architecture#webpage\",\"url\":\"https://aegean.ai/aiml-common/lectures/vae/vae-architecture\",\"name\":\"VAE architecture\",\"description\":\"Encoder-decoder architecture with variational inference and amortized posterior approximation.\",\"dateModified\":\"2026-10-07T14:03:34.490Z\",\"isPartOf\":{\"@id\":\"https://aegean.ai#website\"},\"breadcrumb\":{\"@id\":\"https://aegean.ai/aiml-common/lectures/vae/vae-architecture#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://aegean.ai/aiml-common/lectures/vae/vae-architecture#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Variational Autoencoders\",\"item\":\"https://aegean.ai/aiml-common/lectures/vae/introduction/index\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"VAE architecture\",\"item\":\"https://aegean.ai/aiml-common/lectures/vae/vae-architecture\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://aegean.ai/aiml-common/lectures/vae/vae-architecture#article\",\"headline\":\"VAE architecture\",\"name\":\"VAE architecture\",\"description\":\"Encoder-decoder architecture with variational inference and amortized posterior approximation.\",\"url\":\"https://aegean.ai/aiml-common/lectures/vae/vae-architecture\",\"mainEntityOfPage\":{\"@id\":\"https://aegean.ai/aiml-common/lectures/vae/vae-architecture#webpage\"},\"dateModified\":\"2026-10-07T14:03:34.490Z\",\"publisher\":{\"@id\":\"https://aegean.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://aegean.ai#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"aegean.ai\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"aegean.ai","nav":{"global":null,"tabs":[{"tab":"Home","icon":"house","pages":[{"title":"Home","href":""}]},{"tab":"Products","icon":"box","menu":[{"item":"Overview","icon":"box","pages":[{"title":"Overview","href":"/products"}]},{"item":"Platforms","icon":"server","pages":[{"title":"Platforms","href":"/products/platforms"}]},{"item":"Applications","icon":"grid-2","pages":[{"title":"Applications","href":"/products/applications"}]},{"item":"Tech Demonstrations","icon":"flask","pages":[{"title":"Tech Demonstrations","href":"/products/tech-demonstrators"}]}],"pages":[{"title":"Products","href":"/products"}]},{"tab":"Book","icon":"book","menu":[{"item":"Introduction","pages":[{"title":"Introduction","href":"/book/introduction"}]},{"item":"Foundations","pages":[{"title":"Foundations","href":"/book/foundations"}]},{"item":"Neural Networks","pages":[{"title":"Neural Networks","href":"/book/training-dnns"}]},{"item":"Perception","icon":"eye","pages":[{"title":"Perception","href":"/book/perception"}]},{"item":"State Estimation \u0026 Mapping","icon":"compass","pages":[{"title":"State Estimation \u0026 Mapping","href":"/book/state-estimation-mapping"}]},{"item":"LLM","icon":"omega","pages":[{"title":"LLM","href":"/book/llms"}]},{"item":"VLM","icon":"image","pages":[{"title":"VLM","href":"/aiml-common/lectures/vlm"}]},{"item":"ALM","icon":"microphone","pages":[{"title":"ALM","href":"/aiml-common/lectures/speech/text-to-speech-and-voice-cloning"}]},{"item":"Logic","icon":"sitemap","pages":[{"title":"Logic","href":"/book/logic"}]},{"item":"Planning","icon":"route","pages":[{"title":"Planning","href":"/book/task-planning"}]},{"item":"MDPs","icon":"arrows-rotate","pages":[{"title":"MDPs","href":"/book/mdps"}]},{"item":"RL","icon":"arrows-rotate","pages":[{"title":"RL","href":"/book/reinforcement-learning"}]},{"item":"Reasoning","icon":"brain","pages":[{"title":"Reasoning","href":"/aiml-common/lectures/reasoning"}]},{"item":"Latent Transport Models","icon":"wand-magic-sparkles","groups":[{"group":"Latent Transport Models","icon":"wand-magic-sparkles","pages":[{"title":"Latent Transport Models","sidebarTitle":"Overview","href":"/book/latent-transport-models"}]},{"group":"Mixture of Gaussians","icon":"chart-scatter","pages":[{"title":"Latent Variable Models","sidebarTitle":"Latent Variable Models","href":"/aiml-common/lectures/mixture-of-gaussians/index"},{"title":"The Expectation-Maximization (EM) Algorithm","sidebarTitle":"EM Algorithm","href":"/aiml-common/lectures/mixture-of-gaussians/em-algorithm/index"},{"title":"EM for mixture of Gaussians","sidebarTitle":"EM for MoG Example","href":"/aiml-common/lectures/mixture-of-gaussians/em-gaussian-mixture/em-example-mog/em_example_mog"}]},{"group":"Variational Autoencoders","icon":"circle-nodes","pages":[{"title":"Variational Inference","sidebarTitle":"Introduction","href":"/aiml-common/lectures/vae/introduction/index"},{"title":"Conditional generator p(x|z)","sidebarTitle":"Generator Example","href":"/aiml-common/lectures/vae/introduction/x-given-z-generator/x_given_z_generator_example"},{"title":"Estimating marginal likelihood","sidebarTitle":"Monte Carlo Sampling","href":"/aiml-common/lectures/vae/introduction/monte-carlo-sampling/monte-carlo-sampling"},{"title":"MNIST manifold","sidebarTitle":"MNIST Manifold","description":"Visualizing the low-dimensional structure of MNIST with PCA and UMAP.","href":"/aiml-common/lectures/vae/introduction/mnist-manifold/mnist-manifold"},{"title":"VAE architecture","sidebarTitle":"Architecture","href":"/aiml-common/lectures/vae/vae-architecture/index"},{"title":"Optimization and the ELBO","sidebarTitle":"Optimization","description":"Derivation of the Evidence Lower Bound from the KL divergence between the inference model and the true posterior, and why maximizing the ELBO jointly trains the encoder and decoder.","href":"/aiml-common/lectures/vae/elbo-optimization/index"}]},{"group":"Diffusion Models","icon":"wand-magic-sparkles","pages":[{"title":"Introduction to diffusion models","sidebarTitle":"Introduction","href":"/aiml-common/lectures/diffusion/introduction/index"},{"title":"Denoising Diffusion Probabilistic Models","sidebarTitle":"DDPM","href":"/aiml-common/lectures/diffusion/ddpm/index"},{"title":"DDPM MoG Example","sidebarTitle":"DDPM MoG Example","href":"/aiml-common/lectures/diffusion/ddpm/ddpm_mog_tutorial"},{"title":"Brownian motion, the continuous-time core of diffusion","sidebarTitle":"Brownian Motion","tag":"Draft","href":"/aiml-common/lectures/diffusion/brownian-motion/brownian_motion"},{"title":"DDIM MoG Example","sidebarTitle":"DDIM MoG Example","href":"/aiml-common/lectures/diffusion/ddim/ddim_mog_tutorial"},{"title":"Score-based generative models","sidebarTitle":"Score-based methods","tag":"Draft","href":"/aiml-common/lectures/diffusion/score-based/index"},{"title":"Score MoG Example","sidebarTitle":"Score MoG Example","href":"/aiml-common/lectures/diffusion/score-based/score-mog-example/score_mog_example"}]},{"group":"Probability Transport Models","icon":"arrows-left-right","pages":[{"title":"Velocity fields","sidebarTitle":"Velocity fields","tag":"DRAFT","href":"/aiml-common/lectures/velocity-fields/index"},{"title":"Flow matching","sidebarTitle":"Flow matching","tag":"DRAFT","href":"/aiml-common/lectures/flow-matching/index"}]}]},{"item":"Robotics Systems","icon":"robot","pages":[{"title":"Robotics Systems","href":"/book/robotics-systems"}]},{"item":"Physical AI","icon":"microchip","pages":[{"title":"Physical AI","href":"/book/physical-ai"}]},{"item":"Prerequisites","pages":[{"title":"Prerequisites","href":"/book/prerequisites"}]}]},{"tab":"Courses","icon":"graduation-cap","menu":[{"item":"Overview","pages":[{"title":"Overview","href":"/courses"}]},{"item":"Introduction to AI","pages":[{"title":"Introduction to AI","href":"/courses/ai"}]},{"item":"DL for Computer Vision","pages":[{"title":"DL for Computer Vision","href":"/courses/cv"}]},{"item":"AI for Robotics","pages":[{"title":"AI for Robotics","href":"/courses/robotics"}]},{"item":"Resources","pages":[{"title":"Resources","href":"/courses/njit-calendar"}]}],"pages":[{"title":"Courses","href":"/courses"}]},{"tab":"Media","icon":"video","pages":[{"title":"Media","href":"/media"}]},{"tab":"AI Industry","icon":"flask","pages":[{"title":"AI Industry","href":"/research"}]},{"tab":"Blog","icon":"pen-nib","pages":[{"title":"Blog","href":"/blog"}]},{"tab":"Careers","icon":"briefcase","menu":[{"item":"Internships","pages":[{"title":"Internships","href":"/careers/virtual-internships"}]}],"pages":[{"title":"Careers","href":"/careers/virtual-internships"}]},{"tab":"About","icon":"user","pages":[{"title":"About","href":"/about"}]}]},"title":"VAE architecture - aegean.ai","buildId":"dpl_9DauxEjb9gzCtcuhPQFbquJvx7FJ","deploymentId":"dpl_9DauxEjb9gzCtcuhPQFbquJvx7FJ","dynamics":["a74be98ba7"],"chunks":["zoom-image-lightbox-D4WcYaf4.js","PlusIcon-CwhPVjTe.js","lightbox-handle-r17bVUz3.js"]}