From 654eefd9ca284ef78ebab2d5315f9fa8a33974bc Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Wed, 31 Aug 2022 18:03:39 +0100 Subject: [PATCH] properly handle water dimensions; add log files to .gitignore TODO: add heightmap --- .gitignore | 3 +++ aimodel/slurm-pretrain.job | 4 ++-- aimodel/src/lib/ai/model_rainfallwater_contrastive.py | 7 +++++-- aimodel/src/lib/dataset/dataset.py | 3 +++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index ebbac55..90cdd97 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +*.err +*.out +*.log output # Created by https://www.toptal.com/developers/gitignore/api/python,node,git,visualstudiocode # Edit at https://www.toptal.com/developers/gitignore?templates=python,node,git,visualstudiocode diff --git a/aimodel/slurm-pretrain.job b/aimodel/slurm-pretrain.job index b559e0a..6380206 100755 --- a/aimodel/slurm-pretrain.job +++ b/aimodel/slurm-pretrain.job @@ -3,8 +3,8 @@ #SBATCH -N 1 #SBATCH -n 4 #SBATCH --gres=gpu:1 -#SBATCH -o %j.%N.%a.out -#SBATCH -e %j.%N.%a.err +#SBATCH -o %j.%N.%a.out.log +#SBATCH -e %j.%N.%a.err.log #SBATCH -p gpu05 #SBATCH --time=5-00:00:00 #SBATCH --exclusive diff --git a/aimodel/src/lib/ai/model_rainfallwater_contrastive.py b/aimodel/src/lib/ai/model_rainfallwater_contrastive.py index f7af3a7..f32fd51 100644 --- a/aimodel/src/lib/ai/model_rainfallwater_contrastive.py +++ b/aimodel/src/lib/ai/model_rainfallwater_contrastive.py @@ -9,8 +9,11 @@ from .components.LossContrastive import LossContrastive def model_rainfallwater_contrastive(shape_rainfall, shape_water, feature_dim=200): logger.info(shape_rainfall) logger.info(shape_water) - rainfall_width, rainfall_height, rainfall_channels = shape_rainfall - water_width, water_height, water_channels = shape_water + + # Shapes come from what rainfallwrangler sees them as, but we add an extra dimension when reading the .tfrecord file + rainfall_width, rainfall_height, rainfall_channels = shape_rainfall # shape = [width, height, channels] + water_width, water_height = shape_water # shape = [width, height] + water_channels = 1 # added in dataset → make_dataset → parse_item input_rainfall = tf.keras.layers.Input( shape=shape_rainfall diff --git a/aimodel/src/lib/dataset/dataset.py b/aimodel/src/lib/dataset/dataset.py index 3fac94d..1435e7c 100644 --- a/aimodel/src/lib/dataset/dataset.py +++ b/aimodel/src/lib/dataset/dataset.py @@ -20,6 +20,9 @@ def parse_item(item): rainfall = tf.io.parse_tensor(parsed["rainfallradar"], out_type=tf.float32) water = tf.io.parse_tensor(parsed["waterdepth"], out_type=tf.float32) + # [width, height] → [width, height, channels] + water = tf.expand_dims(water, axis=-1) + # TODO: The shape of the resulting tensor can't be statically determined, so we need to reshape here # TODO: Any other additional parsing here, since multiple .map() calls are not optimal