Updated critic to use leaky ReLu
This commit is contained in:
parent
948ae9af4f
commit
85c1532920
4 changed files with 7 additions and 6 deletions
BIN
.DS_Store
vendored
Normal file
BIN
.DS_Store
vendored
Normal file
Binary file not shown.
BIN
agents/.DS_Store
vendored
Normal file
BIN
agents/.DS_Store
vendored
Normal file
Binary file not shown.
|
@ -102,16 +102,17 @@ class Agent:
|
||||||
self.critic.optimizer.zero_grad()
|
self.critic.optimizer.zero_grad()
|
||||||
self.total_loss.backward()
|
self.total_loss.backward()
|
||||||
|
|
||||||
|
T.nn.utils.clip_grad_norm_(
|
||||||
|
self.actor.parameters(), max_norm=2)
|
||||||
|
T.nn.utils.clip_grad_norm_(
|
||||||
|
self.critic.parameters(), max_norm=2)
|
||||||
|
|
||||||
# Calculate the gradient norms for both networks
|
# Calculate the gradient norms for both networks
|
||||||
actor_grad_norm = T.nn.utils.clip_grad_norm_(
|
actor_grad_norm = T.nn.utils.clip_grad_norm_(
|
||||||
self.actor.parameters(), max_norm=1)
|
self.actor.parameters(), max_norm=1)
|
||||||
critic_grad_norm = T.nn.utils.clip_grad_norm_(
|
critic_grad_norm = T.nn.utils.clip_grad_norm_(
|
||||||
self.critic.parameters(), max_norm=1)
|
self.critic.parameters(), max_norm=1)
|
||||||
|
|
||||||
T.nn.utils.clip_grad_norm_(
|
|
||||||
self.actor.parameters(), max_norm=1)
|
|
||||||
T.nn.utils.clip_grad_norm_(
|
|
||||||
self.critic.parameters(), max_norm=1)
|
|
||||||
# Log or print the gradient norms
|
# Log or print the gradient norms
|
||||||
print(f"Actor Gradient Norm: {actor_grad_norm}")
|
print(f"Actor Gradient Norm: {actor_grad_norm}")
|
||||||
print(f"Critic Gradient Norm: {critic_grad_norm}")
|
print(f"Critic Gradient Norm: {critic_grad_norm}")
|
||||||
|
|
|
@ -96,9 +96,9 @@ class CriticNetwork(nn.Module):
|
||||||
|
|
||||||
self.critic = nn.Sequential(
|
self.critic = nn.Sequential(
|
||||||
nn.Linear(input_dims, fc1_dims),
|
nn.Linear(input_dims, fc1_dims),
|
||||||
nn.ReLU(),
|
nn.LeakyReLU(),
|
||||||
nn.Linear(fc1_dims, fc2_dims),
|
nn.Linear(fc1_dims, fc2_dims),
|
||||||
nn.ReLU(),
|
nn.LeakyReLU(),
|
||||||
nn.Linear(fc2_dims, 1)
|
nn.Linear(fc2_dims, 1)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue