import{S as Rn,i as Wn,s as In,e as n,k as m,w as y,t as s,M as Gn,c as r,d as t,m as u,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 Vn,L as Na}from"../../chunks/vendor-hf-doc-builder.js";import{T as qa}from"../../chunks/Tip-hf-doc-builder.js";import{D as Bt}from"../../chunks/Docstring-hf-doc-builder.js";import{C as Xa}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as Yt}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Za}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Bn(j){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 F=i(h);p=a(F,"Github Issue"),F.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 Yn(j){let d,T;return d=new Xa({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:Na,i(h){T||(M(d.$$.fragment,h),T=!0)},o(h){k(d.$$.fragment,h),T=!1},d(h){S(d,h)}}}function Pn(j){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 F=i(h);p=a(F,"Module"),F.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 An(j){let d,T,h,p,v;return p=new Xa({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=m(),y(p.$$.fragment)},l(l){d=r(l,"P",{});var _=i(d);T=a(_,"Examples:"),_.forEach(t),h=u(l),b(p.$$.fragment,l)},m(l,_){g(l,d,_),e(d,T),g(l,h,_),w(p,l,_),v=!0},p:Na,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 Dn(j){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 F=i(h);p=a(F,"Module"),F.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 On(j){let d,T,h,p,v;return p=new Xa({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=m(),y(p.$$.fragment)},l(l){d=r(l,"P",{});var _=i(d);T=a(_,"Examples:"),_.forEach(t),h=u(l),b(p.$$.fragment,l)},m(l,_){g(l,d,_),e(d,T),g(l,h,_),w(p,l,_),v=!0},p:Na,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 Hn(j){let d,T,h,p,v,l,_,F,po,Pt,L,At,G,K,rt,Te,_o,it,go,Dt,Ie,To,Ot,Ge,vo,Ht,x,Ve,yo,ve,bo,wo,V,Mo,Be,ko,So,Ye,Uo,xo,Co,U,Pe,jo,Fo,dt,Jo,zo,lt,Eo,$o,ct,qo,Zo,ht,No,Xo,mt,Ro,Wo,ut,Io,Go,Vo,W,Bo,ft,Yo,Po,pt,Ao,Do,X,ee,_t,Oo,Ho,gt,Qo,Lo,Ko,te,Tt,es,ts,vt,os,ss,as,I,yt,ns,rs,bt,is,ds,wt,ls,cs,hs,$,Mt,ms,us,kt,fs,ps,St,_s,gs,Ae,Ts,vs,ys,R,bs,Ut,ws,Ms,xt,ks,Ss,Ct,Us,xs,Cs,ye,js,jt,Fs,Js,Qt,oe,zs,be,Es,$s,Lt,B,se,Ft,we,qs,Jt,Zs,Kt,J,Me,Ns,Y,Xs,De,Rs,Ws,ke,Is,Gs,Vs,P,Bs,Oe,Ys,Ps,He,As,Ds,Os,ae,eo,A,ne,zt,Se,Hs,Et,Qs,to,z,Ue,Ls,xe,Ks,Qe,ea,ta,oa,Ce,sa,je,aa,na,ra,q,Fe,ia,D,da,Le,la,ca,$t,ha,ma,ua,re,fa,ie,oo,O,de,qt,Je,pa,Zt,_a,so,E,ze,ga,Ee,Ta,Ke,va,ya,ba,$e,wa,qe,Ma,ka,Sa,Z,Ze,Ua,H,xa,et,Ca,ja,Nt,Fa,Ja,za,le,Ea,ce,ao;return l=new Yt({}),L=new qa({props:{$$slots:{default:[Bn]},$$scope:{ctx:j}}}),Te=new Yt({}),we=new Yt({}),Me=new Bt({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.30.0/src/transformers/models/time_series_transformer/configuration_time_series_transformer.py#L33"}}),ae=new Za({props:{anchor:"transformers.TimeSeriesTransformerConfig.example",$$slots:{default:[Yn]},$$scope:{ctx:j}}}),Se=new Yt({}),Ue=new Bt({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.30.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.30.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.30.0/src/transformers/models/time_series_transformer/modeling_time_series_transformer.py#L1228"}}),Fe=new Bt({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.30.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.30.0/src/transformers/models/time_series_transformer/modeling_time_series_transformer.py#L1366",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.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.30.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.30.0/en/main_classes/output#transformers.modeling_outputs.Seq2SeqTSModelOutput"
>transformers.modeling_outputs.Seq2SeqTSModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),re=new qa({props:{$$slots:{default:[Pn]},$$scope:{ctx:j}}}),ie=new Za({props:{anchor:"transformers.TimeSeriesTransformerModel.forward.example",$$slots:{default:[An]},$$scope:{ctx:j}}}),Je=new Yt({}),ze=new Bt({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.30.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.30.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.30.0/src/transformers/models/time_series_transformer/modeling_time_series_transformer.py#L1489"}}),Ze=new Bt({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.30.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.30.0/src/transformers/models/time_series_transformer/modeling_time_series_transformer.py#L1529",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.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.30.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.30.0/en/main_classes/output#transformers.modeling_outputs.Seq2SeqTSModelOutput"
>transformers.modeling_outputs.Seq2SeqTSModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),le=new qa({props:{$$slots:{default:[Dn]},$$scope:{ctx:j}}}),ce=new Za({props:{anchor:"transformers.TimeSeriesTransformerForPrediction.forward.example",$$slots:{default:[On]},$$scope:{ctx:j}}}),{c(){d=n("meta"),T=m(),h=n("h1"),p=n("a"),v=n("span"),y(l.$$.fragment),_=m(),F=n("span"),po=s("Time Series Transformer"),Pt=m(),y(L.$$.fragment),At=m(),G=n("h2"),K=n("a"),rt=n("span"),y(Te.$$.fragment),_o=m(),it=n("span"),go=s("Overview"),Dt=m(),Ie=n("p"),To=s("The Time Series Transformer model is a vanilla encoder-decoder Transformer for time series forecasting."),Ot=m(),Ge=n("p"),vo=s("Tips:"),Ht=m(),x=n("ul"),Ve=n("li"),yo=s("Check out the Time Series Transformer blog-post in HuggingFace blog: "),ve=n("a"),bo=s("Probabilistic Time Series Forecasting with \u{1F917} Transformers"),wo=m(),V=n("li"),Mo=s("Similar to other models in the library, "),Be=n("a"),ko=s("TimeSeriesTransformerModel"),So=s(" is the raw Transformer without any head on top, and "),Ye=n("a"),Uo=s("TimeSeriesTransformerForPrediction"),xo=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.`),Co=m(),U=n("li"),Pe=n("a"),jo=s("TimeSeriesTransformerForPrediction"),Fo=s(" consists of 2 blocks: an encoder, which takes a "),dt=n("code"),Jo=s("context_length"),zo=s(" of time series values as input (called "),lt=n("code"),Eo=s("past_values"),$o=s(`),
and a decoder, which predicts a `),ct=n("code"),qo=s("prediction_length"),Zo=s(" of time series values into the future (called "),ht=n("code"),No=s("future_values"),Xo=s(`). During training, one needs to provide
pairs of (`),mt=n("code"),Ro=s("past_values"),Wo=s(" and "),ut=n("code"),Io=s("future_values"),Go=s(") to the model."),Vo=m(),W=n("li"),Bo=s("In addition to the raw ("),ft=n("code"),Yo=s("past_values"),Po=s(" and "),pt=n("code"),Ao=s("future_values"),Do=s("), one typically provides additional features to the model. These can be the following:"),X=n("ul"),ee=n("li"),_t=n("code"),Oo=s("past_time_features"),Ho=s(": temporal features which the model will add to "),gt=n("code"),Qo=s("past_values"),Lo=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).`),Ko=m(),te=n("li"),Tt=n("code"),es=s("future_time_features"),ts=s(": temporal features which the model will add to "),vt=n("code"),os=s("future_values"),ss=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).`),as=m(),I=n("li"),yt=n("code"),ns=s("static_categorical_features"),rs=s(": categorical features which are static over time (i.e., have the same value for all "),bt=n("code"),is=s("past_values"),ds=s(" and "),wt=n("code"),ls=s("future_values"),cs=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).`),hs=m(),$=n("li"),Mt=n("code"),ms=s("static_real_features"),us=s(": real-valued features which are static over time (i.e., have the same value for all "),kt=n("code"),fs=s("past_values"),ps=s(" and "),St=n("code"),_s=s("future_values"),gs=s(`).
An example here is the image representation of the product for which you have the time-series values (like the `),Ae=n("a"),Ts=s("ResNet"),vs=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).`),ys=m(),R=n("li"),bs=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
`),Ut=n("code"),ws=s("future_values"),Ms=s(" one position to the right as input to the decoder, prepended by the last value of "),xt=n("code"),ks=s("past_values"),Ss=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 `),Ct=n("code"),Us=s("decoder_start_token_id"),xs=s(` (we just use the last value
of the context as initial input for the decoder).`),Cs=m(),ye=n("li"),js=s("At inference time, we give the final value of the "),jt=n("code"),Fs=s("past_values"),Js=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).`),Qt=m(),oe=n("p"),zs=s("This model was contributed by "),be=n("a"),Es=s("kashif"),$s=s("."),Lt=m(),B=n("h2"),se=n("a"),Ft=n("span"),y(we.$$.fragment),qs=m(),Jt=n("span"),Zs=s("TimeSeriesTransformerConfig"),Kt=m(),J=n("div"),y(Me.$$.fragment),Ns=m(),Y=n("p"),Xs=s("This is the configuration class to store the configuration of a "),De=n("a"),Rs=s("TimeSeriesTransformerModel"),Ws=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
`),ke=n("a"),Is=s("huggingface/time-series-transformer-tourism-monthly"),Gs=s(`
architecture.`),Vs=m(),P=n("p"),Bs=s("Configuration objects inherit from "),Oe=n("a"),Ys=s("PretrainedConfig"),Ps=s(` can be used to control the model outputs. Read the
documentation from `),He=n("a"),As=s("PretrainedConfig"),Ds=s(" for more information."),Os=m(),y(ae.$$.fragment),eo=m(),A=n("h2"),ne=n("a"),zt=n("span"),y(Se.$$.fragment),Hs=m(),Et=n("span"),Qs=s("TimeSeriesTransformerModel"),to=m(),z=n("div"),y(Ue.$$.fragment),Ls=m(),xe=n("p"),Ks=s(`The bare Time Series Transformer Model outputting raw hidden-states without any specific head on top.
This model inherits from `),Qe=n("a"),ea=s("PreTrainedModel"),ta=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.)`),oa=m(),Ce=n("p"),sa=s("This model is also a PyTorch "),je=n("a"),aa=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=m(),q=n("div"),y(Fe.$$.fragment),ia=m(),D=n("p"),da=s("The "),Le=n("a"),la=s("TimeSeriesTransformerModel"),ca=s(" forward method, overrides the "),$t=n("code"),ha=s("__call__"),ma=s(" special method."),ua=m(),y(re.$$.fragment),fa=m(),y(ie.$$.fragment),oo=m(),O=n("h2"),de=n("a"),qt=n("span"),y(Je.$$.fragment),pa=m(),Zt=n("span"),_a=s("TimeSeriesTransformerForPrediction"),so=m(),E=n("div"),y(ze.$$.fragment),ga=m(),Ee=n("p"),Ta=s(`The Time Series Transformer Model with a distribution head on top for time-series forecasting.
This model inherits from `),Ke=n("a"),va=s("PreTrainedModel"),ya=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.)`),ba=m(),$e=n("p"),wa=s("This model is also a PyTorch "),qe=n("a"),Ma=s("torch.nn.Module"),ka=s(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Sa=m(),Z=n("div"),y(Ze.$$.fragment),Ua=m(),H=n("p"),xa=s("The "),et=n("a"),Ca=s("TimeSeriesTransformerForPrediction"),ja=s(" forward method, overrides the "),Nt=n("code"),Fa=s("__call__"),Ja=s(" special method."),za=m(),y(le.$$.fragment),Ea=m(),y(ce.$$.fragment),this.h()},l(o){const f=Gn('[data-svelte="svelte-1phssyn"]',document.head);d=r(f,"META",{name:!0,content:!0}),f.forEach(t),T=u(o),h=r(o,"H1",{class:!0});var Ne=i(h);p=r(Ne,"A",{id:!0,class:!0,href:!0});var Xt=i(p);v=r(Xt,"SPAN",{});var Rt=i(v);b(l.$$.fragment,Rt),Rt.forEach(t),Xt.forEach(t),_=u(Ne),F=r(Ne,"SPAN",{});var Wt=i(F);po=a(Wt,"Time Series Transformer"),Wt.forEach(t),Ne.forEach(t),Pt=u(o),b(L.$$.fragment,o),At=u(o),G=r(o,"H2",{class:!0});var Xe=i(G);K=r(Xe,"A",{id:!0,class:!0,href:!0});var It=i(K);rt=r(It,"SPAN",{});var Ra=i(rt);b(Te.$$.fragment,Ra),Ra.forEach(t),It.forEach(t),_o=u(Xe),it=r(Xe,"SPAN",{});var Wa=i(it);go=a(Wa,"Overview"),Wa.forEach(t),Xe.forEach(t),Dt=u(o),Ie=r(o,"P",{});var Ia=i(Ie);To=a(Ia,"The Time Series Transformer model is a vanilla encoder-decoder Transformer for time series forecasting."),Ia.forEach(t),Ot=u(o),Ge=r(o,"P",{});var Ga=i(Ge);vo=a(Ga,"Tips:"),Ga.forEach(t),Ht=u(o),x=r(o,"UL",{});var N=i(x);Ve=r(N,"LI",{});var $a=i(Ve);yo=a($a,"Check out the Time Series Transformer blog-post in HuggingFace blog: "),ve=r($a,"A",{href:!0,rel:!0});var Va=i(ve);bo=a(Va,"Probabilistic Time Series Forecasting with \u{1F917} Transformers"),Va.forEach(t),$a.forEach(t),wo=u(N),V=r(N,"LI",{});var tt=i(V);Mo=a(tt,"Similar to other models in the library, "),Be=r(tt,"A",{href:!0});var Ba=i(Be);ko=a(Ba,"TimeSeriesTransformerModel"),Ba.forEach(t),So=a(tt," is the raw Transformer without any head on top, and "),Ye=r(tt,"A",{href:!0});var Ya=i(Ye);Uo=a(Ya,"TimeSeriesTransformerForPrediction"),Ya.forEach(t),xo=a(tt,`
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.`),tt.forEach(t),Co=u(N),U=r(N,"LI",{});var C=i(U);Pe=r(C,"A",{href:!0});var Pa=i(Pe);jo=a(Pa,"TimeSeriesTransformerForPrediction"),Pa.forEach(t),Fo=a(C," consists of 2 blocks: an encoder, which takes a "),dt=r(C,"CODE",{});var Aa=i(dt);Jo=a(Aa,"context_length"),Aa.forEach(t),zo=a(C," of time series values as input (called "),lt=r(C,"CODE",{});var Da=i(lt);Eo=a(Da,"past_values"),Da.forEach(t),$o=a(C,`),
and a decoder, which predicts a `),ct=r(C,"CODE",{});var Oa=i(ct);qo=a(Oa,"prediction_length"),Oa.forEach(t),Zo=a(C," of time series values into the future (called "),ht=r(C,"CODE",{});var Ha=i(ht);No=a(Ha,"future_values"),Ha.forEach(t),Xo=a(C,`). During training, one needs to provide
pairs of (`),mt=r(C,"CODE",{});var Qa=i(mt);Ro=a(Qa,"past_values"),Qa.forEach(t),Wo=a(C," and "),ut=r(C,"CODE",{});var La=i(ut);Io=a(La,"future_values"),La.forEach(t),Go=a(C,") to the model."),C.forEach(t),Vo=u(N),W=r(N,"LI",{});var Re=i(W);Bo=a(Re,"In addition to the raw ("),ft=r(Re,"CODE",{});var Ka=i(ft);Yo=a(Ka,"past_values"),Ka.forEach(t),Po=a(Re," and "),pt=r(Re,"CODE",{});var en=i(pt);Ao=a(en,"future_values"),en.forEach(t),Do=a(Re,"), one typically provides additional features to the model. These can be the following:"),X=r(Re,"UL",{});var he=i(X);ee=r(he,"LI",{});var Gt=i(ee);_t=r(Gt,"CODE",{});var tn=i(_t);Oo=a(tn,"past_time_features"),tn.forEach(t),Ho=a(Gt,": temporal features which the model will add to "),gt=r(Gt,"CODE",{});var on=i(gt);Qo=a(on,"past_values"),on.forEach(t),Lo=a(Gt,`. 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).`),Gt.forEach(t),Ko=u(he),te=r(he,"LI",{});var Vt=i(te);Tt=r(Vt,"CODE",{});var sn=i(Tt);es=a(sn,"future_time_features"),sn.forEach(t),ts=a(Vt,": temporal features which the model will add to "),vt=r(Vt,"CODE",{});var an=i(vt);os=a(an,"future_values"),an.forEach(t),ss=a(Vt,`. 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).`),Vt.forEach(t),as=u(he),I=r(he,"LI",{});var We=i(I);yt=r(We,"CODE",{});var nn=i(yt);ns=a(nn,"static_categorical_features"),nn.forEach(t),rs=a(We,": categorical features which are static over time (i.e., have the same value for all "),bt=r(We,"CODE",{});var rn=i(bt);is=a(rn,"past_values"),rn.forEach(t),ds=a(We," and "),wt=r(We,"CODE",{});var dn=i(wt);ls=a(dn,"future_values"),dn.forEach(t),cs=a(We,`).
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).`),We.forEach(t),hs=u(he),$=r(he,"LI",{});var Q=i($);Mt=r(Q,"CODE",{});var ln=i(Mt);ms=a(ln,"static_real_features"),ln.forEach(t),us=a(Q,": real-valued features which are static over time (i.e., have the same value for all "),kt=r(Q,"CODE",{});var cn=i(kt);fs=a(cn,"past_values"),cn.forEach(t),ps=a(Q," and "),St=r(Q,"CODE",{});var hn=i(St);_s=a(hn,"future_values"),hn.forEach(t),gs=a(Q,`).
An example here is the image representation of the product for which you have the time-series values (like the `),Ae=r(Q,"A",{href:!0});var mn=i(Ae);Ts=a(mn,"ResNet"),mn.forEach(t),vs=a(Q,` 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).`),Q.forEach(t),he.forEach(t),Re.forEach(t),ys=u(N),R=r(N,"LI",{});var me=i(R);bs=a(me,`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
`),Ut=r(me,"CODE",{});var un=i(Ut);ws=a(un,"future_values"),un.forEach(t),Ms=a(me," one position to the right as input to the decoder, prepended by the last value of "),xt=r(me,"CODE",{});var fn=i(xt);ks=a(fn,"past_values"),fn.forEach(t),Ss=a(me,`. 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 `),Ct=r(me,"CODE",{});var pn=i(Ct);Us=a(pn,"decoder_start_token_id"),pn.forEach(t),xs=a(me,` (we just use the last value
of the context as initial input for the decoder).`),me.forEach(t),Cs=u(N),ye=r(N,"LI",{});var no=i(ye);js=a(no,"At inference time, we give the final value of the "),jt=r(no,"CODE",{});var _n=i(jt);Fs=a(_n,"past_values"),_n.forEach(t),Js=a(no,` 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).`),no.forEach(t),N.forEach(t),Qt=u(o),oe=r(o,"P",{});var ro=i(oe);zs=a(ro,"This model was contributed by "),be=r(ro,"A",{href:!0,rel:!0});var gn=i(be);Es=a(gn,"kashif"),gn.forEach(t),$s=a(ro,"."),ro.forEach(t),Lt=u(o),B=r(o,"H2",{class:!0});var io=i(B);se=r(io,"A",{id:!0,class:!0,href:!0});var Tn=i(se);Ft=r(Tn,"SPAN",{});var vn=i(Ft);b(we.$$.fragment,vn),vn.forEach(t),Tn.forEach(t),qs=u(io),Jt=r(io,"SPAN",{});var yn=i(Jt);Zs=a(yn,"TimeSeriesTransformerConfig"),yn.forEach(t),io.forEach(t),Kt=u(o),J=r(o,"DIV",{class:!0});var ue=i(J);b(Me.$$.fragment,ue),Ns=u(ue),Y=r(ue,"P",{});var ot=i(Y);Xs=a(ot,"This is the configuration class to store the configuration of a "),De=r(ot,"A",{href:!0});var bn=i(De);Rs=a(bn,"TimeSeriesTransformerModel"),bn.forEach(t),Ws=a(ot,`. 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
`),ke=r(ot,"A",{href:!0,rel:!0});var wn=i(ke);Is=a(wn,"huggingface/time-series-transformer-tourism-monthly"),wn.forEach(t),Gs=a(ot,`
architecture.`),ot.forEach(t),Vs=u(ue),P=r(ue,"P",{});var st=i(P);Bs=a(st,"Configuration objects inherit from "),Oe=r(st,"A",{href:!0});var Mn=i(Oe);Ys=a(Mn,"PretrainedConfig"),Mn.forEach(t),Ps=a(st,` can be used to control the model outputs. Read the
documentation from `),He=r(st,"A",{href:!0});var kn=i(He);As=a(kn,"PretrainedConfig"),kn.forEach(t),Ds=a(st," for more information."),st.forEach(t),Os=u(ue),b(ae.$$.fragment,ue),ue.forEach(t),eo=u(o),A=r(o,"H2",{class:!0});var lo=i(A);ne=r(lo,"A",{id:!0,class:!0,href:!0});var Sn=i(ne);zt=r(Sn,"SPAN",{});var Un=i(zt);b(Se.$$.fragment,Un),Un.forEach(t),Sn.forEach(t),Hs=u(lo),Et=r(lo,"SPAN",{});var xn=i(Et);Qs=a(xn,"TimeSeriesTransformerModel"),xn.forEach(t),lo.forEach(t),to=u(o),z=r(o,"DIV",{class:!0});var fe=i(z);b(Ue.$$.fragment,fe),Ls=u(fe),xe=r(fe,"P",{});var co=i(xe);Ks=a(co,`The bare Time Series Transformer Model outputting raw hidden-states without any specific head on top.
This model inherits from `),Qe=r(co,"A",{href:!0});var Cn=i(Qe);ea=a(Cn,"PreTrainedModel"),Cn.forEach(t),ta=a(co,`. 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.)`),co.forEach(t),oa=u(fe),Ce=r(fe,"P",{});var ho=i(Ce);sa=a(ho,"This model is also a PyTorch "),je=r(ho,"A",{href:!0,rel:!0});var jn=i(je);aa=a(jn,"torch.nn.Module"),jn.forEach(t),na=a(ho,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ho.forEach(t),ra=u(fe),q=r(fe,"DIV",{class:!0});var pe=i(q);b(Fe.$$.fragment,pe),ia=u(pe),D=r(pe,"P",{});var at=i(D);da=a(at,"The "),Le=r(at,"A",{href:!0});var Fn=i(Le);la=a(Fn,"TimeSeriesTransformerModel"),Fn.forEach(t),ca=a(at," forward method, overrides the "),$t=r(at,"CODE",{});var Jn=i($t);ha=a(Jn,"__call__"),Jn.forEach(t),ma=a(at," special method."),at.forEach(t),ua=u(pe),b(re.$$.fragment,pe),fa=u(pe),b(ie.$$.fragment,pe),pe.forEach(t),fe.forEach(t),oo=u(o),O=r(o,"H2",{class:!0});var mo=i(O);de=r(mo,"A",{id:!0,class:!0,href:!0});var zn=i(de);qt=r(zn,"SPAN",{});var En=i(qt);b(Je.$$.fragment,En),En.forEach(t),zn.forEach(t),pa=u(mo),Zt=r(mo,"SPAN",{});var $n=i(Zt);_a=a($n,"TimeSeriesTransformerForPrediction"),$n.forEach(t),mo.forEach(t),so=u(o),E=r(o,"DIV",{class:!0});var _e=i(E);b(ze.$$.fragment,_e),ga=u(_e),Ee=r(_e,"P",{});var uo=i(Ee);Ta=a(uo,`The Time Series Transformer Model with a distribution head on top for time-series forecasting.
This model inherits from `),Ke=r(uo,"A",{href:!0});var qn=i(Ke);va=a(qn,"PreTrainedModel"),qn.forEach(t),ya=a(uo,`. 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.)`),uo.forEach(t),ba=u(_e),$e=r(_e,"P",{});var fo=i($e);wa=a(fo,"This model is also a PyTorch "),qe=r(fo,"A",{href:!0,rel:!0});var Zn=i(qe);Ma=a(Zn,"torch.nn.Module"),Zn.forEach(t),ka=a(fo,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),fo.forEach(t),Sa=u(_e),Z=r(_e,"DIV",{class:!0});var ge=i(Z);b(Ze.$$.fragment,ge),Ua=u(ge),H=r(ge,"P",{});var nt=i(H);xa=a(nt,"The "),et=r(nt,"A",{href:!0});var Nn=i(et);Ca=a(Nn,"TimeSeriesTransformerForPrediction"),Nn.forEach(t),ja=a(nt," forward method, overrides the "),Nt=r(nt,"CODE",{});var Xn=i(Nt);Fa=a(Xn,"__call__"),Xn.forEach(t),Ja=a(nt," special method."),nt.forEach(t),za=u(ge),b(le.$$.fragment,ge),Ea=u(ge),b(ce.$$.fragment,ge),ge.forEach(t),_e.forEach(t),this.h()},h(){c(d,"name","hf:doc:metadata"),c(d,"content",JSON.stringify(Qn)),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(K,"id","overview"),c(K,"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(K,"href","#overview"),c(G,"class","relative group"),c(ve,"href","https://huggingface.co/blog/time-series-transformers"),c(ve,"rel","nofollow"),c(Be,"href","/docs/transformers/v4.30.0/en/model_doc/time_series_transformer#transformers.TimeSeriesTransformerModel"),c(Ye,"href","/docs/transformers/v4.30.0/en/model_doc/time_series_transformer#transformers.TimeSeriesTransformerForPrediction"),c(Pe,"href","/docs/transformers/v4.30.0/en/model_doc/time_series_transformer#transformers.TimeSeriesTransformerForPrediction"),c(Ae,"href","resnet"),c(be,"href","https://huggingface.co/kashif"),c(be,"rel","nofollow"),c(se,"id","transformers.TimeSeriesTransformerConfig"),c(se,"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(se,"href","#transformers.TimeSeriesTransformerConfig"),c(B,"class","relative group"),c(De,"href","/docs/transformers/v4.30.0/en/model_doc/time_series_transformer#transformers.TimeSeriesTransformerModel"),c(ke,"href","https://huggingface.co/huggingface/time-series-transformer-tourism-monthly"),c(ke,"rel","nofollow"),c(Oe,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),c(He,"href","/docs/transformers/v4.30.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(ne,"id","transformers.TimeSeriesTransformerModel"),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.TimeSeriesTransformerModel"),c(A,"class","relative group"),c(Qe,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.PreTrainedModel"),c(je,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(je,"rel","nofollow"),c(Le,"href","/docs/transformers/v4.30.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(de,"id","transformers.TimeSeriesTransformerForPrediction"),c(de,"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(de,"href","#transformers.TimeSeriesTransformerForPrediction"),c(O,"class","relative group"),c(Ke,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.PreTrainedModel"),c(qe,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(qe,"rel","nofollow"),c(et,"href","/docs/transformers/v4.30.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(E,"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,f){e(document.head,d),g(o,T,f),g(o,h,f),e(h,p),e(p,v),w(l,v,null),e(h,_),e(h,F),e(F,po),g(o,Pt,f),w(L,o,f),g(o,At,f),g(o,G,f),e(G,K),e(K,rt),w(Te,rt,null),e(G,_o),e(G,it),e(it,go),g(o,Dt,f),g(o,Ie,f),e(Ie,To),g(o,Ot,f),g(o,Ge,f),e(Ge,vo),g(o,Ht,f),g(o,x,f),e(x,Ve),e(Ve,yo),e(Ve,ve),e(ve,bo),e(x,wo),e(x,V),e(V,Mo),e(V,Be),e(Be,ko),e(V,So),e(V,Ye),e(Ye,Uo),e(V,xo),e(x,Co),e(x,U),e(U,Pe),e(Pe,jo),e(U,Fo),e(U,dt),e(dt,Jo),e(U,zo),e(U,lt),e(lt,Eo),e(U,$o),e(U,ct),e(ct,qo),e(U,Zo),e(U,ht),e(ht,No),e(U,Xo),e(U,mt),e(mt,Ro),e(U,Wo),e(U,ut),e(ut,Io),e(U,Go),e(x,Vo),e(x,W),e(W,Bo),e(W,ft),e(ft,Yo),e(W,Po),e(W,pt),e(pt,Ao),e(W,Do),e(W,X),e(X,ee),e(ee,_t),e(_t,Oo),e(ee,Ho),e(ee,gt),e(gt,Qo),e(ee,Lo),e(X,Ko),e(X,te),e(te,Tt),e(Tt,es),e(te,ts),e(te,vt),e(vt,os),e(te,ss),e(X,as),e(X,I),e(I,yt),e(yt,ns),e(I,rs),e(I,bt),e(bt,is),e(I,ds),e(I,wt),e(wt,ls),e(I,cs),e(X,hs),e(X,$),e($,Mt),e(Mt,ms),e($,us),e($,kt),e(kt,fs),e($,ps),e($,St),e(St,_s),e($,gs),e($,Ae),e(Ae,Ts),e($,vs),e(x,ys),e(x,R),e(R,bs),e(R,Ut),e(Ut,ws),e(R,Ms),e(R,xt),e(xt,ks),e(R,Ss),e(R,Ct),e(Ct,Us),e(R,xs),e(x,Cs),e(x,ye),e(ye,js),e(ye,jt),e(jt,Fs),e(ye,Js),g(o,Qt,f),g(o,oe,f),e(oe,zs),e(oe,be),e(be,Es),e(oe,$s),g(o,Lt,f),g(o,B,f),e(B,se),e(se,Ft),w(we,Ft,null),e(B,qs),e(B,Jt),e(Jt,Zs),g(o,Kt,f),g(o,J,f),w(Me,J,null),e(J,Ns),e(J,Y),e(Y,Xs),e(Y,De),e(De,Rs),e(Y,Ws),e(Y,ke),e(ke,Is),e(Y,Gs),e(J,Vs),e(J,P),e(P,Bs),e(P,Oe),e(Oe,Ys),e(P,Ps),e(P,He),e(He,As),e(P,Ds),e(J,Os),w(ae,J,null),g(o,eo,f),g(o,A,f),e(A,ne),e(ne,zt),w(Se,zt,null),e(A,Hs),e(A,Et),e(Et,Qs),g(o,to,f),g(o,z,f),w(Ue,z,null),e(z,Ls),e(z,xe),e(xe,Ks),e(xe,Qe),e(Qe,ea),e(xe,ta),e(z,oa),e(z,Ce),e(Ce,sa),e(Ce,je),e(je,aa),e(Ce,na),e(z,ra),e(z,q),w(Fe,q,null),e(q,ia),e(q,D),e(D,da),e(D,Le),e(Le,la),e(D,ca),e(D,$t),e($t,ha),e(D,ma),e(q,ua),w(re,q,null),e(q,fa),w(ie,q,null),g(o,oo,f),g(o,O,f),e(O,de),e(de,qt),w(Je,qt,null),e(O,pa),e(O,Zt),e(Zt,_a),g(o,so,f),g(o,E,f),w(ze,E,null),e(E,ga),e(E,Ee),e(Ee,Ta),e(Ee,Ke),e(Ke,va),e(Ee,ya),e(E,ba),e(E,$e),e($e,wa),e($e,qe),e(qe,Ma),e($e,ka),e(E,Sa),e(E,Z),w(Ze,Z,null),e(Z,Ua),e(Z,H),e(H,xa),e(H,et),e(et,Ca),e(H,ja),e(H,Nt),e(Nt,Fa),e(H,Ja),e(Z,za),w(le,Z,null),e(Z,Ea),w(ce,Z,null),ao=!0},p(o,[f]){const Ne={};f&2&&(Ne.$$scope={dirty:f,ctx:o}),L.$set(Ne);const Xt={};f&2&&(Xt.$$scope={dirty:f,ctx:o}),ae.$set(Xt);const Rt={};f&2&&(Rt.$$scope={dirty:f,ctx:o}),re.$set(Rt);const Wt={};f&2&&(Wt.$$scope={dirty:f,ctx:o}),ie.$set(Wt);const Xe={};f&2&&(Xe.$$scope={dirty:f,ctx:o}),le.$set(Xe);const It={};f&2&&(It.$$scope={dirty:f,ctx:o}),ce.$set(It)},i(o){ao||(M(l.$$.fragment,o),M(L.$$.fragment,o),M(Te.$$.fragment,o),M(we.$$.fragment,o),M(Me.$$.fragment,o),M(ae.$$.fragment,o),M(Se.$$.fragment,o),M(Ue.$$.fragment,o),M(Fe.$$.fragment,o),M(re.$$.fragment,o),M(ie.$$.fragment,o),M(Je.$$.fragment,o),M(ze.$$.fragment,o),M(Ze.$$.fragment,o),M(le.$$.fragment,o),M(ce.$$.fragment,o),ao=!0)},o(o){k(l.$$.fragment,o),k(L.$$.fragment,o),k(Te.$$.fragment,o),k(we.$$.fragment,o),k(Me.$$.fragment,o),k(ae.$$.fragment,o),k(Se.$$.fragment,o),k(Ue.$$.fragment,o),k(Fe.$$.fragment,o),k(re.$$.fragment,o),k(ie.$$.fragment,o),k(Je.$$.fragment,o),k(ze.$$.fragment,o),k(Ze.$$.fragment,o),k(le.$$.fragment,o),k(ce.$$.fragment,o),ao=!1},d(o){t(d),o&&t(T),o&&t(h),S(l),o&&t(Pt),S(L,o),o&&t(At),o&&t(G),S(Te),o&&t(Dt),o&&t(Ie),o&&t(Ot),o&&t(Ge),o&&t(Ht),o&&t(x),o&&t(Qt),o&&t(oe),o&&t(Lt),o&&t(B),S(we),o&&t(Kt),o&&t(J),S(Me),S(ae),o&&t(eo),o&&t(A),S(Se),o&&t(to),o&&t(z),S(Ue),S(Fe),S(re),S(ie),o&&t(oo),o&&t(O),S(Je),o&&t(so),o&&t(E),S(ze),S(Ze),S(le),S(ce)}}}const Qn={local:"time-series-transformer",sections:[{local:"overview",title:"Overview"},{local:"transformers.TimeSeriesTransformerConfig",title:"TimeSeriesTransformerConfig"},{local:"transformers.TimeSeriesTransformerModel",title:"TimeSeriesTransformerModel"},{local:"transformers.TimeSeriesTransformerForPrediction",title:"TimeSeriesTransformerForPrediction"}],title:"Time Series Transformer"};function Ln(j){return Vn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class nr extends Rn{constructor(d){super();Wn(this,d,Ln,Hn,In,{})}}export{nr as default,Qn as metadata};
