Skip to content

Instantly share code, notes, and snippets.

@ntakouris
Created September 19, 2020 09:36
Show Gist options
  • Save ntakouris/64a8fc717bc370fe7e2472b4d77c5b97 to your computer and use it in GitHub Desktop.
Save ntakouris/64a8fc717bc370fe7e2472b4d77c5b97 to your computer and use it in GitHub Desktop.
import tensorflow as tf
import kerastuner
TRAIN_STEPS = 1000
EVAL_STEPS = 100
BATCH_SIZE = 128
INPUT_WINDOW_SIZE = 7
OUTPUT_WINDOW_SIZE = 1
# === Feature Directory ===
DENSE_FLOAT_FEATURE_KEYS = ['a', 'b', 'c', 'd', 'e']
# === Feature Selection ===
FEATURE_KEYS = DENSE_FLOAT_FEATURE_KEYS # feature inputs for model
PREDICT_FEATURE_KEYS = FEATURE_KEYS # features that model predicts (if equal to feature_keys it can predict multiple timesteps ahead)
INPUT_FEATURE_KEYS = list(set(FEATURE_KEYS + PREDICT_FEATURE_KEYS))
# === Hyperparameters ===
HP_LR = 'learning_rate'
HP_HIDDEN_LAYER_NUM = 'hidden_layer_num'
HP_HIDDEN_LATENT_DIM = 'hidden_latent_dim'
HP_PRE_OUTPUT_UNITS = 'pre_output_units'
def _get_hyperparameters() -> kerastuner.HyperParameters:
hp = kerastuner.HyperParameters()
# todo: move string value definitions to constants
hp.Fixed(HP_LR, 1e-2)
hp.Fixed(HP_HIDDEN_LAYER_NUM, 1)
hp.Fixed(HP_HIDDEN_LATENT_DIM, 64)
#hp.Choice('dropout', [0.2, 0.3, 0.5], default=0.2)
hp.Fixed(HP_PRE_OUTPUT_UNITS, 32)
return hp
HYPERPARAMETERS = _get_hyperparameters()
HYPERPARAM_NUM_STEPS = 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment