mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-14 20:23:57 +00:00
add documentation for CNN, allow it to interact with model_training_parameters
This commit is contained in:
parent
9ce8255f24
commit
665eed3906
|
@ -242,3 +242,23 @@ If you want to predict multiple targets you must specify all labels in the same
|
|||
df['&s-up_or_down'] = np.where( df["close"].shift(-100) > df["close"], 'up', 'down')
|
||||
df['&s-up_or_down'] = np.where( df["close"].shift(-100) == df["close"], 'same', df['&s-up_or_down'])
|
||||
```
|
||||
|
||||
### Convolutional Neural Network model
|
||||
|
||||
The `CNNPredictionModel` is a non-linear regression based on `Tensorflow` which follows very similar configuration to the other regressors. Feature engineering and label creation remains the same as highlighted [here](#building-a-freqai-strategy) and [here](#setting-model-targets). Control of the model is focused in the `model_training_parameters` configuration dictionary, which accepts any hyperparameter available to the CNN `fit()` function of Tensorflow [more here](https://www.tensorflow.org/api_docs/python/tf/keras/Model#fit). For example, this is where the `epochs` and `batch_size` are controlled:
|
||||
|
||||
```json
|
||||
"model_training_parameters" : {
|
||||
"batch_size": 64,
|
||||
"epochs": 10,
|
||||
"verbose": "auto",
|
||||
"shuffle": false
|
||||
"workers": 1,
|
||||
"use_multiprocessing": False
|
||||
}
|
||||
```
|
||||
|
||||
Running the `CNNPredictionModel` is the same as other regressors: `--freqaimodel CNNPredictionModel`.
|
||||
|
||||
|
||||
```
|
|
@ -17,8 +17,6 @@ logger = logging.getLogger(__name__)
|
|||
# tf.config.run_functions_eagerly(True)
|
||||
# tf.data.experimental.enable_debug_mode()
|
||||
|
||||
MAX_EPOCHS = 10
|
||||
|
||||
|
||||
class CNNPredictionModel(BaseTensorFlowModel):
|
||||
"""
|
||||
|
@ -46,7 +44,12 @@ class CNNPredictionModel(BaseTensorFlowModel):
|
|||
)
|
||||
|
||||
n_features = len(data_dictionary["train_features"].columns)
|
||||
BATCH_SIZE = self.freqai_info.get("batch_size", 64)
|
||||
BATCH_SIZE = self.model_training_parameters.get("batch_size", 64)
|
||||
|
||||
# we need to remove batch_size from the model_training_params because
|
||||
# we dont want fit() to get the incorrect assignment (we use the WindowGenerator)
|
||||
# to handle our batches.
|
||||
self.model_training_parameters.pop('batch_size')
|
||||
input_dims = [BATCH_SIZE, self.CONV_WIDTH, n_features]
|
||||
|
||||
w1 = WindowGenerator(
|
||||
|
@ -84,8 +87,7 @@ class CNNPredictionModel(BaseTensorFlowModel):
|
|||
|
||||
model.fit(
|
||||
w1.train,
|
||||
epochs=MAX_EPOCHS,
|
||||
shuffle=False,
|
||||
**self.model_training_parameters,
|
||||
validation_data=val_data,
|
||||
callbacks=[early_stopping],
|
||||
verbose=1,
|
||||
|
|
Loading…
Reference in New Issue
Block a user