Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialize custom layer and test with mlflow #39

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions mlpp_lib/models.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import tensorflow as tf
import logging
from typing import Optional, Union, Any

import numpy as np
import tensorflow as tf
from tensorflow.keras.layers import (
Add,
Dense,
Dropout,
BatchNormalization,
Activation,
)

from tensorflow.keras import Model, initializers

from mlpp_lib.physical_layers import *
from mlpp_lib.probabilistic_layers import *

import numpy as np

try:
import tcn # type: ignore
except ImportError:
Expand All @@ -24,6 +23,10 @@
TCN_IMPORTED = True


_LOGGER = logging.getLogger(__name__)


@tf.keras.utils.register_keras_serializable()
class MonteCarloDropout(Dropout):
def call(self, inputs):
return super().call(inputs, training=True)
Expand All @@ -39,6 +42,9 @@ def _build_fcn_block(
skip_connection,
idx=0,
):
if mc_dropout and dropout is None:
_LOGGER.warning("dropout=None, hence I will ignore mc_dropout=True")

x = inputs
for i, units in enumerate(hidden_layers):
x = Dense(units, name=f"dense_{idx}_{i}")(x)
Expand Down
Loading