ClimateNet
Collection
A family of models to predict natural disasters
•
2 items
•
Updated
This model requires the following custom objects to be loaded with it:
import tensorflow as tf
from tensorflow.keras.saving import register_keras_serializable
from tensorflow.keras import layers, models, backend as K
import numpy as np
@register_keras_serializable()
def cold_temp_penalty(inputs):
temp = inputs[:, 0]
penalty = tf.where(
temp > 295.0,
1.0,
tf.where(
temp < 290.0,
0.0,
(temp - 290.0) / 5.0
)
)
return penalty[:, None]
@register_keras_serializable()
def fire_risk_booster(inputs):
temp = inputs[:, 0]
humidity = inputs[:, 1]
wind = inputs[:, 2]
veg = inputs[:, 3]
# Boost ranges
temp_boost = tf.sigmoid((temp - 305.0) * 1.2)
humidity_boost = tf.sigmoid((20.0 - humidity) * 0.5)
wind_boost = tf.sigmoid((wind - 15.0) * 0.8)
veg_boost = tf.sigmoid((veg - 70.0) * 0.5)
# Combine and scale
combined = temp_boost * humidity_boost * wind_boost * veg_boost
boost = 1.0 + 0.3 * combined # Up to 30% increase in fire score
return boost[:, None]
@register_keras_serializable()
def fire_suppression_mask(inputs):
temp = inputs[:, 0]
humidity = inputs[:, 1]
wind = inputs[:, 2]
# Suppress if warm but humid and still
temp_flag = tf.sigmoid((temp - 293.0) * 1.2)
humid_flag = tf.sigmoid((humidity - 50.0) * 0.4)
wind_flag = 1 - tf.sigmoid((wind - 5.0) * 0.8)
suppression = temp_flag * humid_flag * wind_flag
penalty = 1.0 - 0.3 * suppression # Max 30% suppression
return penalty[:, None]