Hi,
I have a few confusions where I am not understanding Pytorch.


What needs to be wrapped in a variable? Why do inputs and outputs have to be wrapped in a variable? Is the wrapping still needed when using nn.Modules?


When using nn.Modules, we can just pass input tensors to the model and use it, right? Is there still anything that we need to do to ensure that optimization and backprop works?


LSTM implementations do not have any state right (tutorial by https://apaszke.github.io/lstm-explained.html 4 @apaszke) ? Their state is maintained by passing the hidden state as an input. So, to use LSTM I need to create a hidden variable which will be passed as input to the LSTM. Why does hidden state has to be wrapped in a variable? What steps do I need to do maintain the hidden state, i.e. does it need o be initialized, detached? I have seen many examples where they initialize and detach hidden variables and I am not getting why it needs to be initialized (isn’t zero init already done in Pytorch?) and why do detaching? When to do detaching?


Before any new training sample, why set gradient to zero?


nn.Modules’s LSTM has an API where it takes a 3d tensor. How does it accept the hidden state input? How to define and use the hidden variable for the LSTM in the nn.Module?


I am trying to understand batching, suppose I want to use a dataset of size ~ 100MB. I can load the dataset into memory, but I am getting the message: you are trying to allocate 6GB RAM, buy more RAM from Pytorch. i assume this is happening because the pytorch model has to pass data around and hence even a small dataset of ~ 100 MB can take large space? How to resolve this issue? How to do batching in this case and why would it solve the issue?


Sorry if the questions seem too naive. Links to any relevant resources are welcome!!
Cheers!