Updated critic to use leaky ReLu

This commit is contained in:
Vasilis Valatsos 2023-12-09 13:48:16 +01:00
parent 948ae9af4f
commit 85c1532920
4 changed files with 7 additions and 6 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

BIN
agents/.DS_Store vendored Normal file

Binary file not shown.

View file

@ -102,16 +102,17 @@ class Agent:
self.critic.optimizer.zero_grad()
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
actor_grad_norm = T.nn.utils.clip_grad_norm_(
self.actor.parameters(), max_norm=1)
critic_grad_norm = T.nn.utils.clip_grad_norm_(
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
print(f"Actor Gradient Norm: {actor_grad_norm}")
print(f"Critic Gradient Norm: {critic_grad_norm}")

View file

@ -96,9 +96,9 @@ class CriticNetwork(nn.Module):
self.critic = nn.Sequential(
nn.Linear(input_dims, fc1_dims),
nn.ReLU(),
nn.LeakyReLU(),
nn.Linear(fc1_dims, fc2_dims),
nn.ReLU(),
nn.LeakyReLU(),
nn.Linear(fc2_dims, 1)
)