Ejemplo n.º 1
0
def __model_fn(
    window_size: int,
    hidden_size: int,
    dropout: float = 0.0,
    pos_weight: float = 1.0,
    metrics_fn: Callable[[], List[tf.keras.metrics.Metric]] = lambda: []
) -> tff.learning.Model:
    return tff.learning.from_keras_model(
        keras_model=models.bidirectional(window_size, len(data.SENSORS),
                                         hidden_size, dropout),
        loss=losses.WeightedBinaryCrossEntropy(pos_weight),
        input_spec=(tf.TensorSpec((None, window_size, len(data.SENSORS)),
                                  dtype=tf.float32),
                    tf.TensorSpec((None, 1), dtype=tf.float32)),
        metrics=metrics_fn())
Ejemplo n.º 2
0
def __model_fn(window_size: int, hidden_size: int,
               dropout: float) -> tf.keras.Model:
    return models.bidirectional(window_size, len(SENSORS), hidden_size,
                                dropout)