dlr eo: add LEARNING_RATE

This commit is contained in:
Starbeamrainbowlabs 2023-01-27 16:51:13 +00:00
parent fb898ea72b
commit f8202851a1
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 7 additions and 5 deletions

View file

@ -35,9 +35,9 @@ show_help() {
echo -e " WINDOW_SIZE=33 The window size to use when convolving the input dataset for single pixel prediction." >&2; echo -e " WINDOW_SIZE=33 The window size to use when convolving the input dataset for single pixel prediction." >&2;
echo -e " STEPS_PER_EPOCH The number of steps to consider an epoch. Defaults to None, which means use the entire dataset." >&2; echo -e " STEPS_PER_EPOCH The number of steps to consider an epoch. Defaults to None, which means use the entire dataset." >&2;
echo -e " EPOCHS=25 The number of epochs to train for." >&2; echo -e " EPOCHS=25 The number of epochs to train for." >&2;
echo -e " LEARNING_RATE The learning rate to use. Default: 0.001." >&2;
# echo -e " NO_REMOVE_ISOLATED_PIXELS Set to any value to avoid the engine from removing isolated pixels - that is, water pixels with no other surrounding pixels, either side to side to diagonally." >&2; # echo -e " NO_REMOVE_ISOLATED_PIXELS Set to any value to avoid the engine from removing isolated pixels - that is, water pixels with no other surrounding pixels, either side to side to diagonally." >&2;
# echo -e " PATH_CHECKPOINT The path to a checkcpoint to load. If specified, a model will be loaded instead of being trained." >&2; # echo -e " PATH_CHECKPOINT The path to a checkcpoint to load. If specified, a model will be loaded instead of being trained." >&2;
# echo -e " LEARNING_RATE The learning rate to use. Default: 0.001." >&2;
# echo -e " PREDICT_COUNT The number of items from the (SCRAMBLED) dataset to make a prediction for." >&2; # echo -e " PREDICT_COUNT The number of items from the (SCRAMBLED) dataset to make a prediction for." >&2;
echo -e " POSTFIX Postfix to append to the output dir (auto calculated)." >&2; echo -e " POSTFIX Postfix to append to the output dir (auto calculated)." >&2;
echo -e " ARGS Optional. Any additional arguments to pass to the python program." >&2; echo -e " ARGS Optional. Any additional arguments to pass to the python program." >&2;
@ -66,8 +66,8 @@ echo -e ">>> DIR_OUTPUT: ${DIR_OUTPUT}";
echo -e ">>> Additional args: ${ARGS}"; echo -e ">>> Additional args: ${ARGS}";
export PATH=$HOME/software/bin:$PATH; export PATH=$HOME/software/bin:$PATH;
export BATCH_SIZE DIRPATH_RAINFALLWATER PATH_HEIGHTMAP STEPS_PER_EPOCH DIRPATH_OUTPUT PATH_CHECKPOINT CHANNELS WINDOW_SIZE EPOCHS; export BATCH_SIZE DIRPATH_RAINFALLWATER PATH_HEIGHTMAP STEPS_PER_EPOCH DIRPATH_OUTPUT PATH_CHECKPOINT CHANNELS WINDOW_SIZE EPOCHS LEARNING_RATE;
#LOSS LEARNING_RATE; #LOSS ;
echo ">>> Installing requirements"; echo ">>> Installing requirements";
conda run -n py38 pip install -q -r requirements.txt; conda run -n py38 pip install -q -r requirements.txt;

View file

@ -22,10 +22,11 @@ DIRPATH_OUTPUT = os.environ["DIRPATH_OUTPUT"]
PATH_HEIGHTMAP = os.environ["PATH_HEIGHTMAP"] if "PATH_HEIGHTMAP" in os.environ else None PATH_HEIGHTMAP = os.environ["PATH_HEIGHTMAP"] if "PATH_HEIGHTMAP" in os.environ else None
CHANNELS = os.environ["CHANNELS"] if "CHANNELS" in os.environ else 8 CHANNELS = os.environ["CHANNELS"] if "CHANNELS" in os.environ else 8
EPOCHS = int(os.environ["EPOCHS"]) if "EPOCHS" in os.environ else 25 EPOCHS = int(os.environ["EPOCHS"]) if "EPOCHS" in os.environ else 25
BATCH_SIZE = int(os.environ["BATCH_SIZE"]) if "BATCH_SIZE" in os.environ else 64 BATCH_SIZE = int(os.environ["BATCH_SIZE"]) if "BATCH_SIZE" in os.environ else 64
WINDOW_SIZE = int(os.environ["WINDOW_SIZE"]) if "WINDOW_SIZE" in os.environ else 33 WINDOW_SIZE = int(os.environ["WINDOW_SIZE"]) if "WINDOW_SIZE" in os.environ else 33
STEPS_PER_EPOCH = int(os.environ["STEPS_PER_EPOCH"]) if "STEPS_PER_EPOCH" in os.environ else None STEPS_PER_EPOCH = int(os.environ["STEPS_PER_EPOCH"]) if "STEPS_PER_EPOCH" in os.environ else None
LEARNING_RATE = float(os.environ["LEARNING_RATE"]) if "LEARNING_RATE" in os.environ else 0.001
logger.info("Encoder-only rainfall radar TEST") logger.info("Encoder-only rainfall radar TEST")
logger.info(f"> DIRPATH_RAINFALLWATER {DIRPATH_RAINFALLWATER}") logger.info(f"> DIRPATH_RAINFALLWATER {DIRPATH_RAINFALLWATER}")
@ -35,6 +36,7 @@ logger.info(f"> CHANNELS {CHANNELS}")
logger.info(f"> BATCH_SIZE {BATCH_SIZE}") logger.info(f"> BATCH_SIZE {BATCH_SIZE}")
logger.info(f"> WINDOW_SIZE {WINDOW_SIZE}") logger.info(f"> WINDOW_SIZE {WINDOW_SIZE}")
logger.info(f"> STEPS_PER_EPOCH {STEPS_PER_EPOCH}") logger.info(f"> STEPS_PER_EPOCH {STEPS_PER_EPOCH}")
logger.info(f"> LEARNING_RATE {LEARNING_RATE}")
if not os.path.exists(DIRPATH_OUTPUT): if not os.path.exists(DIRPATH_OUTPUT):
@ -89,7 +91,7 @@ def make_encoderonly(windowsize, channels, encoder="convnext", water_bins=2, **k
raise Exception(f"Error: Unknown encoder '{encoder}' (known encoders: convnext, resnet).") raise Exception(f"Error: Unknown encoder '{encoder}' (known encoders: convnext, resnet).")
model.compile( model.compile(
optimizer="Adam", optimizer=tf.keras.optimizers.Adam(learning_rate=LEARNING_RATE),
loss = tf.keras.losses.SparseCategoricalCrossentropy(), loss = tf.keras.losses.SparseCategoricalCrossentropy(),
metrics = [ metrics = [
tf.keras.metrics.SparseCategoricalAccuracy() tf.keras.metrics.SparseCategoricalAccuracy()