Exemple #1
0
def random():
    """Seed all random number generators.

    Ensures repeatable tests.
    """
    with seed_random():
        yield
def test_reproducibility():
    results = []
    for _ in range(5):
        with seed_random():
            multinetwork = SimpleMultiNetwork()
            x = np.random.rand(13, 1)
            y = np.random.rand(13, 1)
            multinetwork.fit(x, y, model='forecaster', batch_size=1, epochs=1)
            loss = multinetwork.history[-1]['history']['loss'][-1]
        results.append(loss)
    assert min(results) == max(results)