import{S as sr,i as ar,s as nr,e as n,k as u,w as y,t as s,M as rr,c as r,d as t,m as f,a as i,x as b,h as a,b as c,G as e,g,y as w,q as M,o as k,B as S,v as ir,L as Ha}from"../../chunks/vendor-hf-doc-builder.js";import{T as Da}from"../../chunks/Tip-hf-doc-builder.js";import{D as Lt}from"../../chunks/Docstring-hf-doc-builder.js";import{C as Qa}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as ht}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Oa}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function dr(C){let d,T,h,p,v;return{c(){d=n("p"),T=s(`This is a recently introduced model so the API hasn\u2019t been tested extensively. There may be some bugs or slight
breaking changes to fix it in the future. If you see something strange, file a `),h=n("a"),p=s("Github Issue"),v=s("."),this.h()},l(l){d=r(l,"P",{});var _=i(d);T=a(_,`This is a recently introduced model so the API hasn\u2019t been tested extensively. There may be some bugs or slight
breaking changes to fix it in the future. If you see something strange, file a `),h=r(_,"A",{href:!0,rel:!0});var j=i(h);p=a(j,"Github Issue"),j.forEach(t),v=a(_,"."),_.forEach(t),this.h()},h(){c(h,"href","https://github.com/huggingface/transformers/issues/new?assignees=&labels=&template=bug-report.md&title"),c(h,"rel","nofollow")},m(l,_){g(l,d,_),e(d,T),e(d,h),e(h,p),e(d,v)},d(l){l&&t(d)}}}function lr(C){let d,T;return d=new Qa({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRpbWVTZXJpZXNUcmFuc2Zvcm1lckNvbmZpZyUyQyUyMFRpbWVTZXJpZXNUcmFuc2Zvcm1lck1vZGVsJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMFRpbWUlMjBTZXJpZXMlMjBUcmFuc2Zvcm1lciUyMGNvbmZpZ3VyYXRpb24lMjB3aXRoJTIwMTIlMjB0aW1lJTIwc3RlcHMlMjBmb3IlMjBwcmVkaWN0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMFRpbWVTZXJpZXNUcmFuc2Zvcm1lckNvbmZpZyhwcmVkaWN0aW9uX2xlbmd0aCUzRDEyKSUwQSUwQSUyMyUyMFJhbmRvbWx5JTIwaW5pdGlhbGl6aW5nJTIwYSUyMG1vZGVsJTIwKHdpdGglMjByYW5kb20lMjB3ZWlnaHRzKSUyMGZyb20lMjB0aGUlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBUaW1lU2VyaWVzVHJhbnNmb3JtZXJNb2RlbChjb25maWd1cmF0aW9uKSUwQSUwQSUyMyUyMEFjY2Vzc2luZyUyMHRoZSUyMG1vZGVsJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBtb2RlbC5jb25maWc=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TimeSeriesTransformerConfig, TimeSeriesTransformerModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Time Series Transformer configuration with 12 time steps for prediction</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = TimeSeriesTransformerConfig(prediction_length=<span class="hljs-number">12</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Randomly initializing a model (with random weights) from the configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TimeSeriesTransformerModel(configuration)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`}}),{c(){y(d.$$.fragment)},l(h){b(d.$$.fragment,h)},m(h,p){w(d,h,p),T=!0},p:Ha,i(h){T||(M(d.$$.fragment,h),T=!0)},o(h){k(d.$$.fragment,h),T=!1},d(h){S(d,h)}}}function cr(C){let d,T,h,p,v;return{c(){d=n("p"),T=s("Although the recipe for forward pass needs to be defined within this function, one should call the "),h=n("code"),p=s("Module"),v=s(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(l){d=r(l,"P",{});var _=i(d);T=a(_,"Although the recipe for forward pass needs to be defined within this function, one should call the "),h=r(_,"CODE",{});var j=i(h);p=a(j,"Module"),j.forEach(t),v=a(_,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),_.forEach(t)},m(l,_){g(l,d,_),e(d,T),e(d,h),e(h,p),e(d,v)},d(l){l&&t(d)}}}function hr(C){let d,T,h,p,v;return p=new Qa({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMGhmX2h1Yl9kb3dubG9hZCUwQWltcG9ydCUyMHRvcmNoJTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRpbWVTZXJpZXNUcmFuc2Zvcm1lck1vZGVsJTBBJTBBZmlsZSUyMCUzRCUyMGhmX2h1Yl9kb3dubG9hZCglMEElMjAlMjAlMjAlMjByZXBvX2lkJTNEJTIyaGYtaW50ZXJuYWwtdGVzdGluZyUyRnRvdXJpc20tbW9udGhseS1iYXRjaCUyMiUyQyUyMGZpbGVuYW1lJTNEJTIydHJhaW4tYmF0Y2gucHQlMjIlMkMlMjByZXBvX3R5cGUlM0QlMjJkYXRhc2V0JTIyJTBBKSUwQWJhdGNoJTIwJTNEJTIwdG9yY2gubG9hZChmaWxlKSUwQSUwQW1vZGVsJTIwJTNEJTIwVGltZVNlcmllc1RyYW5zZm9ybWVyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmh1Z2dpbmdmYWNlJTJGdGltZS1zZXJpZXMtdHJhbnNmb3JtZXItdG91cmlzbS1tb250aGx5JTIyKSUwQSUwQSUyMyUyMGR1cmluZyUyMHRyYWluaW5nJTJDJTIwb25lJTIwcHJvdmlkZXMlMjBib3RoJTIwcGFzdCUyMGFuZCUyMGZ1dHVyZSUyMHZhbHVlcyUwQSUyMyUyMGFzJTIwd2VsbCUyMGFzJTIwcG9zc2libGUlMjBhZGRpdGlvbmFsJTIwZmVhdHVyZXMlMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoJTBBJTIwJTIwJTIwJTIwcGFzdF92YWx1ZXMlM0RiYXRjaCU1QiUyMnBhc3RfdmFsdWVzJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwcGFzdF90aW1lX2ZlYXR1cmVzJTNEYmF0Y2glNUIlMjJwYXN0X3RpbWVfZmVhdHVyZXMlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBwYXN0X29ic2VydmVkX21hc2slM0RiYXRjaCU1QiUyMnBhc3Rfb2JzZXJ2ZWRfbWFzayUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHN0YXRpY19jYXRlZ29yaWNhbF9mZWF0dXJlcyUzRGJhdGNoJTVCJTIyc3RhdGljX2NhdGVnb3JpY2FsX2ZlYXR1cmVzJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwc3RhdGljX3JlYWxfZmVhdHVyZXMlM0RiYXRjaCU1QiUyMnN0YXRpY19yZWFsX2ZlYXR1cmVzJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwZnV0dXJlX3ZhbHVlcyUzRGJhdGNoJTVCJTIyZnV0dXJlX3ZhbHVlcyUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGZ1dHVyZV90aW1lX2ZlYXR1cmVzJTNEYmF0Y2glNUIlMjJmdXR1cmVfdGltZV9mZWF0dXJlcyUyMiU1RCUyQyUwQSklMEElMEFsYXN0X2hpZGRlbl9zdGF0ZSUyMCUzRCUyMG91dHB1dHMubGFzdF9oaWRkZW5fc3RhdGU=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> hf_hub_download
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TimeSeriesTransformerModel

<span class="hljs-meta">&gt;&gt;&gt; </span>file = hf_hub_download(
<span class="hljs-meta">... </span>    repo_id=<span class="hljs-string">&quot;hf-internal-testing/tourism-monthly-batch&quot;</span>, filename=<span class="hljs-string">&quot;train-batch.pt&quot;</span>, repo_type=<span class="hljs-string">&quot;dataset&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>batch = torch.load(file)

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TimeSeriesTransformerModel.from_pretrained(<span class="hljs-string">&quot;huggingface/time-series-transformer-tourism-monthly&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># during training, one provides both past and future values</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># as well as possible additional features</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(
<span class="hljs-meta">... </span>    past_values=batch[<span class="hljs-string">&quot;past_values&quot;</span>],
<span class="hljs-meta">... </span>    past_time_features=batch[<span class="hljs-string">&quot;past_time_features&quot;</span>],
<span class="hljs-meta">... </span>    past_observed_mask=batch[<span class="hljs-string">&quot;past_observed_mask&quot;</span>],
<span class="hljs-meta">... </span>    static_categorical_features=batch[<span class="hljs-string">&quot;static_categorical_features&quot;</span>],
<span class="hljs-meta">... </span>    static_real_features=batch[<span class="hljs-string">&quot;static_real_features&quot;</span>],
<span class="hljs-meta">... </span>    future_values=batch[<span class="hljs-string">&quot;future_values&quot;</span>],
<span class="hljs-meta">... </span>    future_time_features=batch[<span class="hljs-string">&quot;future_time_features&quot;</span>],
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_state = outputs.last_hidden_state`}}),{c(){d=n("p"),T=s("Examples:"),h=u(),y(p.$$.fragment)},l(l){d=r(l,"P",{});var _=i(d);T=a(_,"Examples:"),_.forEach(t),h=f(l),b(p.$$.fragment,l)},m(l,_){g(l,d,_),e(d,T),g(l,h,_),w(p,l,_),v=!0},p:Ha,i(l){v||(M(p.$$.fragment,l),v=!0)},o(l){k(p.$$.fragment,l),v=!1},d(l){l&&t(d),l&&t(h),S(p,l)}}}function mr(C){let d,T,h,p,v;return{c(){d=n("p"),T=s("Although the recipe for forward pass needs to be defined within this function, one should call the "),h=n("code"),p=s("Module"),v=s(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(l){d=r(l,"P",{});var _=i(d);T=a(_,"Although the recipe for forward pass needs to be defined within this function, one should call the "),h=r(_,"CODE",{});var j=i(h);p=a(j,"Module"),j.forEach(t),v=a(_,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),_.forEach(t)},m(l,_){g(l,d,_),e(d,T),e(d,h),e(h,p),e(d,v)},d(l){l&&t(d)}}}function ur(C){let d,T,h,p,v;return p=new Qa({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMGhmX2h1Yl9kb3dubG9hZCUwQWltcG9ydCUyMHRvcmNoJTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRpbWVTZXJpZXNUcmFuc2Zvcm1lckZvclByZWRpY3Rpb24lMEElMEFmaWxlJTIwJTNEJTIwaGZfaHViX2Rvd25sb2FkKCUwQSUyMCUyMCUyMCUyMHJlcG9faWQlM0QlMjJoZi1pbnRlcm5hbC10ZXN0aW5nJTJGdG91cmlzbS1tb250aGx5LWJhdGNoJTIyJTJDJTIwZmlsZW5hbWUlM0QlMjJ0cmFpbi1iYXRjaC5wdCUyMiUyQyUyMHJlcG9fdHlwZSUzRCUyMmRhdGFzZXQlMjIlMEEpJTBBYmF0Y2glMjAlM0QlMjB0b3JjaC5sb2FkKGZpbGUpJTBBJTBBbW9kZWwlMjAlM0QlMjBUaW1lU2VyaWVzVHJhbnNmb3JtZXJGb3JQcmVkaWN0aW9uLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJodWdnaW5nZmFjZSUyRnRpbWUtc2VyaWVzLXRyYW5zZm9ybWVyLXRvdXJpc20tbW9udGhseSUyMiUwQSklMEElMEElMjMlMjBkdXJpbmclMjB0cmFpbmluZyUyQyUyMG9uZSUyMHByb3ZpZGVzJTIwYm90aCUyMHBhc3QlMjBhbmQlMjBmdXR1cmUlMjB2YWx1ZXMlMEElMjMlMjBhcyUyMHdlbGwlMjBhcyUyMHBvc3NpYmxlJTIwYWRkaXRpb25hbCUyMGZlYXR1cmVzJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCUwQSUyMCUyMCUyMCUyMHBhc3RfdmFsdWVzJTNEYmF0Y2glNUIlMjJwYXN0X3ZhbHVlcyUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHBhc3RfdGltZV9mZWF0dXJlcyUzRGJhdGNoJTVCJTIycGFzdF90aW1lX2ZlYXR1cmVzJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwcGFzdF9vYnNlcnZlZF9tYXNrJTNEYmF0Y2glNUIlMjJwYXN0X29ic2VydmVkX21hc2slMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBzdGF0aWNfY2F0ZWdvcmljYWxfZmVhdHVyZXMlM0RiYXRjaCU1QiUyMnN0YXRpY19jYXRlZ29yaWNhbF9mZWF0dXJlcyUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHN0YXRpY19yZWFsX2ZlYXR1cmVzJTNEYmF0Y2glNUIlMjJzdGF0aWNfcmVhbF9mZWF0dXJlcyUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGZ1dHVyZV92YWx1ZXMlM0RiYXRjaCU1QiUyMmZ1dHVyZV92YWx1ZXMlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBmdXR1cmVfdGltZV9mZWF0dXJlcyUzRGJhdGNoJTVCJTIyZnV0dXJlX3RpbWVfZmVhdHVyZXMlMjIlNUQlMkMlMEEpJTBBJTBBbG9zcyUyMCUzRCUyMG91dHB1dHMubG9zcyUwQWxvc3MuYmFja3dhcmQoKSUwQSUwQSUyMyUyMGR1cmluZyUyMGluZmVyZW5jZSUyQyUyMG9uZSUyMG9ubHklMjBwcm92aWRlcyUyMHBhc3QlMjB2YWx1ZXMlMEElMjMlMjBhcyUyMHdlbGwlMjBhcyUyMHBvc3NpYmxlJTIwYWRkaXRpb25hbCUyMGZlYXR1cmVzJTBBJTIzJTIwdGhlJTIwbW9kZWwlMjBhdXRvcmVncmVzc2l2ZWx5JTIwZ2VuZXJhdGVzJTIwZnV0dXJlJTIwdmFsdWVzJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCUwQSUyMCUyMCUyMCUyMHBhc3RfdmFsdWVzJTNEYmF0Y2glNUIlMjJwYXN0X3ZhbHVlcyUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHBhc3RfdGltZV9mZWF0dXJlcyUzRGJhdGNoJTVCJTIycGFzdF90aW1lX2ZlYXR1cmVzJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwcGFzdF9vYnNlcnZlZF9tYXNrJTNEYmF0Y2glNUIlMjJwYXN0X29ic2VydmVkX21hc2slMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBzdGF0aWNfY2F0ZWdvcmljYWxfZmVhdHVyZXMlM0RiYXRjaCU1QiUyMnN0YXRpY19jYXRlZ29yaWNhbF9mZWF0dXJlcyUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHN0YXRpY19yZWFsX2ZlYXR1cmVzJTNEYmF0Y2glNUIlMjJzdGF0aWNfcmVhbF9mZWF0dXJlcyUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGZ1dHVyZV90aW1lX2ZlYXR1cmVzJTNEYmF0Y2glNUIlMjJmdXR1cmVfdGltZV9mZWF0dXJlcyUyMiU1RCUyQyUwQSklMEElMEFtZWFuX3ByZWRpY3Rpb24lMjAlM0QlMjBvdXRwdXRzLnNlcXVlbmNlcy5tZWFuKGRpbSUzRDEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> hf_hub_download
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TimeSeriesTransformerForPrediction

<span class="hljs-meta">&gt;&gt;&gt; </span>file = hf_hub_download(
<span class="hljs-meta">... </span>    repo_id=<span class="hljs-string">&quot;hf-internal-testing/tourism-monthly-batch&quot;</span>, filename=<span class="hljs-string">&quot;train-batch.pt&quot;</span>, repo_type=<span class="hljs-string">&quot;dataset&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>batch = torch.load(file)

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TimeSeriesTransformerForPrediction.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;huggingface/time-series-transformer-tourism-monthly&quot;</span>
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># during training, one provides both past and future values</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># as well as possible additional features</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(
<span class="hljs-meta">... </span>    past_values=batch[<span class="hljs-string">&quot;past_values&quot;</span>],
<span class="hljs-meta">... </span>    past_time_features=batch[<span class="hljs-string">&quot;past_time_features&quot;</span>],
<span class="hljs-meta">... </span>    past_observed_mask=batch[<span class="hljs-string">&quot;past_observed_mask&quot;</span>],
<span class="hljs-meta">... </span>    static_categorical_features=batch[<span class="hljs-string">&quot;static_categorical_features&quot;</span>],
<span class="hljs-meta">... </span>    static_real_features=batch[<span class="hljs-string">&quot;static_real_features&quot;</span>],
<span class="hljs-meta">... </span>    future_values=batch[<span class="hljs-string">&quot;future_values&quot;</span>],
<span class="hljs-meta">... </span>    future_time_features=batch[<span class="hljs-string">&quot;future_time_features&quot;</span>],
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>loss.backward()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># during inference, one only provides past values</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># as well as possible additional features</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># the model autoregressively generates future values</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(
<span class="hljs-meta">... </span>    past_values=batch[<span class="hljs-string">&quot;past_values&quot;</span>],
<span class="hljs-meta">... </span>    past_time_features=batch[<span class="hljs-string">&quot;past_time_features&quot;</span>],
<span class="hljs-meta">... </span>    past_observed_mask=batch[<span class="hljs-string">&quot;past_observed_mask&quot;</span>],
<span class="hljs-meta">... </span>    static_categorical_features=batch[<span class="hljs-string">&quot;static_categorical_features&quot;</span>],
<span class="hljs-meta">... </span>    static_real_features=batch[<span class="hljs-string">&quot;static_real_features&quot;</span>],
<span class="hljs-meta">... </span>    future_time_features=batch[<span class="hljs-string">&quot;future_time_features&quot;</span>],
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>mean_prediction = outputs.sequences.mean(dim=<span class="hljs-number">1</span>)`}}),{c(){d=n("p"),T=s("Examples:"),h=u(),y(p.$$.fragment)},l(l){d=r(l,"P",{});var _=i(d);T=a(_,"Examples:"),_.forEach(t),h=f(l),b(p.$$.fragment,l)},m(l,_){g(l,d,_),e(d,T),g(l,h,_),w(p,l,_),v=!0},p:Ha,i(l){v||(M(p.$$.fragment,l),v=!0)},o(l){k(p.$$.fragment,l),v=!1},d(l){l&&t(d),l&&t(h),S(p,l)}}}function fr(C){let d,T,h,p,v,l,_,j,Uo,Kt,K,eo,G,ee,mt,ye,xo,ut,Co,to,Be,jo,oo,Ye,Fo,so,F,V,Jo,Pe,zo,$o,Ae,Eo,qo,Zo,U,De,No,Ro,ft,Xo,Wo,pt,Io,Go,_t,Vo,Bo,gt,Yo,Po,Tt,Ao,Do,vt,Oo,Ho,Qo,X,Lo,yt,Ko,es,bt,ts,os,N,te,wt,ss,as,Mt,ns,rs,is,oe,kt,ds,ls,St,cs,hs,ms,W,Ut,us,fs,xt,ps,_s,Ct,gs,Ts,vs,E,jt,ys,bs,Ft,ws,Ms,Jt,ks,Ss,Oe,Us,xs,Cs,R,js,zt,Fs,Js,$t,zs,$s,Et,Es,qs,Zs,be,Ns,qt,Rs,Xs,ao,se,Ws,we,Is,Gs,no,B,ae,Zt,Me,Vs,Nt,Bs,ro,He,Ys,io,Qe,Le,Ps,ke,As,lo,Y,ne,Rt,Se,Ds,Xt,Os,co,J,Ue,Hs,P,Qs,Ke,Ls,Ks,xe,ea,ta,oa,A,sa,et,aa,na,tt,ra,ia,da,re,ho,D,ie,Wt,Ce,la,It,ca,mo,z,je,ha,Fe,ma,ot,ua,fa,pa,Je,_a,ze,ga,Ta,va,q,$e,ya,O,ba,st,wa,Ma,Gt,ka,Sa,Ua,de,xa,le,uo,H,ce,Vt,Ee,Ca,Bt,ja,fo,$,qe,Fa,Ze,Ja,at,za,$a,Ea,Ne,qa,Re,Za,Na,Ra,Z,Xe,Xa,Q,Wa,nt,Ia,Ga,Yt,Va,Ba,Ya,he,Pa,me,po;return l=new ht({}),K=new Da({props:{$$slots:{default:[dr]},$$scope:{ctx:C}}}),ye=new ht({}),Me=new ht({}),Se=new ht({}),Ue=new Lt({props:{name:"class transformers.TimeSeriesTransformerConfig",anchor:"transformers.TimeSeriesTransformerConfig",parameters:[{name:"prediction_length",val:": typing.Optional[int] = None"},{name:"context_length",val:": typing.Optional[int] = None"},{name:"distribution_output",val:": str = 'student_t'"},{name:"loss",val:": str = 'nll'"},{name:"input_size",val:": int = 1"},{name:"lags_sequence",val:": typing.List[int] = [1, 2, 3, 4, 5, 6, 7]"},{name:"scaling",val:": typing.Union[str, bool, NoneType] = 'mean'"},{name:"num_dynamic_real_features",val:": int = 0"},{name:"num_static_categorical_features",val:": int = 0"},{name:"num_static_real_features",val:": int = 0"},{name:"num_time_features",val:": int = 0"},{name:"cardinality",val:": typing.Optional[typing.List[int]] = None"},{name:"embedding_dimension",val:": typing.Optional[typing.List[int]] = None"},{name:"encoder_ffn_dim",val:": int = 32"},{name:"decoder_ffn_dim",val:": int = 32"},{name:"encoder_attention_heads",val:": int = 2"},{name:"decoder_attention_heads",val:": int = 2"},{name:"encoder_layers",val:": int = 2"},{name:"decoder_layers",val:": int = 2"},{name:"is_encoder_decoder",val:": bool = True"},{name:"activation_function",val:": str = 'gelu'"},{name:"d_model",val:": int = 64"},{name:"dropout",val:": float = 0.1"},{name:"encoder_layerdrop",val:": float = 0.1"},{name:"decoder_layerdrop",val:": float = 0.1"},{name:"attention_dropout",val:": float = 0.1"},{name:"activation_dropout",val:": float = 0.1"},{name:"num_parallel_samples",val:": int = 100"},{name:"init_std",val:": float = 0.02"},{name:"use_cache",val:" = True"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TimeSeriesTransformerConfig.prediction_length",description:`<strong>prediction_length</strong> (<code>int</code>) &#x2014;
The prediction length for the decoder. In other words, the prediction horizon of the model. This value is
typically dictated by the dataset and we recommend to set it appropriately.`,name:"prediction_length"},{anchor:"transformers.TimeSeriesTransformerConfig.context_length",description:`<strong>context_length</strong> (<code>int</code>, <em>optional</em>, defaults to <code>prediction_length</code>) &#x2014;
The context length for the encoder. If <code>None</code>, the context length will be the same as the
<code>prediction_length</code>.`,name:"context_length"},{anchor:"transformers.TimeSeriesTransformerConfig.distribution_output",description:`<strong>distribution_output</strong> (<code>string</code>, <em>optional</em>, defaults to <code>&quot;student_t&quot;</code>) &#x2014;
The distribution emission head for the model. Could be either &#x201C;student_t&#x201D;, &#x201C;normal&#x201D; or &#x201C;negative_binomial&#x201D;.`,name:"distribution_output"},{anchor:"transformers.TimeSeriesTransformerConfig.loss",description:`<strong>loss</strong> (<code>string</code>, <em>optional</em>, defaults to <code>&quot;nll&quot;</code>) &#x2014;
The loss function for the model corresponding to the <code>distribution_output</code> head. For parametric
distributions it is the negative log likelihood (nll) - which currently is the only supported one.`,name:"loss"},{anchor:"transformers.TimeSeriesTransformerConfig.input_size",description:`<strong>input_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The size of the target variable which by default is 1 for univariate targets. Would be &gt; 1 in case of
multivariate targets.`,name:"input_size"},{anchor:"transformers.TimeSeriesTransformerConfig.scaling",description:`<strong>scaling</strong> (<code>string</code> or <code>bool</code>, <em>optional</em> defaults to <code>&quot;mean&quot;</code>) &#x2014;
Whether to scale the input targets via &#x201C;mean&#x201D; scaler, &#x201C;std&#x201D; scaler or no scaler if <code>None</code>. If <code>True</code>, the
scaler is set to &#x201C;mean&#x201D;.`,name:"scaling"},{anchor:"transformers.TimeSeriesTransformerConfig.lags_sequence",description:`<strong>lags_sequence</strong> (<code>list[int]</code>, <em>optional</em>, defaults to <code>[1, 2, 3, 4, 5, 6, 7]</code>) &#x2014;
The lags of the input time series as covariates often dictated by the frequency of the data. Default is
<code>[1, 2, 3, 4, 5, 6, 7]</code> but we recommend to change it based on the dataset appropriately.`,name:"lags_sequence"},{anchor:"transformers.TimeSeriesTransformerConfig.num_time_features",description:`<strong>num_time_features</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
The number of time features in the input time series.`,name:"num_time_features"},{anchor:"transformers.TimeSeriesTransformerConfig.num_dynamic_real_features",description:`<strong>num_dynamic_real_features</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
The number of dynamic real valued features.`,name:"num_dynamic_real_features"},{anchor:"transformers.TimeSeriesTransformerConfig.num_static_categorical_features",description:`<strong>num_static_categorical_features</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
The number of static categorical features.`,name:"num_static_categorical_features"},{anchor:"transformers.TimeSeriesTransformerConfig.num_static_real_features",description:`<strong>num_static_real_features</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
The number of static real valued features.`,name:"num_static_real_features"},{anchor:"transformers.TimeSeriesTransformerConfig.cardinality",description:`<strong>cardinality</strong> (<code>list[int]</code>, <em>optional</em>) &#x2014;
The cardinality (number of different values) for each of the static categorical features. Should be a list
of integers, having the same length as <code>num_static_categorical_features</code>. Cannot be <code>None</code> if
<code>num_static_categorical_features</code> is &gt; 0.`,name:"cardinality"},{anchor:"transformers.TimeSeriesTransformerConfig.embedding_dimension",description:`<strong>embedding_dimension</strong> (<code>list[int]</code>, <em>optional</em>) &#x2014;
The dimension of the embedding for each of the static categorical features. Should be a list of integers,
having the same length as <code>num_static_categorical_features</code>. Cannot be <code>None</code> if
<code>num_static_categorical_features</code> is &gt; 0.`,name:"embedding_dimension"},{anchor:"transformers.TimeSeriesTransformerConfig.d_model",description:`<strong>d_model</strong> (<code>int</code>, <em>optional</em>, defaults to 64) &#x2014;
Dimensionality of the transformer layers.`,name:"d_model"},{anchor:"transformers.TimeSeriesTransformerConfig.encoder_layers",description:`<strong>encoder_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
Number of encoder layers.`,name:"encoder_layers"},{anchor:"transformers.TimeSeriesTransformerConfig.decoder_layers",description:`<strong>decoder_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
Number of decoder layers.`,name:"decoder_layers"},{anchor:"transformers.TimeSeriesTransformerConfig.encoder_attention_heads",description:`<strong>encoder_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"encoder_attention_heads"},{anchor:"transformers.TimeSeriesTransformerConfig.decoder_attention_heads",description:`<strong>decoder_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
Number of attention heads for each attention layer in the Transformer decoder.`,name:"decoder_attention_heads"},{anchor:"transformers.TimeSeriesTransformerConfig.encoder_ffn_dim",description:`<strong>encoder_ffn_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 32) &#x2014;
Dimension of the &#x201C;intermediate&#x201D; (often named feed-forward) layer in encoder.`,name:"encoder_ffn_dim"},{anchor:"transformers.TimeSeriesTransformerConfig.decoder_ffn_dim",description:`<strong>decoder_ffn_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 32) &#x2014;
Dimension of the &#x201C;intermediate&#x201D; (often named feed-forward) layer in decoder.`,name:"decoder_ffn_dim"},{anchor:"transformers.TimeSeriesTransformerConfig.activation_function",description:`<strong>activation_function</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the encoder and decoder. If string, <code>&quot;gelu&quot;</code> and
<code>&quot;relu&quot;</code> are supported.`,name:"activation_function"},{anchor:"transformers.TimeSeriesTransformerConfig.dropout",description:`<strong>dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probability for all fully connected layers in the encoder, and decoder.`,name:"dropout"},{anchor:"transformers.TimeSeriesTransformerConfig.encoder_layerdrop",description:`<strong>encoder_layerdrop</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probability for the attention and fully connected layers for each encoder layer.`,name:"encoder_layerdrop"},{anchor:"transformers.TimeSeriesTransformerConfig.decoder_layerdrop",description:`<strong>decoder_layerdrop</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probability for the attention and fully connected layers for each decoder layer.`,name:"decoder_layerdrop"},{anchor:"transformers.TimeSeriesTransformerConfig.attention_dropout",description:`<strong>attention_dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probability for the attention probabilities.`,name:"attention_dropout"},{anchor:"transformers.TimeSeriesTransformerConfig.activation_dropout",description:`<strong>activation_dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probability used between the two layers of the feed-forward networks.`,name:"activation_dropout"},{anchor:"transformers.TimeSeriesTransformerConfig.num_parallel_samples",description:`<strong>num_parallel_samples</strong> (<code>int</code>, <em>optional</em>, defaults to 100) &#x2014;
The number of samples to generate in parallel for each time step of inference.`,name:"num_parallel_samples"},{anchor:"transformers.TimeSeriesTransformerConfig.init_std",description:`<strong>init_std</strong> (<code>float</code>, <em>optional</em>, defaults to 0.02) &#x2014;
The standard deviation of the truncated normal weight initialization distribution.`,name:"init_std"},{anchor:"transformers.TimeSeriesTransformerConfig.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to use the past key/values attentions (if applicable to the model) to speed up decoding.</p>
<p>Example &#x2014;`,name:"use_cache"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/time_series_transformer/configuration_time_series_transformer.py#L33"}}),re=new Oa({props:{anchor:"transformers.TimeSeriesTransformerConfig.example",$$slots:{default:[lr]},$$scope:{ctx:C}}}),Ce=new ht({}),je=new Lt({props:{name:"class transformers.TimeSeriesTransformerModel",anchor:"transformers.TimeSeriesTransformerModel",parameters:[{name:"config",val:": TimeSeriesTransformerConfig"}],parametersDescription:[{anchor:"transformers.TimeSeriesTransformerModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.31.0/en/model_doc/time_series_transformer#transformers.TimeSeriesTransformerConfig">TimeSeriesTransformerConfig</a>) &#x2014;
Model configuration class with all the parameters of the model. Initializing with a config file does not
load the weights associated with the model, only the configuration. Check out the
<a href="/docs/transformers/v4.31.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/time_series_transformer/modeling_time_series_transformer.py#L1233"}}),$e=new Lt({props:{name:"forward",anchor:"transformers.TimeSeriesTransformerModel.forward",parameters:[{name:"past_values",val:": Tensor"},{name:"past_time_features",val:": Tensor"},{name:"past_observed_mask",val:": Tensor"},{name:"static_categorical_features",val:": typing.Optional[torch.Tensor] = None"},{name:"static_real_features",val:": typing.Optional[torch.Tensor] = None"},{name:"future_values",val:": typing.Optional[torch.Tensor] = None"},{name:"future_time_features",val:": typing.Optional[torch.Tensor] = None"},{name:"decoder_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"decoder_head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"cross_attn_head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"encoder_outputs",val:": typing.Optional[typing.List[torch.FloatTensor]] = None"},{name:"past_key_values",val:": typing.Optional[typing.List[torch.FloatTensor]] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.TimeSeriesTransformerModel.forward.past_values",description:`<strong>past_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code> or <code>(batch_size, sequence_length, input_size)</code>) &#x2014;
Past values of the time series, that serve as context in order to predict the future. The sequence size of
this tensor must be larger than the <code>context_length</code> of the model, since the model will use the larger size
to construct lag features, i.e. additional values from the past which are added in order to serve as &#x201C;extra
context&#x201D;.</p>
<p>The <code>sequence_length</code> here is equal to <code>config.context_length</code> + <code>max(config.lags_sequence)</code>, which if no
<code>lags_sequence</code> is configured, is equal to <code>config.context_length</code> + 7 (as by default, the largest
look-back index in <code>config.lags_sequence</code> is 7). The property <code>_past_length</code> returns the actual length of
the past.</p>
<p>The <code>past_values</code> is what the Transformer encoder gets as input (with optional additional features, such as
<code>static_categorical_features</code>, <code>static_real_features</code>, <code>past_time_features</code> and lags).</p>
<p>Optionally, missing values need to be replaced with zeros and indicated via the <code>past_observed_mask</code>.</p>
<p>For multivariate time series, the <code>input_size</code> &gt; 1 dimension is required and corresponds to the number of
variates in the time series per time step.`,name:"past_values"},{anchor:"transformers.TimeSeriesTransformerModel.forward.past_time_features",description:`<strong>past_time_features</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, num_features)</code>) &#x2014;
Required time features, which the model internally will add to <code>past_values</code>. These could be things like
&#x201C;month of year&#x201D;, &#x201C;day of the month&#x201D;, etc. encoded as vectors (for instance as Fourier features). These
could also be so-called &#x201C;age&#x201D; features, which basically help the model know &#x201C;at which point in life&#x201D; a
time-series is. Age features have small values for distant past time steps and increase monotonically the
more we approach the current time step. Holiday features are also a good example of time features.</p>
<p>These features serve as the &#x201C;positional encodings&#x201D; of the inputs. So contrary to a model like BERT, where
the position encodings are learned from scratch internally as parameters of the model, the Time Series
Transformer requires to provide additional time features. The Time Series Transformer only learns
additional embeddings for <code>static_categorical_features</code>.</p>
<p>Additional dynamic real covariates can be concatenated to this tensor, with the caveat that these features
must but known at prediction time.</p>
<p>The <code>num_features</code> here is equal to <code>config.</code>num_time_features<code>+</code>config.num_dynamic_real_features\`.`,name:"past_time_features"},{anchor:"transformers.TimeSeriesTransformerModel.forward.past_observed_mask",description:`<strong>past_observed_mask</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, sequence_length)</code> or <code>(batch_size, sequence_length, input_size)</code>, <em>optional</em>) &#x2014;
Boolean mask to indicate which <code>past_values</code> were observed and which were missing. Mask values selected in
<code>[0, 1]</code>:</p>
<ul>
<li>1 for values that are <strong>observed</strong>,</li>
<li>0 for values that are <strong>missing</strong> (i.e. NaNs that were replaced by zeros).</li>
</ul>`,name:"past_observed_mask"},{anchor:"transformers.TimeSeriesTransformerModel.forward.static_categorical_features",description:`<strong>static_categorical_features</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, number of static categorical features)</code>, <em>optional</em>) &#x2014;
Optional static categorical features for which the model will learn an embedding, which it will add to the
values of the time series.</p>
<p>Static categorical features are features which have the same value for all time steps (static over time).</p>
<p>A typical example of a static categorical feature is a time series ID.`,name:"static_categorical_features"},{anchor:"transformers.TimeSeriesTransformerModel.forward.static_real_features",description:`<strong>static_real_features</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, number of static real features)</code>, <em>optional</em>) &#x2014;
Optional static real features which the model will add to the values of the time series.</p>
<p>Static real features are features which have the same value for all time steps (static over time).</p>
<p>A typical example of a static real feature is promotion information.`,name:"static_real_features"},{anchor:"transformers.TimeSeriesTransformerModel.forward.future_values",description:`<strong>future_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, prediction_length)</code> or <code>(batch_size, prediction_length, input_size)</code>, <em>optional</em>) &#x2014;
Future values of the time series, that serve as labels for the model. The <code>future_values</code> is what the
Transformer needs during training to learn to output, given the <code>past_values</code>.</p>
<p>The sequence length here is equal to <code>prediction_length</code>.</p>
<p>See the demo notebook and code snippets for details.</p>
<p>Optionally, during training any missing values need to be replaced with zeros and indicated via the
<code>future_observed_mask</code>.</p>
<p>For multivariate time series, the <code>input_size</code> &gt; 1 dimension is required and corresponds to the number of
variates in the time series per time step.`,name:"future_values"},{anchor:"transformers.TimeSeriesTransformerModel.forward.future_time_features",description:`<strong>future_time_features</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, prediction_length, num_features)</code>) &#x2014;
Required time features for the prediction window, which the model internally will add to <code>future_values</code>.
These could be things like &#x201C;month of year&#x201D;, &#x201C;day of the month&#x201D;, etc. encoded as vectors (for instance as
Fourier features). These could also be so-called &#x201C;age&#x201D; features, which basically help the model know &#x201C;at
which point in life&#x201D; a time-series is. Age features have small values for distant past time steps and
increase monotonically the more we approach the current time step. Holiday features are also a good example
of time features.</p>
<p>These features serve as the &#x201C;positional encodings&#x201D; of the inputs. So contrary to a model like BERT, where
the position encodings are learned from scratch internally as parameters of the model, the Time Series
Transformer requires to provide additional time features. The Time Series Transformer only learns
additional embeddings for <code>static_categorical_features</code>.</p>
<p>Additional dynamic real covariates can be concatenated to this tensor, with the caveat that these features
must but known at prediction time.</p>
<p>The <code>num_features</code> here is equal to <code>config.</code>num_time_features<code>+</code>config.num_dynamic_real_features\`.`,name:"future_time_features"},{anchor:"transformers.TimeSeriesTransformerModel.forward.future_observed_mask",description:`<strong>future_observed_mask</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, sequence_length)</code> or <code>(batch_size, sequence_length, input_size)</code>, <em>optional</em>) &#x2014;
Boolean mask to indicate which <code>future_values</code> were observed and which were missing. Mask values selected
in <code>[0, 1]</code>:</p>
<ul>
<li>1 for values that are <strong>observed</strong>,</li>
<li>0 for values that are <strong>missing</strong> (i.e. NaNs that were replaced by zeros).</li>
</ul>
<p>This mask is used to filter out missing values for the final loss calculation.`,name:"future_observed_mask"},{anchor:"transformers.TimeSeriesTransformerModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on certain token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.TimeSeriesTransformerModel.forward.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on certain token indices. By default, a causal mask will be used, to
make sure the model can only look at previous inputs in order to predict the future.`,name:"decoder_attention_mask"},{anchor:"transformers.TimeSeriesTransformerModel.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.Tensor</code> of shape <code>(encoder_layers, encoder_attention_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the attention modules in the encoder. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.TimeSeriesTransformerModel.forward.decoder_head_mask",description:`<strong>decoder_head_mask</strong> (<code>torch.Tensor</code> of shape <code>(decoder_layers, decoder_attention_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the attention modules in the decoder. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"decoder_head_mask"},{anchor:"transformers.TimeSeriesTransformerModel.forward.cross_attn_head_mask",description:`<strong>cross_attn_head_mask</strong> (<code>torch.Tensor</code> of shape <code>(decoder_layers, decoder_attention_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the cross-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"cross_attn_head_mask"},{anchor:"transformers.TimeSeriesTransformerModel.forward.encoder_outputs",description:`<strong>encoder_outputs</strong> (<code>tuple(tuple(torch.FloatTensor)</code>, <em>optional</em>) &#x2014;
Tuple consists of <code>last_hidden_state</code>, <code>hidden_states</code> (<em>optional</em>) and <code>attentions</code> (<em>optional</em>)
<code>last_hidden_state</code> of shape <code>(batch_size, sequence_length, hidden_size)</code> (<em>optional</em>) is a sequence of
hidden-states at the output of the last layer of the encoder. Used in the cross-attention of the decoder.`,name:"encoder_outputs"},{anchor:"transformers.TimeSeriesTransformerModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) &#x2014;
Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and 2 additional tensors of shape
<code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>decoder_input_ids</code> (those that
don&#x2019;t have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all
<code>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.TimeSeriesTransformerModel.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.TimeSeriesTransformerModel.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.TimeSeriesTransformerModel.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.TimeSeriesTransformerModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.TimeSeriesTransformerModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.31.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/time_series_transformer/modeling_time_series_transformer.py#L1371",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.0/en/main_classes/output#transformers.modeling_outputs.Seq2SeqTSModelOutput"
>transformers.modeling_outputs.Seq2SeqTSModelOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.31.0/en/model_doc/time_series_transformer#transformers.TimeSeriesTransformerConfig"
>TimeSeriesTransformerConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) \u2014 Sequence of hidden-states at the output of the last layer of the decoder of the model.</p>
<p>If <code>past_key_values</code> is used only the last hidden-state of the sequences of shape <code>(batch_size, 1, hidden_size)</code> is output.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and 2 additional tensors of shape
<code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>decoder_hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the decoder at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>decoder_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
<li>
<p><strong>cross_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder\u2019s cross-attention layer, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
<li>
<p><strong>encoder_last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden-states at the output of the last layer of the encoder of the model.</p>
</li>
<li>
<p><strong>encoder_hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the encoder at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>encoder_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
<li>
<p><strong>loc</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size,)</code> or <code>(batch_size, input_size)</code>, <em>optional</em>) \u2014 Shift values of each time series\u2019 context window which is used to give the model inputs of the same
magnitude and then used to shift back to the original magnitude.</p>
</li>
<li>
<p><strong>scale</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size,)</code> or <code>(batch_size, input_size)</code>, <em>optional</em>) \u2014 Scaling values of each time series\u2019 context window which is used to give the model inputs of the same
magnitude and then used to rescale back to the original magnitude.</p>
</li>
<li>
<p><strong>static_features</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, feature size)</code>, <em>optional</em>) \u2014 Static features of each time series\u2019 in a batch which are copied to the covariates at inference time.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.31.0/en/main_classes/output#transformers.modeling_outputs.Seq2SeqTSModelOutput"
>transformers.modeling_outputs.Seq2SeqTSModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),de=new Da({props:{$$slots:{default:[cr]},$$scope:{ctx:C}}}),le=new Oa({props:{anchor:"transformers.TimeSeriesTransformerModel.forward.example",$$slots:{default:[hr]},$$scope:{ctx:C}}}),Ee=new ht({}),qe=new Lt({props:{name:"class transformers.TimeSeriesTransformerForPrediction",anchor:"transformers.TimeSeriesTransformerForPrediction",parameters:[{name:"config",val:": TimeSeriesTransformerConfig"}],parametersDescription:[{anchor:"transformers.TimeSeriesTransformerForPrediction.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.31.0/en/model_doc/time_series_transformer#transformers.TimeSeriesTransformerConfig">TimeSeriesTransformerConfig</a>) &#x2014;
Model configuration class with all the parameters of the model. Initializing with a config file does not
load the weights associated with the model, only the configuration. Check out the
<a href="/docs/transformers/v4.31.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/time_series_transformer/modeling_time_series_transformer.py#L1494"}}),Xe=new Lt({props:{name:"forward",anchor:"transformers.TimeSeriesTransformerForPrediction.forward",parameters:[{name:"past_values",val:": Tensor"},{name:"past_time_features",val:": Tensor"},{name:"past_observed_mask",val:": Tensor"},{name:"static_categorical_features",val:": typing.Optional[torch.Tensor] = None"},{name:"static_real_features",val:": typing.Optional[torch.Tensor] = None"},{name:"future_values",val:": typing.Optional[torch.Tensor] = None"},{name:"future_time_features",val:": typing.Optional[torch.Tensor] = None"},{name:"future_observed_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"decoder_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"decoder_head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"cross_attn_head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"encoder_outputs",val:": typing.Optional[typing.List[torch.FloatTensor]] = None"},{name:"past_key_values",val:": typing.Optional[typing.List[torch.FloatTensor]] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.TimeSeriesTransformerForPrediction.forward.past_values",description:`<strong>past_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code> or <code>(batch_size, sequence_length, input_size)</code>) &#x2014;
Past values of the time series, that serve as context in order to predict the future. The sequence size of
this tensor must be larger than the <code>context_length</code> of the model, since the model will use the larger size
to construct lag features, i.e. additional values from the past which are added in order to serve as &#x201C;extra
context&#x201D;.</p>
<p>The <code>sequence_length</code> here is equal to <code>config.context_length</code> + <code>max(config.lags_sequence)</code>, which if no
<code>lags_sequence</code> is configured, is equal to <code>config.context_length</code> + 7 (as by default, the largest
look-back index in <code>config.lags_sequence</code> is 7). The property <code>_past_length</code> returns the actual length of
the past.</p>
<p>The <code>past_values</code> is what the Transformer encoder gets as input (with optional additional features, such as
<code>static_categorical_features</code>, <code>static_real_features</code>, <code>past_time_features</code> and lags).</p>
<p>Optionally, missing values need to be replaced with zeros and indicated via the <code>past_observed_mask</code>.</p>
<p>For multivariate time series, the <code>input_size</code> &gt; 1 dimension is required and corresponds to the number of
variates in the time series per time step.`,name:"past_values"},{anchor:"transformers.TimeSeriesTransformerForPrediction.forward.past_time_features",description:`<strong>past_time_features</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, num_features)</code>) &#x2014;
Required time features, which the model internally will add to <code>past_values</code>. These could be things like
&#x201C;month of year&#x201D;, &#x201C;day of the month&#x201D;, etc. encoded as vectors (for instance as Fourier features). These
could also be so-called &#x201C;age&#x201D; features, which basically help the model know &#x201C;at which point in life&#x201D; a
time-series is. Age features have small values for distant past time steps and increase monotonically the
more we approach the current time step. Holiday features are also a good example of time features.</p>
<p>These features serve as the &#x201C;positional encodings&#x201D; of the inputs. So contrary to a model like BERT, where
the position encodings are learned from scratch internally as parameters of the model, the Time Series
Transformer requires to provide additional time features. The Time Series Transformer only learns
additional embeddings for <code>static_categorical_features</code>.</p>
<p>Additional dynamic real covariates can be concatenated to this tensor, with the caveat that these features
must but known at prediction time.</p>
<p>The <code>num_features</code> here is equal to <code>config.</code>num_time_features<code>+</code>config.num_dynamic_real_features\`.`,name:"past_time_features"},{anchor:"transformers.TimeSeriesTransformerForPrediction.forward.past_observed_mask",description:`<strong>past_observed_mask</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, sequence_length)</code> or <code>(batch_size, sequence_length, input_size)</code>, <em>optional</em>) &#x2014;
Boolean mask to indicate which <code>past_values</code> were observed and which were missing. Mask values selected in
<code>[0, 1]</code>:</p>
<ul>
<li>1 for values that are <strong>observed</strong>,</li>
<li>0 for values that are <strong>missing</strong> (i.e. NaNs that were replaced by zeros).</li>
</ul>`,name:"past_observed_mask"},{anchor:"transformers.TimeSeriesTransformerForPrediction.forward.static_categorical_features",description:`<strong>static_categorical_features</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, number of static categorical features)</code>, <em>optional</em>) &#x2014;
Optional static categorical features for which the model will learn an embedding, which it will add to the
values of the time series.</p>
<p>Static categorical features are features which have the same value for all time steps (static over time).</p>
<p>A typical example of a static categorical feature is a time series ID.`,name:"static_categorical_features"},{anchor:"transformers.TimeSeriesTransformerForPrediction.forward.static_real_features",description:`<strong>static_real_features</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, number of static real features)</code>, <em>optional</em>) &#x2014;
Optional static real features which the model will add to the values of the time series.</p>
<p>Static real features are features which have the same value for all time steps (static over time).</p>
<p>A typical example of a static real feature is promotion information.`,name:"static_real_features"},{anchor:"transformers.TimeSeriesTransformerForPrediction.forward.future_values",description:`<strong>future_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, prediction_length)</code> or <code>(batch_size, prediction_length, input_size)</code>, <em>optional</em>) &#x2014;
Future values of the time series, that serve as labels for the model. The <code>future_values</code> is what the
Transformer needs during training to learn to output, given the <code>past_values</code>.</p>
<p>The sequence length here is equal to <code>prediction_length</code>.</p>
<p>See the demo notebook and code snippets for details.</p>
<p>Optionally, during training any missing values need to be replaced with zeros and indicated via the
<code>future_observed_mask</code>.</p>
<p>For multivariate time series, the <code>input_size</code> &gt; 1 dimension is required and corresponds to the number of
variates in the time series per time step.`,name:"future_values"},{anchor:"transformers.TimeSeriesTransformerForPrediction.forward.future_time_features",description:`<strong>future_time_features</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, prediction_length, num_features)</code>) &#x2014;
Required time features for the prediction window, which the model internally will add to <code>future_values</code>.
These could be things like &#x201C;month of year&#x201D;, &#x201C;day of the month&#x201D;, etc. encoded as vectors (for instance as
Fourier features). These could also be so-called &#x201C;age&#x201D; features, which basically help the model know &#x201C;at
which point in life&#x201D; a time-series is. Age features have small values for distant past time steps and
increase monotonically the more we approach the current time step. Holiday features are also a good example
of time features.</p>
<p>These features serve as the &#x201C;positional encodings&#x201D; of the inputs. So contrary to a model like BERT, where
the position encodings are learned from scratch internally as parameters of the model, the Time Series
Transformer requires to provide additional time features. The Time Series Transformer only learns
additional embeddings for <code>static_categorical_features</code>.</p>
<p>Additional dynamic real covariates can be concatenated to this tensor, with the caveat that these features
must but known at prediction time.</p>
<p>The <code>num_features</code> here is equal to <code>config.</code>num_time_features<code>+</code>config.num_dynamic_real_features\`.`,name:"future_time_features"},{anchor:"transformers.TimeSeriesTransformerForPrediction.forward.future_observed_mask",description:`<strong>future_observed_mask</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, sequence_length)</code> or <code>(batch_size, sequence_length, input_size)</code>, <em>optional</em>) &#x2014;
Boolean mask to indicate which <code>future_values</code> were observed and which were missing. Mask values selected
in <code>[0, 1]</code>:</p>
<ul>
<li>1 for values that are <strong>observed</strong>,</li>
<li>0 for values that are <strong>missing</strong> (i.e. NaNs that were replaced by zeros).</li>
</ul>
<p>This mask is used to filter out missing values for the final loss calculation.`,name:"future_observed_mask"},{anchor:"transformers.TimeSeriesTransformerForPrediction.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on certain token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.TimeSeriesTransformerForPrediction.forward.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on certain token indices. By default, a causal mask will be used, to
make sure the model can only look at previous inputs in order to predict the future.`,name:"decoder_attention_mask"},{anchor:"transformers.TimeSeriesTransformerForPrediction.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.Tensor</code> of shape <code>(encoder_layers, encoder_attention_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the attention modules in the encoder. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.TimeSeriesTransformerForPrediction.forward.decoder_head_mask",description:`<strong>decoder_head_mask</strong> (<code>torch.Tensor</code> of shape <code>(decoder_layers, decoder_attention_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the attention modules in the decoder. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"decoder_head_mask"},{anchor:"transformers.TimeSeriesTransformerForPrediction.forward.cross_attn_head_mask",description:`<strong>cross_attn_head_mask</strong> (<code>torch.Tensor</code> of shape <code>(decoder_layers, decoder_attention_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the cross-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"cross_attn_head_mask"},{anchor:"transformers.TimeSeriesTransformerForPrediction.forward.encoder_outputs",description:`<strong>encoder_outputs</strong> (<code>tuple(tuple(torch.FloatTensor)</code>, <em>optional</em>) &#x2014;
Tuple consists of <code>last_hidden_state</code>, <code>hidden_states</code> (<em>optional</em>) and <code>attentions</code> (<em>optional</em>)
<code>last_hidden_state</code> of shape <code>(batch_size, sequence_length, hidden_size)</code> (<em>optional</em>) is a sequence of
hidden-states at the output of the last layer of the encoder. Used in the cross-attention of the decoder.`,name:"encoder_outputs"},{anchor:"transformers.TimeSeriesTransformerForPrediction.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) &#x2014;
Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and 2 additional tensors of shape
<code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>decoder_input_ids</code> (those that
don&#x2019;t have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all
<code>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.TimeSeriesTransformerForPrediction.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.TimeSeriesTransformerForPrediction.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.TimeSeriesTransformerForPrediction.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.TimeSeriesTransformerForPrediction.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.TimeSeriesTransformerForPrediction.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.31.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/time_series_transformer/modeling_time_series_transformer.py#L1534",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.0/en/main_classes/output#transformers.modeling_outputs.Seq2SeqTSModelOutput"
>transformers.modeling_outputs.Seq2SeqTSModelOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.31.0/en/model_doc/time_series_transformer#transformers.TimeSeriesTransformerConfig"
>TimeSeriesTransformerConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) \u2014 Sequence of hidden-states at the output of the last layer of the decoder of the model.</p>
<p>If <code>past_key_values</code> is used only the last hidden-state of the sequences of shape <code>(batch_size, 1, hidden_size)</code> is output.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and 2 additional tensors of shape
<code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>decoder_hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the decoder at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>decoder_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
<li>
<p><strong>cross_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder\u2019s cross-attention layer, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
<li>
<p><strong>encoder_last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden-states at the output of the last layer of the encoder of the model.</p>
</li>
<li>
<p><strong>encoder_hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the encoder at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>encoder_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
<li>
<p><strong>loc</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size,)</code> or <code>(batch_size, input_size)</code>, <em>optional</em>) \u2014 Shift values of each time series\u2019 context window which is used to give the model inputs of the same
magnitude and then used to shift back to the original magnitude.</p>
</li>
<li>
<p><strong>scale</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size,)</code> or <code>(batch_size, input_size)</code>, <em>optional</em>) \u2014 Scaling values of each time series\u2019 context window which is used to give the model inputs of the same
magnitude and then used to rescale back to the original magnitude.</p>
</li>
<li>
<p><strong>static_features</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, feature size)</code>, <em>optional</em>) \u2014 Static features of each time series\u2019 in a batch which are copied to the covariates at inference time.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.31.0/en/main_classes/output#transformers.modeling_outputs.Seq2SeqTSModelOutput"
>transformers.modeling_outputs.Seq2SeqTSModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),he=new Da({props:{$$slots:{default:[mr]},$$scope:{ctx:C}}}),me=new Oa({props:{anchor:"transformers.TimeSeriesTransformerForPrediction.forward.example",$$slots:{default:[ur]},$$scope:{ctx:C}}}),{c(){d=n("meta"),T=u(),h=n("h1"),p=n("a"),v=n("span"),y(l.$$.fragment),_=u(),j=n("span"),Uo=s("Time Series Transformer"),Kt=u(),y(K.$$.fragment),eo=u(),G=n("h2"),ee=n("a"),mt=n("span"),y(ye.$$.fragment),xo=u(),ut=n("span"),Co=s("Overview"),to=u(),Be=n("p"),jo=s("The Time Series Transformer model is a vanilla encoder-decoder Transformer for time series forecasting."),oo=u(),Ye=n("p"),Fo=s("Tips:"),so=u(),F=n("ul"),V=n("li"),Jo=s("Similar to other models in the library, "),Pe=n("a"),zo=s("TimeSeriesTransformerModel"),$o=s(" is the raw Transformer without any head on top, and "),Ae=n("a"),Eo=s("TimeSeriesTransformerForPrediction"),qo=s(`
adds a distribution head on top of the former, which can be used for time-series forecasting. Note that this is a so-called probabilistic forecasting model, not a
point forecasting model. This means that the model learns a distribution, from which one can sample. The model doesn\u2019t directly output values.`),Zo=u(),U=n("li"),De=n("a"),No=s("TimeSeriesTransformerForPrediction"),Ro=s(" consists of 2 blocks: an encoder, which takes a "),ft=n("code"),Xo=s("context_length"),Wo=s(" of time series values as input (called "),pt=n("code"),Io=s("past_values"),Go=s(`),
and a decoder, which predicts a `),_t=n("code"),Vo=s("prediction_length"),Bo=s(" of time series values into the future (called "),gt=n("code"),Yo=s("future_values"),Po=s(`). During training, one needs to provide
pairs of (`),Tt=n("code"),Ao=s("past_values"),Do=s(" and "),vt=n("code"),Oo=s("future_values"),Ho=s(") to the model."),Qo=u(),X=n("li"),Lo=s("In addition to the raw ("),yt=n("code"),Ko=s("past_values"),es=s(" and "),bt=n("code"),ts=s("future_values"),os=s("), one typically provides additional features to the model. These can be the following:"),N=n("ul"),te=n("li"),wt=n("code"),ss=s("past_time_features"),as=s(": temporal features which the model will add to "),Mt=n("code"),ns=s("past_values"),rs=s(`. These serve as \u201Cpositional encodings\u201D for the Transformer encoder.
Examples are \u201Cday of the month\u201D, \u201Cmonth of the year\u201D, etc. as scalar values (and then stacked together as a vector).
e.g. if a given time-series value was obtained on the 11th of August, then one could have [11, 8] as time feature vector (11 being \u201Cday of the month\u201D, 8 being \u201Cmonth of the year\u201D).`),is=u(),oe=n("li"),kt=n("code"),ds=s("future_time_features"),ls=s(": temporal features which the model will add to "),St=n("code"),cs=s("future_values"),hs=s(`. These serve as \u201Cpositional encodings\u201D for the Transformer decoder.
Examples are \u201Cday of the month\u201D, \u201Cmonth of the year\u201D, etc. as scalar values (and then stacked together as a vector).
e.g. if a given time-series value was obtained on the 11th of August, then one could have [11, 8] as time feature vector (11 being \u201Cday of the month\u201D, 8 being \u201Cmonth of the year\u201D).`),ms=u(),W=n("li"),Ut=n("code"),us=s("static_categorical_features"),fs=s(": categorical features which are static over time (i.e., have the same value for all "),xt=n("code"),ps=s("past_values"),_s=s(" and "),Ct=n("code"),gs=s("future_values"),Ts=s(`).
An example here is the store ID or region ID that identifies a given time-series.
Note that these features need to be known for ALL data points (also those in the future).`),vs=u(),E=n("li"),jt=n("code"),ys=s("static_real_features"),bs=s(": real-valued features which are static over time (i.e., have the same value for all "),Ft=n("code"),ws=s("past_values"),Ms=s(" and "),Jt=n("code"),ks=s("future_values"),Ss=s(`).
An example here is the image representation of the product for which you have the time-series values (like the `),Oe=n("a"),Us=s("ResNet"),xs=s(` embedding of a \u201Cshoe\u201D picture,
if your time-series is about the sales of shoes).
Note that these features need to be known for ALL data points (also those in the future).`),Cs=u(),R=n("li"),js=s(`The model is trained using \u201Cteacher-forcing\u201D, similar to how a Transformer is trained for machine translation. This means that, during training, one shifts the
`),zt=n("code"),Fs=s("future_values"),Js=s(" one position to the right as input to the decoder, prepended by the last value of "),$t=n("code"),zs=s("past_values"),$s=s(`. At each time step, the model needs to predict the
next target. So the set-up of training is similar to a GPT model for language, except that there\u2019s no notion of `),Et=n("code"),Es=s("decoder_start_token_id"),qs=s(` (we just use the last value
of the context as initial input for the decoder).`),Zs=u(),be=n("li"),Ns=s("At inference time, we give the final value of the "),qt=n("code"),Rs=s("past_values"),Xs=s(` as input to the decoder. Next, we can sample from the model to make a prediction at the next time step,
which is then fed to the decoder in order to make the next prediction (also called autoregressive generation).`),ao=u(),se=n("p"),Ws=s("This model was contributed by "),we=n("a"),Is=s("kashif"),Gs=s("."),no=u(),B=n("h2"),ae=n("a"),Zt=n("span"),y(Me.$$.fragment),Vs=u(),Nt=n("span"),Bs=s("Resources"),ro=u(),He=n("p"),Ys=s("A list of official Hugging Face and community (indicated by \u{1F30E}) resources to help you get started. If you\u2019re interested in submitting a resource to be included here, please feel free to open a Pull Request and we\u2019ll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource."),io=u(),Qe=n("ul"),Le=n("li"),Ps=s("Check out the Time Series Transformer blog-post in HuggingFace blog: "),ke=n("a"),As=s("Probabilistic Time Series Forecasting with \u{1F917} Transformers"),lo=u(),Y=n("h2"),ne=n("a"),Rt=n("span"),y(Se.$$.fragment),Ds=u(),Xt=n("span"),Os=s("TimeSeriesTransformerConfig"),co=u(),J=n("div"),y(Ue.$$.fragment),Hs=u(),P=n("p"),Qs=s("This is the configuration class to store the configuration of a "),Ke=n("a"),Ls=s("TimeSeriesTransformerModel"),Ks=s(`. It is used to
instantiate a Time Series Transformer model according to the specified arguments, defining the model architecture.
Instantiating a configuration with the defaults will yield a similar configuration to that of the Time Series
Transformer
`),xe=n("a"),ea=s("huggingface/time-series-transformer-tourism-monthly"),ta=s(`
architecture.`),oa=u(),A=n("p"),sa=s("Configuration objects inherit from "),et=n("a"),aa=s("PretrainedConfig"),na=s(` can be used to control the model outputs. Read the
documentation from `),tt=n("a"),ra=s("PretrainedConfig"),ia=s(" for more information."),da=u(),y(re.$$.fragment),ho=u(),D=n("h2"),ie=n("a"),Wt=n("span"),y(Ce.$$.fragment),la=u(),It=n("span"),ca=s("TimeSeriesTransformerModel"),mo=u(),z=n("div"),y(je.$$.fragment),ha=u(),Fe=n("p"),ma=s(`The bare Time Series Transformer Model outputting raw hidden-states without any specific head on top.
This model inherits from `),ot=n("a"),ua=s("PreTrainedModel"),fa=s(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),pa=u(),Je=n("p"),_a=s("This model is also a PyTorch "),ze=n("a"),ga=s("torch.nn.Module"),Ta=s(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),va=u(),q=n("div"),y($e.$$.fragment),ya=u(),O=n("p"),ba=s("The "),st=n("a"),wa=s("TimeSeriesTransformerModel"),Ma=s(" forward method, overrides the "),Gt=n("code"),ka=s("__call__"),Sa=s(" special method."),Ua=u(),y(de.$$.fragment),xa=u(),y(le.$$.fragment),uo=u(),H=n("h2"),ce=n("a"),Vt=n("span"),y(Ee.$$.fragment),Ca=u(),Bt=n("span"),ja=s("TimeSeriesTransformerForPrediction"),fo=u(),$=n("div"),y(qe.$$.fragment),Fa=u(),Ze=n("p"),Ja=s(`The Time Series Transformer Model with a distribution head on top for time-series forecasting.
This model inherits from `),at=n("a"),za=s("PreTrainedModel"),$a=s(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Ea=u(),Ne=n("p"),qa=s("This model is also a PyTorch "),Re=n("a"),Za=s("torch.nn.Module"),Na=s(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ra=u(),Z=n("div"),y(Xe.$$.fragment),Xa=u(),Q=n("p"),Wa=s("The "),nt=n("a"),Ia=s("TimeSeriesTransformerForPrediction"),Ga=s(" forward method, overrides the "),Yt=n("code"),Va=s("__call__"),Ba=s(" special method."),Ya=u(),y(he.$$.fragment),Pa=u(),y(me.$$.fragment),this.h()},l(o){const m=rr('[data-svelte="svelte-1phssyn"]',document.head);d=r(m,"META",{name:!0,content:!0}),m.forEach(t),T=f(o),h=r(o,"H1",{class:!0});var We=i(h);p=r(We,"A",{id:!0,class:!0,href:!0});var Pt=i(p);v=r(Pt,"SPAN",{});var At=i(v);b(l.$$.fragment,At),At.forEach(t),Pt.forEach(t),_=f(We),j=r(We,"SPAN",{});var Dt=i(j);Uo=a(Dt,"Time Series Transformer"),Dt.forEach(t),We.forEach(t),Kt=f(o),b(K.$$.fragment,o),eo=f(o),G=r(o,"H2",{class:!0});var Ie=i(G);ee=r(Ie,"A",{id:!0,class:!0,href:!0});var Ot=i(ee);mt=r(Ot,"SPAN",{});var La=i(mt);b(ye.$$.fragment,La),La.forEach(t),Ot.forEach(t),xo=f(Ie),ut=r(Ie,"SPAN",{});var Ka=i(ut);Co=a(Ka,"Overview"),Ka.forEach(t),Ie.forEach(t),to=f(o),Be=r(o,"P",{});var en=i(Be);jo=a(en,"The Time Series Transformer model is a vanilla encoder-decoder Transformer for time series forecasting."),en.forEach(t),oo=f(o),Ye=r(o,"P",{});var tn=i(Ye);Fo=a(tn,"Tips:"),tn.forEach(t),so=f(o),F=r(o,"UL",{});var I=i(F);V=r(I,"LI",{});var rt=i(V);Jo=a(rt,"Similar to other models in the library, "),Pe=r(rt,"A",{href:!0});var on=i(Pe);zo=a(on,"TimeSeriesTransformerModel"),on.forEach(t),$o=a(rt," is the raw Transformer without any head on top, and "),Ae=r(rt,"A",{href:!0});var sn=i(Ae);Eo=a(sn,"TimeSeriesTransformerForPrediction"),sn.forEach(t),qo=a(rt,`
adds a distribution head on top of the former, which can be used for time-series forecasting. Note that this is a so-called probabilistic forecasting model, not a
point forecasting model. This means that the model learns a distribution, from which one can sample. The model doesn\u2019t directly output values.`),rt.forEach(t),Zo=f(I),U=r(I,"LI",{});var x=i(U);De=r(x,"A",{href:!0});var an=i(De);No=a(an,"TimeSeriesTransformerForPrediction"),an.forEach(t),Ro=a(x," consists of 2 blocks: an encoder, which takes a "),ft=r(x,"CODE",{});var nn=i(ft);Xo=a(nn,"context_length"),nn.forEach(t),Wo=a(x," of time series values as input (called "),pt=r(x,"CODE",{});var rn=i(pt);Io=a(rn,"past_values"),rn.forEach(t),Go=a(x,`),
and a decoder, which predicts a `),_t=r(x,"CODE",{});var dn=i(_t);Vo=a(dn,"prediction_length"),dn.forEach(t),Bo=a(x," of time series values into the future (called "),gt=r(x,"CODE",{});var ln=i(gt);Yo=a(ln,"future_values"),ln.forEach(t),Po=a(x,`). During training, one needs to provide
pairs of (`),Tt=r(x,"CODE",{});var cn=i(Tt);Ao=a(cn,"past_values"),cn.forEach(t),Do=a(x," and "),vt=r(x,"CODE",{});var hn=i(vt);Oo=a(hn,"future_values"),hn.forEach(t),Ho=a(x,") to the model."),x.forEach(t),Qo=f(I),X=r(I,"LI",{});var Ge=i(X);Lo=a(Ge,"In addition to the raw ("),yt=r(Ge,"CODE",{});var mn=i(yt);Ko=a(mn,"past_values"),mn.forEach(t),es=a(Ge," and "),bt=r(Ge,"CODE",{});var un=i(bt);ts=a(un,"future_values"),un.forEach(t),os=a(Ge,"), one typically provides additional features to the model. These can be the following:"),N=r(Ge,"UL",{});var ue=i(N);te=r(ue,"LI",{});var Ht=i(te);wt=r(Ht,"CODE",{});var fn=i(wt);ss=a(fn,"past_time_features"),fn.forEach(t),as=a(Ht,": temporal features which the model will add to "),Mt=r(Ht,"CODE",{});var pn=i(Mt);ns=a(pn,"past_values"),pn.forEach(t),rs=a(Ht,`. These serve as \u201Cpositional encodings\u201D for the Transformer encoder.
Examples are \u201Cday of the month\u201D, \u201Cmonth of the year\u201D, etc. as scalar values (and then stacked together as a vector).
e.g. if a given time-series value was obtained on the 11th of August, then one could have [11, 8] as time feature vector (11 being \u201Cday of the month\u201D, 8 being \u201Cmonth of the year\u201D).`),Ht.forEach(t),is=f(ue),oe=r(ue,"LI",{});var Qt=i(oe);kt=r(Qt,"CODE",{});var _n=i(kt);ds=a(_n,"future_time_features"),_n.forEach(t),ls=a(Qt,": temporal features which the model will add to "),St=r(Qt,"CODE",{});var gn=i(St);cs=a(gn,"future_values"),gn.forEach(t),hs=a(Qt,`. These serve as \u201Cpositional encodings\u201D for the Transformer decoder.
Examples are \u201Cday of the month\u201D, \u201Cmonth of the year\u201D, etc. as scalar values (and then stacked together as a vector).
e.g. if a given time-series value was obtained on the 11th of August, then one could have [11, 8] as time feature vector (11 being \u201Cday of the month\u201D, 8 being \u201Cmonth of the year\u201D).`),Qt.forEach(t),ms=f(ue),W=r(ue,"LI",{});var Ve=i(W);Ut=r(Ve,"CODE",{});var Tn=i(Ut);us=a(Tn,"static_categorical_features"),Tn.forEach(t),fs=a(Ve,": categorical features which are static over time (i.e., have the same value for all "),xt=r(Ve,"CODE",{});var vn=i(xt);ps=a(vn,"past_values"),vn.forEach(t),_s=a(Ve," and "),Ct=r(Ve,"CODE",{});var yn=i(Ct);gs=a(yn,"future_values"),yn.forEach(t),Ts=a(Ve,`).
An example here is the store ID or region ID that identifies a given time-series.
Note that these features need to be known for ALL data points (also those in the future).`),Ve.forEach(t),vs=f(ue),E=r(ue,"LI",{});var L=i(E);jt=r(L,"CODE",{});var bn=i(jt);ys=a(bn,"static_real_features"),bn.forEach(t),bs=a(L,": real-valued features which are static over time (i.e., have the same value for all "),Ft=r(L,"CODE",{});var wn=i(Ft);ws=a(wn,"past_values"),wn.forEach(t),Ms=a(L," and "),Jt=r(L,"CODE",{});var Mn=i(Jt);ks=a(Mn,"future_values"),Mn.forEach(t),Ss=a(L,`).
An example here is the image representation of the product for which you have the time-series values (like the `),Oe=r(L,"A",{href:!0});var kn=i(Oe);Us=a(kn,"ResNet"),kn.forEach(t),xs=a(L,` embedding of a \u201Cshoe\u201D picture,
if your time-series is about the sales of shoes).
Note that these features need to be known for ALL data points (also those in the future).`),L.forEach(t),ue.forEach(t),Ge.forEach(t),Cs=f(I),R=r(I,"LI",{});var fe=i(R);js=a(fe,`The model is trained using \u201Cteacher-forcing\u201D, similar to how a Transformer is trained for machine translation. This means that, during training, one shifts the
`),zt=r(fe,"CODE",{});var Sn=i(zt);Fs=a(Sn,"future_values"),Sn.forEach(t),Js=a(fe," one position to the right as input to the decoder, prepended by the last value of "),$t=r(fe,"CODE",{});var Un=i($t);zs=a(Un,"past_values"),Un.forEach(t),$s=a(fe,`. At each time step, the model needs to predict the
next target. So the set-up of training is similar to a GPT model for language, except that there\u2019s no notion of `),Et=r(fe,"CODE",{});var xn=i(Et);Es=a(xn,"decoder_start_token_id"),xn.forEach(t),qs=a(fe,` (we just use the last value
of the context as initial input for the decoder).`),fe.forEach(t),Zs=f(I),be=r(I,"LI",{});var _o=i(be);Ns=a(_o,"At inference time, we give the final value of the "),qt=r(_o,"CODE",{});var Cn=i(qt);Rs=a(Cn,"past_values"),Cn.forEach(t),Xs=a(_o,` as input to the decoder. Next, we can sample from the model to make a prediction at the next time step,
which is then fed to the decoder in order to make the next prediction (also called autoregressive generation).`),_o.forEach(t),I.forEach(t),ao=f(o),se=r(o,"P",{});var go=i(se);Ws=a(go,"This model was contributed by "),we=r(go,"A",{href:!0,rel:!0});var jn=i(we);Is=a(jn,"kashif"),jn.forEach(t),Gs=a(go,"."),go.forEach(t),no=f(o),B=r(o,"H2",{class:!0});var To=i(B);ae=r(To,"A",{id:!0,class:!0,href:!0});var Fn=i(ae);Zt=r(Fn,"SPAN",{});var Jn=i(Zt);b(Me.$$.fragment,Jn),Jn.forEach(t),Fn.forEach(t),Vs=f(To),Nt=r(To,"SPAN",{});var zn=i(Nt);Bs=a(zn,"Resources"),zn.forEach(t),To.forEach(t),ro=f(o),He=r(o,"P",{});var $n=i(He);Ys=a($n,"A list of official Hugging Face and community (indicated by \u{1F30E}) resources to help you get started. If you\u2019re interested in submitting a resource to be included here, please feel free to open a Pull Request and we\u2019ll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource."),$n.forEach(t),io=f(o),Qe=r(o,"UL",{});var En=i(Qe);Le=r(En,"LI",{});var Aa=i(Le);Ps=a(Aa,"Check out the Time Series Transformer blog-post in HuggingFace blog: "),ke=r(Aa,"A",{href:!0,rel:!0});var qn=i(ke);As=a(qn,"Probabilistic Time Series Forecasting with \u{1F917} Transformers"),qn.forEach(t),Aa.forEach(t),En.forEach(t),lo=f(o),Y=r(o,"H2",{class:!0});var vo=i(Y);ne=r(vo,"A",{id:!0,class:!0,href:!0});var Zn=i(ne);Rt=r(Zn,"SPAN",{});var Nn=i(Rt);b(Se.$$.fragment,Nn),Nn.forEach(t),Zn.forEach(t),Ds=f(vo),Xt=r(vo,"SPAN",{});var Rn=i(Xt);Os=a(Rn,"TimeSeriesTransformerConfig"),Rn.forEach(t),vo.forEach(t),co=f(o),J=r(o,"DIV",{class:!0});var pe=i(J);b(Ue.$$.fragment,pe),Hs=f(pe),P=r(pe,"P",{});var it=i(P);Qs=a(it,"This is the configuration class to store the configuration of a "),Ke=r(it,"A",{href:!0});var Xn=i(Ke);Ls=a(Xn,"TimeSeriesTransformerModel"),Xn.forEach(t),Ks=a(it,`. It is used to
instantiate a Time Series Transformer model according to the specified arguments, defining the model architecture.
Instantiating a configuration with the defaults will yield a similar configuration to that of the Time Series
Transformer
`),xe=r(it,"A",{href:!0,rel:!0});var Wn=i(xe);ea=a(Wn,"huggingface/time-series-transformer-tourism-monthly"),Wn.forEach(t),ta=a(it,`
architecture.`),it.forEach(t),oa=f(pe),A=r(pe,"P",{});var dt=i(A);sa=a(dt,"Configuration objects inherit from "),et=r(dt,"A",{href:!0});var In=i(et);aa=a(In,"PretrainedConfig"),In.forEach(t),na=a(dt,` can be used to control the model outputs. Read the
documentation from `),tt=r(dt,"A",{href:!0});var Gn=i(tt);ra=a(Gn,"PretrainedConfig"),Gn.forEach(t),ia=a(dt," for more information."),dt.forEach(t),da=f(pe),b(re.$$.fragment,pe),pe.forEach(t),ho=f(o),D=r(o,"H2",{class:!0});var yo=i(D);ie=r(yo,"A",{id:!0,class:!0,href:!0});var Vn=i(ie);Wt=r(Vn,"SPAN",{});var Bn=i(Wt);b(Ce.$$.fragment,Bn),Bn.forEach(t),Vn.forEach(t),la=f(yo),It=r(yo,"SPAN",{});var Yn=i(It);ca=a(Yn,"TimeSeriesTransformerModel"),Yn.forEach(t),yo.forEach(t),mo=f(o),z=r(o,"DIV",{class:!0});var _e=i(z);b(je.$$.fragment,_e),ha=f(_e),Fe=r(_e,"P",{});var bo=i(Fe);ma=a(bo,`The bare Time Series Transformer Model outputting raw hidden-states without any specific head on top.
This model inherits from `),ot=r(bo,"A",{href:!0});var Pn=i(ot);ua=a(Pn,"PreTrainedModel"),Pn.forEach(t),fa=a(bo,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),bo.forEach(t),pa=f(_e),Je=r(_e,"P",{});var wo=i(Je);_a=a(wo,"This model is also a PyTorch "),ze=r(wo,"A",{href:!0,rel:!0});var An=i(ze);ga=a(An,"torch.nn.Module"),An.forEach(t),Ta=a(wo,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),wo.forEach(t),va=f(_e),q=r(_e,"DIV",{class:!0});var ge=i(q);b($e.$$.fragment,ge),ya=f(ge),O=r(ge,"P",{});var lt=i(O);ba=a(lt,"The "),st=r(lt,"A",{href:!0});var Dn=i(st);wa=a(Dn,"TimeSeriesTransformerModel"),Dn.forEach(t),Ma=a(lt," forward method, overrides the "),Gt=r(lt,"CODE",{});var On=i(Gt);ka=a(On,"__call__"),On.forEach(t),Sa=a(lt," special method."),lt.forEach(t),Ua=f(ge),b(de.$$.fragment,ge),xa=f(ge),b(le.$$.fragment,ge),ge.forEach(t),_e.forEach(t),uo=f(o),H=r(o,"H2",{class:!0});var Mo=i(H);ce=r(Mo,"A",{id:!0,class:!0,href:!0});var Hn=i(ce);Vt=r(Hn,"SPAN",{});var Qn=i(Vt);b(Ee.$$.fragment,Qn),Qn.forEach(t),Hn.forEach(t),Ca=f(Mo),Bt=r(Mo,"SPAN",{});var Ln=i(Bt);ja=a(Ln,"TimeSeriesTransformerForPrediction"),Ln.forEach(t),Mo.forEach(t),fo=f(o),$=r(o,"DIV",{class:!0});var Te=i($);b(qe.$$.fragment,Te),Fa=f(Te),Ze=r(Te,"P",{});var ko=i(Ze);Ja=a(ko,`The Time Series Transformer Model with a distribution head on top for time-series forecasting.
This model inherits from `),at=r(ko,"A",{href:!0});var Kn=i(at);za=a(Kn,"PreTrainedModel"),Kn.forEach(t),$a=a(ko,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),ko.forEach(t),Ea=f(Te),Ne=r(Te,"P",{});var So=i(Ne);qa=a(So,"This model is also a PyTorch "),Re=r(So,"A",{href:!0,rel:!0});var er=i(Re);Za=a(er,"torch.nn.Module"),er.forEach(t),Na=a(So,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),So.forEach(t),Ra=f(Te),Z=r(Te,"DIV",{class:!0});var ve=i(Z);b(Xe.$$.fragment,ve),Xa=f(ve),Q=r(ve,"P",{});var ct=i(Q);Wa=a(ct,"The "),nt=r(ct,"A",{href:!0});var tr=i(nt);Ia=a(tr,"TimeSeriesTransformerForPrediction"),tr.forEach(t),Ga=a(ct," forward method, overrides the "),Yt=r(ct,"CODE",{});var or=i(Yt);Va=a(or,"__call__"),or.forEach(t),Ba=a(ct," special method."),ct.forEach(t),Ya=f(ve),b(he.$$.fragment,ve),Pa=f(ve),b(me.$$.fragment,ve),ve.forEach(t),Te.forEach(t),this.h()},h(){c(d,"name","hf:doc:metadata"),c(d,"content",JSON.stringify(pr)),c(p,"id","time-series-transformer"),c(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"),c(p,"href","#time-series-transformer"),c(h,"class","relative group"),c(ee,"id","overview"),c(ee,"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"),c(ee,"href","#overview"),c(G,"class","relative group"),c(Pe,"href","/docs/transformers/v4.31.0/en/model_doc/time_series_transformer#transformers.TimeSeriesTransformerModel"),c(Ae,"href","/docs/transformers/v4.31.0/en/model_doc/time_series_transformer#transformers.TimeSeriesTransformerForPrediction"),c(De,"href","/docs/transformers/v4.31.0/en/model_doc/time_series_transformer#transformers.TimeSeriesTransformerForPrediction"),c(Oe,"href","resnet"),c(we,"href","https://huggingface.co/kashif"),c(we,"rel","nofollow"),c(ae,"id","resources"),c(ae,"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"),c(ae,"href","#resources"),c(B,"class","relative group"),c(ke,"href","https://huggingface.co/blog/time-series-transformers"),c(ke,"rel","nofollow"),c(ne,"id","transformers.TimeSeriesTransformerConfig"),c(ne,"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"),c(ne,"href","#transformers.TimeSeriesTransformerConfig"),c(Y,"class","relative group"),c(Ke,"href","/docs/transformers/v4.31.0/en/model_doc/time_series_transformer#transformers.TimeSeriesTransformerModel"),c(xe,"href","https://huggingface.co/huggingface/time-series-transformer-tourism-monthly"),c(xe,"rel","nofollow"),c(et,"href","/docs/transformers/v4.31.0/en/main_classes/configuration#transformers.PretrainedConfig"),c(tt,"href","/docs/transformers/v4.31.0/en/main_classes/configuration#transformers.PretrainedConfig"),c(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(ie,"id","transformers.TimeSeriesTransformerModel"),c(ie,"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"),c(ie,"href","#transformers.TimeSeriesTransformerModel"),c(D,"class","relative group"),c(ot,"href","/docs/transformers/v4.31.0/en/main_classes/model#transformers.PreTrainedModel"),c(ze,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(ze,"rel","nofollow"),c(st,"href","/docs/transformers/v4.31.0/en/model_doc/time_series_transformer#transformers.TimeSeriesTransformerModel"),c(q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(ce,"id","transformers.TimeSeriesTransformerForPrediction"),c(ce,"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"),c(ce,"href","#transformers.TimeSeriesTransformerForPrediction"),c(H,"class","relative group"),c(at,"href","/docs/transformers/v4.31.0/en/main_classes/model#transformers.PreTrainedModel"),c(Re,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(Re,"rel","nofollow"),c(nt,"href","/docs/transformers/v4.31.0/en/model_doc/time_series_transformer#transformers.TimeSeriesTransformerForPrediction"),c(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(o,m){e(document.head,d),g(o,T,m),g(o,h,m),e(h,p),e(p,v),w(l,v,null),e(h,_),e(h,j),e(j,Uo),g(o,Kt,m),w(K,o,m),g(o,eo,m),g(o,G,m),e(G,ee),e(ee,mt),w(ye,mt,null),e(G,xo),e(G,ut),e(ut,Co),g(o,to,m),g(o,Be,m),e(Be,jo),g(o,oo,m),g(o,Ye,m),e(Ye,Fo),g(o,so,m),g(o,F,m),e(F,V),e(V,Jo),e(V,Pe),e(Pe,zo),e(V,$o),e(V,Ae),e(Ae,Eo),e(V,qo),e(F,Zo),e(F,U),e(U,De),e(De,No),e(U,Ro),e(U,ft),e(ft,Xo),e(U,Wo),e(U,pt),e(pt,Io),e(U,Go),e(U,_t),e(_t,Vo),e(U,Bo),e(U,gt),e(gt,Yo),e(U,Po),e(U,Tt),e(Tt,Ao),e(U,Do),e(U,vt),e(vt,Oo),e(U,Ho),e(F,Qo),e(F,X),e(X,Lo),e(X,yt),e(yt,Ko),e(X,es),e(X,bt),e(bt,ts),e(X,os),e(X,N),e(N,te),e(te,wt),e(wt,ss),e(te,as),e(te,Mt),e(Mt,ns),e(te,rs),e(N,is),e(N,oe),e(oe,kt),e(kt,ds),e(oe,ls),e(oe,St),e(St,cs),e(oe,hs),e(N,ms),e(N,W),e(W,Ut),e(Ut,us),e(W,fs),e(W,xt),e(xt,ps),e(W,_s),e(W,Ct),e(Ct,gs),e(W,Ts),e(N,vs),e(N,E),e(E,jt),e(jt,ys),e(E,bs),e(E,Ft),e(Ft,ws),e(E,Ms),e(E,Jt),e(Jt,ks),e(E,Ss),e(E,Oe),e(Oe,Us),e(E,xs),e(F,Cs),e(F,R),e(R,js),e(R,zt),e(zt,Fs),e(R,Js),e(R,$t),e($t,zs),e(R,$s),e(R,Et),e(Et,Es),e(R,qs),e(F,Zs),e(F,be),e(be,Ns),e(be,qt),e(qt,Rs),e(be,Xs),g(o,ao,m),g(o,se,m),e(se,Ws),e(se,we),e(we,Is),e(se,Gs),g(o,no,m),g(o,B,m),e(B,ae),e(ae,Zt),w(Me,Zt,null),e(B,Vs),e(B,Nt),e(Nt,Bs),g(o,ro,m),g(o,He,m),e(He,Ys),g(o,io,m),g(o,Qe,m),e(Qe,Le),e(Le,Ps),e(Le,ke),e(ke,As),g(o,lo,m),g(o,Y,m),e(Y,ne),e(ne,Rt),w(Se,Rt,null),e(Y,Ds),e(Y,Xt),e(Xt,Os),g(o,co,m),g(o,J,m),w(Ue,J,null),e(J,Hs),e(J,P),e(P,Qs),e(P,Ke),e(Ke,Ls),e(P,Ks),e(P,xe),e(xe,ea),e(P,ta),e(J,oa),e(J,A),e(A,sa),e(A,et),e(et,aa),e(A,na),e(A,tt),e(tt,ra),e(A,ia),e(J,da),w(re,J,null),g(o,ho,m),g(o,D,m),e(D,ie),e(ie,Wt),w(Ce,Wt,null),e(D,la),e(D,It),e(It,ca),g(o,mo,m),g(o,z,m),w(je,z,null),e(z,ha),e(z,Fe),e(Fe,ma),e(Fe,ot),e(ot,ua),e(Fe,fa),e(z,pa),e(z,Je),e(Je,_a),e(Je,ze),e(ze,ga),e(Je,Ta),e(z,va),e(z,q),w($e,q,null),e(q,ya),e(q,O),e(O,ba),e(O,st),e(st,wa),e(O,Ma),e(O,Gt),e(Gt,ka),e(O,Sa),e(q,Ua),w(de,q,null),e(q,xa),w(le,q,null),g(o,uo,m),g(o,H,m),e(H,ce),e(ce,Vt),w(Ee,Vt,null),e(H,Ca),e(H,Bt),e(Bt,ja),g(o,fo,m),g(o,$,m),w(qe,$,null),e($,Fa),e($,Ze),e(Ze,Ja),e(Ze,at),e(at,za),e(Ze,$a),e($,Ea),e($,Ne),e(Ne,qa),e(Ne,Re),e(Re,Za),e(Ne,Na),e($,Ra),e($,Z),w(Xe,Z,null),e(Z,Xa),e(Z,Q),e(Q,Wa),e(Q,nt),e(nt,Ia),e(Q,Ga),e(Q,Yt),e(Yt,Va),e(Q,Ba),e(Z,Ya),w(he,Z,null),e(Z,Pa),w(me,Z,null),po=!0},p(o,[m]){const We={};m&2&&(We.$$scope={dirty:m,ctx:o}),K.$set(We);const Pt={};m&2&&(Pt.$$scope={dirty:m,ctx:o}),re.$set(Pt);const At={};m&2&&(At.$$scope={dirty:m,ctx:o}),de.$set(At);const Dt={};m&2&&(Dt.$$scope={dirty:m,ctx:o}),le.$set(Dt);const Ie={};m&2&&(Ie.$$scope={dirty:m,ctx:o}),he.$set(Ie);const Ot={};m&2&&(Ot.$$scope={dirty:m,ctx:o}),me.$set(Ot)},i(o){po||(M(l.$$.fragment,o),M(K.$$.fragment,o),M(ye.$$.fragment,o),M(Me.$$.fragment,o),M(Se.$$.fragment,o),M(Ue.$$.fragment,o),M(re.$$.fragment,o),M(Ce.$$.fragment,o),M(je.$$.fragment,o),M($e.$$.fragment,o),M(de.$$.fragment,o),M(le.$$.fragment,o),M(Ee.$$.fragment,o),M(qe.$$.fragment,o),M(Xe.$$.fragment,o),M(he.$$.fragment,o),M(me.$$.fragment,o),po=!0)},o(o){k(l.$$.fragment,o),k(K.$$.fragment,o),k(ye.$$.fragment,o),k(Me.$$.fragment,o),k(Se.$$.fragment,o),k(Ue.$$.fragment,o),k(re.$$.fragment,o),k(Ce.$$.fragment,o),k(je.$$.fragment,o),k($e.$$.fragment,o),k(de.$$.fragment,o),k(le.$$.fragment,o),k(Ee.$$.fragment,o),k(qe.$$.fragment,o),k(Xe.$$.fragment,o),k(he.$$.fragment,o),k(me.$$.fragment,o),po=!1},d(o){t(d),o&&t(T),o&&t(h),S(l),o&&t(Kt),S(K,o),o&&t(eo),o&&t(G),S(ye),o&&t(to),o&&t(Be),o&&t(oo),o&&t(Ye),o&&t(so),o&&t(F),o&&t(ao),o&&t(se),o&&t(no),o&&t(B),S(Me),o&&t(ro),o&&t(He),o&&t(io),o&&t(Qe),o&&t(lo),o&&t(Y),S(Se),o&&t(co),o&&t(J),S(Ue),S(re),o&&t(ho),o&&t(D),S(Ce),o&&t(mo),o&&t(z),S(je),S($e),S(de),S(le),o&&t(uo),o&&t(H),S(Ee),o&&t(fo),o&&t($),S(qe),S(Xe),S(he),S(me)}}}const pr={local:"time-series-transformer",sections:[{local:"overview",title:"Overview"},{local:"resources",title:"Resources"},{local:"transformers.TimeSeriesTransformerConfig",title:"TimeSeriesTransformerConfig"},{local:"transformers.TimeSeriesTransformerModel",title:"TimeSeriesTransformerModel"},{local:"transformers.TimeSeriesTransformerForPrediction",title:"TimeSeriesTransformerForPrediction"}],title:"Time Series Transformer"};function _r(C){return ir(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Mr extends sr{constructor(d){super();ar(this,d,_r,fr,nr,{})}}export{Mr as default,pr as metadata};
