Create custom_objects.py
Browse files- custom_objects.py +12 -0
custom_objects.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from tensorflow.keras.saving import register_keras_serializable
|
| 2 |
+
from tensorflow.keras import layers, models, backend as K
|
| 3 |
+
import tensorflow as tf
|
| 4 |
+
|
| 5 |
+
@register_keras_serializable()
|
| 6 |
+
def trust_activation(x):
|
| 7 |
+
return 0.5 + tf.sigmoid(x)
|
| 8 |
+
|
| 9 |
+
CUSTOM_OBJECTS = {
|
| 10 |
+
'trust_activation': trust_activation,
|
| 11 |
+
'mse': tf.keras.losses.MeanSquaredError()
|
| 12 |
+
}
|