refactor: add 2 spaces in tp7 between function
All checks were successful
SonarQube Scan / SonarQube Trigger (push) Successful in 24s
All checks were successful
SonarQube Scan / SonarQube Trigger (push) Successful in 24s
This commit is contained in:
4
tp7.py
4
tp7.py
@@ -25,6 +25,7 @@ class Actor(nn.Module):
|
||||
std = torch.exp(log_std)
|
||||
return mu, std
|
||||
|
||||
|
||||
class Critic(nn.Module):
|
||||
def __init__(self, state_dim):
|
||||
super().__init__()
|
||||
@@ -53,6 +54,7 @@ def compute_gae(rewards, values, gamma, lam, next_value):
|
||||
advantages = (advantages - advantages.mean()) / (advantages.std() + 1e-8)
|
||||
return returns, advantages
|
||||
|
||||
|
||||
# ——— Entraînement ———
|
||||
def train_and_save():
|
||||
env = gym.make("Pusher-v5")
|
||||
@@ -151,7 +153,7 @@ def train_and_save():
|
||||
|
||||
torch.save(actor.state_dict(), "a2c_pusher.pth")
|
||||
|
||||
# ——— Démonstration ———
|
||||
|
||||
def show(weights_path="a2c_pusher.pth"):
|
||||
env = gym.make("Pusher-v5", render_mode="human")
|
||||
actor = Actor(env.observation_space.shape[0], env.action_space.shape[0])
|
||||
|
||||
Reference in New Issue
Block a user