Hi @nairbv, currently I do that as follows:
source = np.random.randn(T)
samples = torch.empty(N, t)
inds = np.random.randint(0, T-t+1, N)
for i in range(N):
    ind = inds[i]
    samples[i] = torch.Tensor(source[ind:(ind+t)])

So, I am willing to take N*t space for samples tensor. The problem is that if N is large, the for-loop might take some time to execute (but I really am not sure whether it could be a problem. Maybe i’m too precautious). I also do not want to take O(Nt) memory for indices that I will use to extract samples from source.
I am wondering if there is a neat way to vectorize the operation of extracting the samples from source.
After that, each sample is passed through a neural net.