def save_mock_data(cache: SummaryCache):
    i = 1
    for j in range(500):
        cache.store(reward=(1 - np.exp(i)) + 0.1 * np.random.rand(),
                    activations=np.random.normal(5, 0.5),
                    actions=np.random.normal(50, 0.5),
                    scalar=np.random.rand(1)[0],
                    uneven_length=np.array([1] * np.random.randint(0, 5)))
Beispiel #2
0
def test_single_key():
    print_helper = PrintHelper()
    cache = SummaryCache(mode='tiled')
    print()
    for i in range(10):
        save_mock_data(cache)
        mean_reward = cache.get("reward").mean()
        assert isinstance(mean_reward, float)
def save_mock_data(cache: SummaryCache):
    i = 1
    for j in range(500):
        cache.store(
            reward=(1 - np.exp(i)) + 0.1 * np.random.rand(),
            activations=np.random.normal(5, 0.5),
            actions=np.random.normal(50, 0.5),
        )
Beispiel #4
0
def test_summary_cache():
    print_helper = PrintHelper()
    cache = SummaryCache(mode='tiled')
    print()
    for i in range(10):
        save_mock_data(cache)
        stats = cache.summary_stats(reward="mean",
                                    activations="quantile",
                                    actions="histogram")
        s = print_helper.format_tabular(stats)
Beispiel #5
0
def test_repr():
    print_helper = PrintHelper()
    cache = SummaryCache(mode='tiled')
    print()
    for i in range(10):
        save_mock_data(cache)
        stats = cache.summary_stats(reward="mean",
                                    activations="quantile",
                                    actions="histogram")
        # s = print_helper.format_tabular(stats)
        # s = print_helper.format_row_table(stats)
        # print(s)

    np.mean(cache.get('reward'))
    from textwrap import dedent
    assert str(cache) == dedent("""
    SummaryCache:  reward: Shape()[:5000]
      activations: [5.370795870404581, 4.241508632737578][:5000]
      actions: [50.77645686095641, 49.56686189467056][:5000]
      scalar: Shape()[:5000]
      uneven_length: Shape(1,)[:5000]
    """)[1:]