reformat code

This commit is contained in:
Yinon Polak 2023-03-06 17:50:02 +02:00
parent 348a08f1c4
commit e6e747bcd8
2 changed files with 16 additions and 14 deletions

View File

@ -69,7 +69,7 @@ class PyTorchModelTrainer:
self.model.eval() self.model.eval()
epochs = self.calc_n_epochs( epochs = self.calc_n_epochs(
n_obs=len(data_dictionary[f'test_features']), n_obs=len(data_dictionary['test_features']),
batch_size=self.batch_size, batch_size=self.batch_size,
n_iters=self.eval_iters n_iters=self.eval_iters
) )
@ -101,8 +101,11 @@ class PyTorchModelTrainer:
torch.from_numpy(data_dictionary[f'{split}_features'].values).float(), torch.from_numpy(data_dictionary[f'{split}_features'].values).float(),
torch.from_numpy(data_dictionary[f'{split}_labels'].astype(float).values) torch.from_numpy(data_dictionary[f'{split}_labels'].astype(float).values)
.long() .long()
.view(labels_view) # todo currently assuming class labels are strings ['0.0', '1.0' .. n_classes]. need to resolve it per ClassifierModel .view(labels_view)
) )
# todo currently assuming class labels are strings ['0.0', '1.0' .. n_classes].
# need to resolve it per ClassifierModel
data_loader = DataLoader( data_loader = DataLoader(
dataset, dataset,
batch_size=self.batch_size, batch_size=self.batch_size,

View File

@ -24,7 +24,6 @@ from freqtrade.exceptions import OperationalException
from freqtrade.freqai.data_kitchen import FreqaiDataKitchen from freqtrade.freqai.data_kitchen import FreqaiDataKitchen
from freqtrade.strategy.interface import IStrategy from freqtrade.strategy.interface import IStrategy
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -446,9 +445,9 @@ class FreqaiDataDrawer:
dump(model, save_path / f"{dk.model_filename}_model.joblib") dump(model, save_path / f"{dk.model_filename}_model.joblib")
elif self.model_type == 'keras': elif self.model_type == 'keras':
model.save(save_path / f"{dk.model_filename}_model.h5") model.save(save_path / f"{dk.model_filename}_model.h5")
elif 'stable_baselines' in self.model_type or\ elif ('stable_baselines' in self.model_type or
'sb3_contrib' == self.model_type or\ 'sb3_contrib' == self.model_type or
'pytorch' == self.model_type: 'pytorch' == self.model_type):
model.save(save_path / f"{dk.model_filename}_model.zip") model.save(save_path / f"{dk.model_filename}_model.zip")
if dk.svm_model is not None: if dk.svm_model is not None: