I was trying to use euler based backprop through time.
for i in tqdm(range(iterations)):
x0 = sample(batch_size)
loss = 0.0
for t in np.arange(start_time,end_time+1e-5,step):
u = policy(x0)
loss= loss+ step*cost(x0,u)
x0 = x0 + step * dynamics(x0, u)
del x0
del u
optimizer.zero_grad()
loss.backward()
optimizer.step()
Here sample function just samples batches from normal dist, policy is a small neural network, cost and dynamics are small functions (containing sin, cos and some small computations).
But its eating up my ram. Is there a way to clear ram after some iterations?
Thanks in advance