I am working with an autoencoder and I use latent.view(batch_size,1,-1).expand(-1,<max_length>,-1) to add a timestep dimension and then repeat the latent space that many time steps to then feed into the decoder RNN.
When I use .expand() in this way, how does the gradient backpropagate through it? I need to ensure that the gradient accumulates from each time step and is stored in the latent vector so that I can then also backprop through the encoder.
Confirmation that what I am doing gets this done would be much appreciated.