問題文
A developer defines a custom layer by subclassing nn.Module. Which pair of methods makes up the minimum they must provide for the layer to hold learnable state and be usable in a model?
選択肢
- Only a forward method, since state is registered automatically.
- A forward method and a backward method, because a subclass has to supply the derivative of its own computation.
- A forward method and a train method that switches modes.
- An initializer that calls the base class initializer and registers the state, and a forward method that performs the computation.