Mehdi:

selected = self.v_n_mem[current_min:current_max] #v_n_mem is a list. It holds predictions for next state value. It is a tensor, but without history (I used .detach())


Since it contains previous predictions you need to specify retain_graph=True in your backward call. Otherwise it will delete the autograd graph after/during the first call