deactivate tensorboard by default

This commit is contained in:
robcaulk 2023-05-14 14:39:23 +00:00
parent 55a1a3afd6
commit 340d2191ff
4 changed files with 20 additions and 27 deletions

View File

@ -68,11 +68,8 @@ class BaseReinforcementLearningModel(IFreqaiModel):
self.unset_outlier_removal()
self.net_arch = self.rl_config.get('net_arch', [128, 128])
self.dd.model_type = import_str
if self.activate_tensorboard:
self.tensorboard_callback: TensorboardCallback = \
TensorboardCallback(verbose=1, actions=BaseActions)
else:
self.tenorboard_callback = None
self.tensorboard_callback: TensorboardCallback = \
TensorboardCallback(verbose=1, actions=BaseActions)
def unset_outlier_removal(self):
"""
@ -159,10 +156,7 @@ class BaseReinforcementLearningModel(IFreqaiModel):
best_model_save_path=str(dk.data_path))
actions = self.train_env.get_actions()
if self.activate_tensorboard:
self.tensorboard_callback = TensorboardCallback(verbose=1, actions=actions)
else:
self.tensorboard_callback = None # type: ignore
self.tensorboard_callback = TensorboardCallback(verbose=1, actions=actions)
def pack_env_dict(self, pair: str) -> Dict[str, Any]:
"""

View File

@ -110,7 +110,7 @@ class IFreqaiModel(ABC):
if self.ft_params.get('principal_component_analysis', False) and self.continual_learning:
self.ft_params.update({'principal_component_analysis': False})
logger.warning('User tried to use PCA with continual learning. Deactivating PCA.')
self.activate_tensorboard: bool = self.freqai_info.get('activate_tensorboard', True)
self.activate_tensorboard: bool = self.freqai_info.get('activate_tensorboard', False)
record_params(config, self.full_path)

View File

@ -58,10 +58,14 @@ class ReinforcementLearner(BaseReinforcementLearningModel):
policy_kwargs = dict(activation_fn=th.nn.ReLU,
net_arch=self.net_arch)
if self.activate_tensorboard:
tb_path = Path(dk.full_path / "tensorboard" / dk.pair.split('/')[0])
else:
tb_path = None
if dk.pair not in self.dd.model_dictionary or not self.continual_learning:
model = self.MODELCLASS(self.policy_type, self.train_env, policy_kwargs=policy_kwargs,
tensorboard_log=Path(
dk.full_path / "tensorboard" / dk.pair.split('/')[0]),
tensorboard_log=tb_path,
**self.freqai_info.get('model_training_parameters', {})
)
else:
@ -70,14 +74,9 @@ class ReinforcementLearner(BaseReinforcementLearningModel):
model = self.dd.model_dictionary[dk.pair]
model.set_env(self.train_env)
callbacks = [self.eval_callback]
if self.activate_tensorboard:
callbacks.append(self.tensorboard_callback)
model.learn(
total_timesteps=int(total_timesteps),
callback=callbacks,
callback=[self.eval_callback, self.tensorboard_callback],
progress_bar=self.rl_config.get('progress_bar', False)
)

View File

@ -55,9 +55,9 @@ def test_extract_data_and_train_model_Standard(mocker, freqai_conf, model, pca,
can_run_model(model)
test_tb = True
if is_mac():
test_tb = False
# test_tb = True
# if is_mac():
# test_tb = False
model_save_ext = 'joblib'
freqai_conf.update({"freqaimodel": model})
@ -94,7 +94,7 @@ def test_extract_data_and_train_model_Standard(mocker, freqai_conf, model, pca,
strategy.freqai_info = freqai_conf.get("freqai", {})
freqai = strategy.freqai
freqai.live = True
freqai.activate_tensorboard = test_tb
# freqai.activate_tensorboard = test_tb
freqai.can_short = can_short
freqai.dk = FreqaiDataKitchen(freqai_conf)
freqai.dk.live = True
@ -233,7 +233,7 @@ def test_extract_data_and_train_model_Classifiers(mocker, freqai_conf, model):
("CatboostRegressor", 2, "freqai_test_strat"),
("PyTorchMLPRegressor", 2, "freqai_test_strat"),
("PyTorchTransformerRegressor", 2, "freqai_test_strat"),
("ReinforcementLearner", 3, "freqai_rl_test_strat"),
("ReinforcementLearner", 2, "freqai_rl_test_strat"),
("XGBoostClassifier", 2, "freqai_test_classifier"),
("LightGBMClassifier", 2, "freqai_test_classifier"),
("CatboostClassifier", 2, "freqai_test_classifier"),
@ -242,9 +242,9 @@ def test_extract_data_and_train_model_Classifiers(mocker, freqai_conf, model):
)
def test_start_backtesting(mocker, freqai_conf, model, num_files, strat, caplog):
can_run_model(model)
test_tb = True
if is_mac():
test_tb = False
# test_tb = True
# if is_mac():
# test_tb = False
freqai_conf.get("freqai", {}).update({"save_backtest_models": True})
freqai_conf['runmode'] = RunMode.BACKTEST
@ -277,7 +277,7 @@ def test_start_backtesting(mocker, freqai_conf, model, num_files, strat, caplog)
strategy.freqai_info = freqai_conf.get("freqai", {})
freqai = strategy.freqai
freqai.live = False
freqai.activate_tensorboard = test_tb
# freqai.activate_tensorboard = test_tb
freqai.dk = FreqaiDataKitchen(freqai_conf)
timerange = TimeRange.parse_timerange("20180110-20180130")
freqai.dd.load_all_pair_histories(timerange, freqai.dk)