forked from taochenshh/easyrl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request taochenshh#2 from taochenshh/sac
Sac
- Loading branch information
Showing
46 changed files
with
2,454 additions
and
537 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,23 @@ | ||
from dataclasses import dataclass | ||
import gym | ||
from easyrl.envs.vec_normalize import VecNormalize | ||
from easyrl.utils.gym_util import save_vec_normalized_env | ||
from easyrl.utils.gym_util import load_vec_normalized_env | ||
|
||
@dataclass | ||
class BaseAgent: | ||
env: gym.Env | ||
|
||
def get_action(self, ob, sample=True, **kwargs): | ||
raise NotImplementedError | ||
|
||
def optimize(self, data, **kwargs): | ||
raise NotImplementedError | ||
|
||
def save_env(self, save_dir): | ||
if isinstance(self.env, VecNormalize): | ||
save_vec_normalized_env(self.env, save_dir) | ||
|
||
def load_env(self, save_dir): | ||
if isinstance(self.env, VecNormalize): | ||
load_vec_normalized_env(self.env, save_dir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.