This commit is contained in:
Junior
2024-02-28 22:59:54 +08:00
parent 708ea57572
commit a0500f5111
12 changed files with 1200 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
import numpy as np
import torch
def dev0(a, b):
a = a.detach().numpy()
b = b.detach().numpy()
with np.errstate(divide='ignore', invalid='ignore'):
c = np.true_divide(a, b)
c[~ np.isfinite(c)] = 0
c = torch.from_numpy(c)
return c
def soft_update(target, source, tau):
for target_param, param in zip(target.parameters(), source.parameters()):
target_param.data.copy_(target_param.data * (1.0 - tau) + param.data * tau)
def hard_update(target, source):
for target_param, param in zip(target.parameters(), source.parameters()):
target_param.data.copy_(param.data)
class DeepQNetwork: