About the value of CTX


I don’t understand what is the meaning of the CTX, while I use it. I didn’t find the default value of CTX.
When I use the grid_sample function, I do not give CTX a value.
So what does the CTX mean?

5 Likes

Hi,

ctx can be seen as the context in which this Function is running. You will get an empty one during the forward that only contains helper functions. The same ctx will be passed to the backward function so you can use it to store stuff for the backward.
It is similar to the self argument when working with python classes.

6 Likes

Can an example be given as to using ctx in SDE let’s say?

Thanks!

Hi,

Could you specify what you mean by SDE please?

Sorry for a late reply,
I mean where can i use this “ctx” behaviour in Software Development let’s say?
Thanks.

You can see in my first comment how you should use it.