-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Shubham Jha
committed
Jun 20, 2020
1 parent
974d52d
commit e6b2cb3
Showing
7 changed files
with
65 additions
and
23 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
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,4 +1,5 @@ | ||
from .base_action_space import BaseActionSpace | ||
from .base_agent import BaseAgent | ||
from .base_environment import BaseEnvironment | ||
from .base_trainer import BaseTrainer | ||
from .base_trainer import BaseTrainer | ||
from .metrics import Metrics |
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
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,11 +1,17 @@ | ||
from collections import defaultdict | ||
|
||
|
||
class BaseTrainer: | ||
def __init__(self, params): | ||
def __init__(self, params, agent, environment, metrics): | ||
self.metrics = metrics | ||
self.agent = agent | ||
self.environment = environment | ||
|
||
self.global_step = 0 | ||
self.episodes = params.get("episodes", 10); | ||
self.steps = params.get("steps", 100) | ||
|
||
def do_step(self): | ||
pass | ||
|
||
def train(self): | ||
pass | ||
|
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import logging | ||
from collections import defaultdict | ||
|
||
|
||
class Metrics: | ||
def __init__(self, logger_name, log_level, comet_experiment=None): | ||
self.metrics_dict = defaultdict(defaultdict(dict)) | ||
self.comet_experiment = comet_experiment | ||
self.logger = logging.get_logger(logger_name) | ||
self.logger.setLevel() # TODO | ||
# TODO: initialize logger, take log_level as input | ||
|
||
def log_metric(self, metric_name, metric_val, log_step, namespace="default"): | ||
self.metrics_dict[namespace][log_step][metric_name] = metric_val | ||
self.logger.info("STEP {}:{}:{}".format(log_step, metric_name, metric_val)) | ||
# TODO: add timestamp | ||
|
||
if self.comet_experiment is not None: | ||
self.comet_experiment.log_metric(metric_name, metric_val, step=log_step) | ||
|
||
# TODO: Log metric using logger |
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
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