import{S as Wt,i as jt,s as zt,e as n,k as l,w as H,t as i,M as Bt,c as s,d as r,m as c,a as o,x as J,h as a,b as d,G as e,g as h,y as U,L as Kt,q as V,o as G,B as R,v as Qt}from"../../../chunks/vendor-hf-doc-builder.js";import{D as Me}from"../../../chunks/Docstring-hf-doc-builder.js";import{I as _t}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function Xt(bt){let v,pe,_,y,Y,E,Ee,Z,Ae,fe,b,P,ee,A,Te,te,Oe,ue,T,O,Ne,Ce,he,W,Le,me,j,ke,ge,w,Fe,N,Ie,qe,ve,D,$,re,C,He,ne,Je,_e,p,L,Ue,se,Ve,Ge,u,z,Re,We,oe,je,ze,ie,Be,Ke,ae,Qe,Xe,B,Ye,Ze,K,et,tt,Q,rt,nt,st,X,ot,k,it,at,x,F,dt,de,lt,ct,S,I,pt,le,ft,ut,M,q,ht,ce,mt,be;return E=new _t({}),A=new _t({}),C=new _t({}),L=new Me({props:{name:"class diffusers.DDPMScheduler",anchor:"diffusers.DDPMScheduler",parameters:[{name:"num_train_timesteps",val:": int = 1000"},{name:"beta_start",val:": float = 0.0001"},{name:"beta_end",val:": float = 0.02"},{name:"beta_schedule",val:": str = 'linear'"},{name:"trained_betas",val:": typing.Union[numpy.ndarray, typing.List[float], NoneType] = None"},{name:"variance_type",val:": str = 'fixed_small'"},{name:"clip_sample",val:": bool = True"},{name:"prediction_type",val:": str = 'epsilon'"},{name:"clip_sample_range",val:": typing.Optional[float] = 1.0"}],parametersDescription:[{anchor:"diffusers.DDPMScheduler.num_train_timesteps",description:"<strong>num_train_timesteps</strong> (<code>int</code>) &#x2014; number of diffusion steps used to train the model.",name:"num_train_timesteps"},{anchor:"diffusers.DDPMScheduler.beta_start",description:"<strong>beta_start</strong> (<code>float</code>) &#x2014; the starting <code>beta</code> value of inference.",name:"beta_start"},{anchor:"diffusers.DDPMScheduler.beta_end",description:"<strong>beta_end</strong> (<code>float</code>) &#x2014; the final <code>beta</code> value.",name:"beta_end"},{anchor:"diffusers.DDPMScheduler.beta_schedule",description:`<strong>beta_schedule</strong> (<code>str</code>) &#x2014;
the beta schedule, a mapping from a beta range to a sequence of betas for stepping the model. Choose from
<code>linear</code>, <code>scaled_linear</code>, or <code>squaredcos_cap_v2</code>.`,name:"beta_schedule"},{anchor:"diffusers.DDPMScheduler.trained_betas",description:`<strong>trained_betas</strong> (<code>np.ndarray</code>, optional) &#x2014;
option to pass an array of betas directly to the constructor to bypass <code>beta_start</code>, <code>beta_end</code> etc.`,name:"trained_betas"},{anchor:"diffusers.DDPMScheduler.variance_type",description:`<strong>variance_type</strong> (<code>str</code>) &#x2014;
options to clip the variance used when adding noise to the denoised sample. Choose from <code>fixed_small</code>,
<code>fixed_small_log</code>, <code>fixed_large</code>, <code>fixed_large_log</code>, <code>learned</code> or <code>learned_range</code>.`,name:"variance_type"},{anchor:"diffusers.DDPMScheduler.clip_sample",description:`<strong>clip_sample</strong> (<code>bool</code>, default <code>True</code>) &#x2014;
option to clip predicted sample between -1 and 1 for numerical stability.`,name:"clip_sample"},{anchor:"diffusers.DDPMScheduler.prediction_type",description:`<strong>prediction_type</strong> (<code>str</code>, default <code>epsilon</code>, optional) &#x2014;
prediction type of the scheduler function, one of <code>epsilon</code> (predicting the noise of the diffusion
process), <code>sample</code> (directly predicting the noisy sample<code>) or </code>v_prediction\` (see section 2.4
<a href="https://imagen.research.google/video/paper.pdf" rel="nofollow">https://imagen.research.google/video/paper.pdf</a>)`,name:"prediction_type"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_ddpm.py#L76"}}),F=new Me({props:{name:"scale_model_input",anchor:"diffusers.DDPMScheduler.scale_model_input",parameters:[{name:"sample",val:": FloatTensor"},{name:"timestep",val:": typing.Optional[int] = None"}],parametersDescription:[{anchor:"diffusers.DDPMScheduler.scale_model_input.sample",description:"<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014; input sample",name:"sample"},{anchor:"diffusers.DDPMScheduler.scale_model_input.timestep",description:"<strong>timestep</strong> (<code>int</code>, optional) &#x2014; current timestep",name:"timestep"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_ddpm.py#L156",returnDescription:`
<p>scaled input sample</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),I=new Me({props:{name:"set_timesteps",anchor:"diffusers.DDPMScheduler.set_timesteps",parameters:[{name:"num_inference_steps",val:": int"},{name:"device",val:": typing.Union[str, torch.device] = None"}],parametersDescription:[{anchor:"diffusers.DDPMScheduler.set_timesteps.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>) &#x2014;
the number of diffusion steps used when generating samples with a pre-trained model.`,name:"num_inference_steps"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_ddpm.py#L170"}}),q=new Me({props:{name:"step",anchor:"diffusers.DDPMScheduler.step",parameters:[{name:"model_output",val:": FloatTensor"},{name:"timestep",val:": int"},{name:"sample",val:": FloatTensor"},{name:"generator",val:" = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.DDPMScheduler.step.model_output",description:"<strong>model_output</strong> (<code>torch.FloatTensor</code>) &#x2014; direct output from learned diffusion model.",name:"model_output"},{anchor:"diffusers.DDPMScheduler.step.timestep",description:"<strong>timestep</strong> (<code>int</code>) &#x2014; current discrete timestep in the diffusion chain.",name:"timestep"},{anchor:"diffusers.DDPMScheduler.step.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
current instance of sample being created by diffusion process.
generator &#x2014; random number generator.`,name:"sample"},{anchor:"diffusers.DDPMScheduler.step.return_dict",description:"<strong>return_dict</strong> (<code>bool</code>) &#x2014; option for returning tuple rather than DDPMSchedulerOutput class",name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_ddpm.py#L229",returnDescription:`
<p><code>~schedulers.scheduling_utils.DDPMSchedulerOutput</code> if <code>return_dict</code> is True, otherwise a <code>tuple</code>. When
returning a tuple, the first element is the sample tensor.</p>
`,returnType:`
<p><code>~schedulers.scheduling_utils.DDPMSchedulerOutput</code> or <code>tuple</code></p>
`}}),{c(){v=n("meta"),pe=l(),_=n("h1"),y=n("a"),Y=n("span"),H(E.$$.fragment),Ee=l(),Z=n("span"),Ae=i("Denoising diffusion probabilistic models (DDPM)"),fe=l(),b=n("h2"),P=n("a"),ee=n("span"),H(A.$$.fragment),Te=l(),te=n("span"),Oe=i("Overview"),ue=l(),T=n("p"),O=n("a"),Ne=i("Denoising Diffusion Probabilistic Models"),Ce=i(`
(DDPM) by Jonathan Ho, Ajay Jain and Pieter Abbeel proposes the diffusion based model of the same name, but in the context of the \u{1F917} Diffusers library, DDPM refers to the discrete denoising scheduler from the paper as well as the pipeline.`),he=l(),W=n("p"),Le=i("The abstract of the paper is the following:"),me=l(),j=n("p"),ke=i("We present high quality image synthesis results using diffusion probabilistic models, a class of latent variable models inspired by considerations from nonequilibrium thermodynamics. Our best results are obtained by training on a weighted variational bound designed according to a novel connection between diffusion probabilistic models and denoising score matching with Langevin dynamics, and our models naturally admit a progressive lossy decompression scheme that can be interpreted as a generalization of autoregressive decoding. On the unconditional CIFAR10 dataset, we obtain an Inception score of 9.46 and a state-of-the-art FID score of 3.17. On 256x256 LSUN, we obtain sample quality similar to ProgressiveGAN."),ge=l(),w=n("p"),Fe=i("The original paper can be found "),N=n("a"),Ie=i("here"),qe=i("."),ve=l(),D=n("h2"),$=n("a"),re=n("span"),H(C.$$.fragment),He=l(),ne=n("span"),Je=i("DDPMScheduler"),_e=l(),p=n("div"),H(L.$$.fragment),Ue=l(),se=n("p"),Ve=i(`Denoising diffusion probabilistic models (DDPMs) explores the connections between denoising score matching and
Langevin dynamics sampling.`),Ge=l(),u=n("p"),z=n("a"),Re=i("~ConfigMixin"),We=i(" takes care of storing all config attributes that are passed in the scheduler\u2019s "),oe=n("code"),je=i("__init__"),ze=i(`
function, such as `),ie=n("code"),Be=i("num_train_timesteps"),Ke=i(". They can be accessed via "),ae=n("code"),Qe=i("scheduler.config.num_train_timesteps"),Xe=i(`.
`),B=n("a"),Ye=i("SchedulerMixin"),Ze=i(" provides general loading and saving functionality via the "),K=n("a"),et=i("SchedulerMixin.save_pretrained()"),tt=i(` and
`),Q=n("a"),rt=i("from_pretrained()"),nt=i(" functions."),st=l(),X=n("p"),ot=i("For more details, see the original paper: "),k=n("a"),it=i("https://arxiv.org/abs/2006.11239"),at=l(),x=n("div"),H(F.$$.fragment),dt=l(),de=n("p"),lt=i(`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`),ct=l(),S=n("div"),H(I.$$.fragment),pt=l(),le=n("p"),ft=i("Sets the discrete timesteps used for the diffusion chain. Supporting function to be run before inference."),ut=l(),M=n("div"),H(q.$$.fragment),ht=l(),ce=n("p"),mt=i(`Predict the sample at the previous timestep by reversing the SDE. Core function to propagate the diffusion
process from the learned model outputs (most often the predicted noise).`),this.h()},l(t){const f=Bt('[data-svelte="svelte-1phssyn"]',document.head);v=s(f,"META",{name:!0,content:!0}),f.forEach(r),pe=c(t),_=s(t,"H1",{class:!0});var De=o(_);y=s(De,"A",{id:!0,class:!0,href:!0});var Dt=o(y);Y=s(Dt,"SPAN",{});var yt=o(Y);J(E.$$.fragment,yt),yt.forEach(r),Dt.forEach(r),Ee=c(De),Z=s(De,"SPAN",{});var Pt=o(Z);Ae=a(Pt,"Denoising diffusion probabilistic models (DDPM)"),Pt.forEach(r),De.forEach(r),fe=c(t),b=s(t,"H2",{class:!0});var ye=o(b);P=s(ye,"A",{id:!0,class:!0,href:!0});var wt=o(P);ee=s(wt,"SPAN",{});var $t=o(ee);J(A.$$.fragment,$t),$t.forEach(r),wt.forEach(r),Te=c(ye),te=s(ye,"SPAN",{});var xt=o(te);Oe=a(xt,"Overview"),xt.forEach(r),ye.forEach(r),ue=c(t),T=s(t,"P",{});var gt=o(T);O=s(gt,"A",{href:!0,rel:!0});var St=o(O);Ne=a(St,"Denoising Diffusion Probabilistic Models"),St.forEach(r),Ce=a(gt,`
(DDPM) by Jonathan Ho, Ajay Jain and Pieter Abbeel proposes the diffusion based model of the same name, but in the context of the \u{1F917} Diffusers library, DDPM refers to the discrete denoising scheduler from the paper as well as the pipeline.`),gt.forEach(r),he=c(t),W=s(t,"P",{});var Mt=o(W);Le=a(Mt,"The abstract of the paper is the following:"),Mt.forEach(r),me=c(t),j=s(t,"P",{});var Et=o(j);ke=a(Et,"We present high quality image synthesis results using diffusion probabilistic models, a class of latent variable models inspired by considerations from nonequilibrium thermodynamics. Our best results are obtained by training on a weighted variational bound designed according to a novel connection between diffusion probabilistic models and denoising score matching with Langevin dynamics, and our models naturally admit a progressive lossy decompression scheme that can be interpreted as a generalization of autoregressive decoding. On the unconditional CIFAR10 dataset, we obtain an Inception score of 9.46 and a state-of-the-art FID score of 3.17. On 256x256 LSUN, we obtain sample quality similar to ProgressiveGAN."),Et.forEach(r),ge=c(t),w=s(t,"P",{});var Pe=o(w);Fe=a(Pe,"The original paper can be found "),N=s(Pe,"A",{href:!0,rel:!0});var At=o(N);Ie=a(At,"here"),At.forEach(r),qe=a(Pe,"."),Pe.forEach(r),ve=c(t),D=s(t,"H2",{class:!0});var we=o(D);$=s(we,"A",{id:!0,class:!0,href:!0});var Tt=o($);re=s(Tt,"SPAN",{});var Ot=o(re);J(C.$$.fragment,Ot),Ot.forEach(r),Tt.forEach(r),He=c(we),ne=s(we,"SPAN",{});var Nt=o(ne);Je=a(Nt,"DDPMScheduler"),Nt.forEach(r),we.forEach(r),_e=c(t),p=s(t,"DIV",{class:!0});var g=o(p);J(L.$$.fragment,g),Ue=c(g),se=s(g,"P",{});var Ct=o(se);Ve=a(Ct,`Denoising diffusion probabilistic models (DDPMs) explores the connections between denoising score matching and
Langevin dynamics sampling.`),Ct.forEach(r),Ge=c(g),u=s(g,"P",{});var m=o(u);z=s(m,"A",{href:!0});var Lt=o(z);Re=a(Lt,"~ConfigMixin"),Lt.forEach(r),We=a(m," takes care of storing all config attributes that are passed in the scheduler\u2019s "),oe=s(m,"CODE",{});var kt=o(oe);je=a(kt,"__init__"),kt.forEach(r),ze=a(m,`
function, such as `),ie=s(m,"CODE",{});var Ft=o(ie);Be=a(Ft,"num_train_timesteps"),Ft.forEach(r),Ke=a(m,". They can be accessed via "),ae=s(m,"CODE",{});var It=o(ae);Qe=a(It,"scheduler.config.num_train_timesteps"),It.forEach(r),Xe=a(m,`.
`),B=s(m,"A",{href:!0});var qt=o(B);Ye=a(qt,"SchedulerMixin"),qt.forEach(r),Ze=a(m," provides general loading and saving functionality via the "),K=s(m,"A",{href:!0});var Ht=o(K);et=a(Ht,"SchedulerMixin.save_pretrained()"),Ht.forEach(r),tt=a(m,` and
`),Q=s(m,"A",{href:!0});var Jt=o(Q);rt=a(Jt,"from_pretrained()"),Jt.forEach(r),nt=a(m," functions."),m.forEach(r),st=c(g),X=s(g,"P",{});var vt=o(X);ot=a(vt,"For more details, see the original paper: "),k=s(vt,"A",{href:!0,rel:!0});var Ut=o(k);it=a(Ut,"https://arxiv.org/abs/2006.11239"),Ut.forEach(r),vt.forEach(r),at=c(g),x=s(g,"DIV",{class:!0});var $e=o(x);J(F.$$.fragment,$e),dt=c($e),de=s($e,"P",{});var Vt=o(de);lt=a(Vt,`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`),Vt.forEach(r),$e.forEach(r),ct=c(g),S=s(g,"DIV",{class:!0});var xe=o(S);J(I.$$.fragment,xe),pt=c(xe),le=s(xe,"P",{});var Gt=o(le);ft=a(Gt,"Sets the discrete timesteps used for the diffusion chain. Supporting function to be run before inference."),Gt.forEach(r),xe.forEach(r),ut=c(g),M=s(g,"DIV",{class:!0});var Se=o(M);J(q.$$.fragment,Se),ht=c(Se),ce=s(Se,"P",{});var Rt=o(ce);mt=a(Rt,`Predict the sample at the previous timestep by reversing the SDE. Core function to propagate the diffusion
process from the learned model outputs (most often the predicted noise).`),Rt.forEach(r),Se.forEach(r),g.forEach(r),this.h()},h(){d(v,"name","hf:doc:metadata"),d(v,"content",JSON.stringify(Yt)),d(y,"id","denoising-diffusion-probabilistic-models-ddpm"),d(y,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(y,"href","#denoising-diffusion-probabilistic-models-ddpm"),d(_,"class","relative group"),d(P,"id","overview"),d(P,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(P,"href","#overview"),d(b,"class","relative group"),d(O,"href","https://arxiv.org/abs/2006.11239"),d(O,"rel","nofollow"),d(N,"href","https://arxiv.org/abs/2010.02502"),d(N,"rel","nofollow"),d($,"id","diffusers.DDPMScheduler"),d($,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d($,"href","#diffusers.DDPMScheduler"),d(D,"class","relative group"),d(z,"href","/docs/diffusers/main/en/api/configuration#diffusers.ConfigMixin"),d(B,"href","/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin"),d(K,"href","/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin.save_pretrained"),d(Q,"href","/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin.from_pretrained"),d(k,"href","https://arxiv.org/abs/2006.11239"),d(k,"rel","nofollow"),d(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(p,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(t,f){e(document.head,v),h(t,pe,f),h(t,_,f),e(_,y),e(y,Y),U(E,Y,null),e(_,Ee),e(_,Z),e(Z,Ae),h(t,fe,f),h(t,b,f),e(b,P),e(P,ee),U(A,ee,null),e(b,Te),e(b,te),e(te,Oe),h(t,ue,f),h(t,T,f),e(T,O),e(O,Ne),e(T,Ce),h(t,he,f),h(t,W,f),e(W,Le),h(t,me,f),h(t,j,f),e(j,ke),h(t,ge,f),h(t,w,f),e(w,Fe),e(w,N),e(N,Ie),e(w,qe),h(t,ve,f),h(t,D,f),e(D,$),e($,re),U(C,re,null),e(D,He),e(D,ne),e(ne,Je),h(t,_e,f),h(t,p,f),U(L,p,null),e(p,Ue),e(p,se),e(se,Ve),e(p,Ge),e(p,u),e(u,z),e(z,Re),e(u,We),e(u,oe),e(oe,je),e(u,ze),e(u,ie),e(ie,Be),e(u,Ke),e(u,ae),e(ae,Qe),e(u,Xe),e(u,B),e(B,Ye),e(u,Ze),e(u,K),e(K,et),e(u,tt),e(u,Q),e(Q,rt),e(u,nt),e(p,st),e(p,X),e(X,ot),e(X,k),e(k,it),e(p,at),e(p,x),U(F,x,null),e(x,dt),e(x,de),e(de,lt),e(p,ct),e(p,S),U(I,S,null),e(S,pt),e(S,le),e(le,ft),e(p,ut),e(p,M),U(q,M,null),e(M,ht),e(M,ce),e(ce,mt),be=!0},p:Kt,i(t){be||(V(E.$$.fragment,t),V(A.$$.fragment,t),V(C.$$.fragment,t),V(L.$$.fragment,t),V(F.$$.fragment,t),V(I.$$.fragment,t),V(q.$$.fragment,t),be=!0)},o(t){G(E.$$.fragment,t),G(A.$$.fragment,t),G(C.$$.fragment,t),G(L.$$.fragment,t),G(F.$$.fragment,t),G(I.$$.fragment,t),G(q.$$.fragment,t),be=!1},d(t){r(v),t&&r(pe),t&&r(_),R(E),t&&r(fe),t&&r(b),R(A),t&&r(ue),t&&r(T),t&&r(he),t&&r(W),t&&r(me),t&&r(j),t&&r(ge),t&&r(w),t&&r(ve),t&&r(D),R(C),t&&r(_e),t&&r(p),R(L),R(F),R(I),R(q)}}}const Yt={local:"denoising-diffusion-probabilistic-models-ddpm",sections:[{local:"overview",title:"Overview"},{local:"diffusers.DDPMScheduler",title:"DDPMScheduler"}],title:"Denoising diffusion probabilistic models (DDPM)"};function Zt(bt){return Qt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class nr extends Wt{constructor(v){super();jt(this,v,Zt,Xt,zt,{})}}export{nr as default,Yt as metadata};
