Skip to content

Retrieve Embeddings of Samples in PatchTST #699

Answered by oguiza
MMayr96 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @MMayr96,
If by embeddings you mean the output of a given layer, I'd recommend you use fastai's Hook (see this to learn more about hooks).
You just need to decide which output you want to pull. If you want to pull the output of the backbone before it's passed to the model´s head, you could use something like this:

  1. Instantiate a learner as you would normally do:
from tsai.basics import *
from fastai.callback.hook import Hook

fcst_history = 60
fcst_horizon = 3

df = get_forecasting_time_series("Sunspots")
X, y = prepare_forecasting_data(df, fcst_history=fcst_history, fcst_horizon=fcst_horizon, dtype=np.float32)
splits = get_forecasting_splits(df, fcst_history=fcst_history, fcst_horizon=

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@MMayr96
Comment options

Answer selected by MMayr96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants