Skip to content

Commit

Permalink
style: fix isort
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaiejj committed Apr 30, 2024
1 parent 7d8b236 commit c7c8398
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions omnisafe/adapter/crabs_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ def eval_policy( # pylint: disable=too-many-locals
"""
for _ in range(episode):
ep_ret, ep_cost, ep_len = 0.0, 0.0, 0
obs, _ = self._eval_env.reset()
obs, _ = self._eval_env.reset() # type: ignore
obs = obs.to(self._device)

done = False
while not done:
act = agent.step(obs, deterministic=False)
obs, reward, cost, terminated, truncated, info = self._eval_env.step(act)
obs, reward, cost, terminated, truncated, info = self._eval_env.step(act) # type: ignore
obs, reward, cost, terminated, truncated = (
torch.as_tensor(x, dtype=torch.float32, device=self._device)
for x in (obs, reward, cost, terminated, truncated)
Expand Down
10 changes: 5 additions & 5 deletions omnisafe/common/control_barrier_function/crabs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ def training_step(self, batch):
self.log(f'model/{i}/training_loss', loss.item())

opt = self.optimizers()
opt.zero_grad() # type: ignore
opt.zero_grad()

self.manual_backward(total_loss) # type: ignore
self.manual_backward(total_loss)
nn.utils.clip_grad_norm_(self.parameters(), 10)
opt.step() # type: ignore
opt.step()

def validation_step(self, batch):
"""Validation step of the ensemble model.
Expand Down Expand Up @@ -291,10 +291,10 @@ def training_step(self, batch):
self.log(f'{self.name}/training_loss', loss.item(), on_step=False, on_epoch=True)

opt = self.optimizers()
opt.zero_grad() # type: ignore
opt.zero_grad()
self.manual_backward(loss, opt)
nn.utils.clip_grad_norm_(self.parameters(), 10)
opt.step() # type: ignore
opt.step()

return {
'loss': loss.item(),
Expand Down

0 comments on commit c7c8398

Please sign in to comment.