mirror of
https://github.com/sbrl/research-rainfallradar
synced 2024-11-04 17:13:02 +00:00
dlr CHANGE: properly normalise the heightmap
This commit is contained in:
parent
8e76ac2864
commit
f25d1b5b1a
1 changed files with 5 additions and 4 deletions
|
@ -40,10 +40,11 @@ def parse_item(metadata, output_size=100, input_size="same", water_threshold=0.1
|
||||||
|
|
||||||
if heightmap is not None:
|
if heightmap is not None:
|
||||||
heightmap = tf.expand_dims(heightmap, axis=-1)
|
heightmap = tf.expand_dims(heightmap, axis=-1)
|
||||||
# NORMALLY, this wouldn't work 'cause you'd need to know the max of ALL frames, but here we only have a single frame.
|
norm = tf.keras.layers.Normalization(axis=None)
|
||||||
heightmap_max = tf.math.reduce_max(heightmap)
|
norm.adapt(heightmap)
|
||||||
heightmap_min = tf.math.reduce_min(tf.where(tf.math.less(heightmap, -500), heightmap, tf.fill(heightmap.shape, 0.0)))
|
# THIS IS (probably) OK, because BatchNorm also outputs mean=0 stddev=1, bias term shifts anyway
|
||||||
heightmap = (heightmap - heightmap_min) / heightmap_max
|
# Ref https://datascience.stackexchange.com/a/54383/86851
|
||||||
|
heightmap = norm(heightmap)
|
||||||
heightmap = tf.transpose(heightmap, [1, 0, 2]) # [width, height] → [height, width]
|
heightmap = tf.transpose(heightmap, [1, 0, 2]) # [width, height] → [height, width]
|
||||||
|
|
||||||
def parse_item_inner(item):
|
def parse_item_inner(item):
|
||||||
|
|
Loading…
Reference in a new issue