示例#1
0
def test_get_activations_function(model: Model, batch: Tuple[np.ndarray,
                                                             np.ndarray]):
    X, y = batch
    get_activations = get_activations_function(model)
    *activations, y_hat = get_activations([X, 0])
    assert len(activations) == len(
        model.layers) - 2  # Without input and output layer
    batch, time, features = X.shape
    assert activations[0].shape == (batch, time, features, 1)
    assert activations[1].shape == (batch, time + 2 * 7, features, 1)
    assert activations[2].shape == (batch, time, 1, 64)
    assert all(activation.shape == (batch, time, 64)
               for activation in activations[3:])
    assert y_hat.shape == (2, 1477, 36)
示例#2
0
def layer_outputs(model: Model, batch: Tuple[np.ndarray,
                                             np.ndarray]) -> List[np.ndarray]:
    X, y = batch
    get_activations = get_activations_function(model)
    *activations, y_hat = get_activations([X, 0])
    return [X, *activations, y_hat]