Skip to content

What is the first argument in step() function? #1547

Answered by ydcjeff
Jingnan-Jia asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @Ordgod , you can provide the first argument with whatever name you want. The first argument is used here.

self.state.output = self._process_function(self, self.state.batch)

self._process_function is update or train_step as per your question which will do forward pass + calc loss + gradient update.

  1. self itself is the Engine, so we use any class attribute, methods, etc of Engine whenever we need. So to answer your question, it's used internally.
  2. Since trainer and engine are arguments, it's ok if they are not defined before.
  3. The process_function only needs two arguments as per docs.
process_function (callable) – A fun…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@Jingnan-Jia
Comment options

@ydcjeff
Comment options

Answer selected by Jingnan-Jia
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants