In the above code, why h0 and c0 is created through inputs.data.new()? What inputs.data.new() actually means? Can anyone explain this piece of code? I am not understanding why we can create the h0 and c0 variable of desired shape in a normal way?
input.data.new create a tensor whose type is same as input.data, and also you can create a variable in a normal way such as Variable(torch.zeros(*state_shape)), but in order to keep the tensor type consistent with inputs, you need to cast to the type of inputs. with type_as or type manually