How to use the yarl.spaces.Continuous function in yarl

To help you get started, we’ve selected a few yarl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rlgraph / rlgraph / examples / _end_to_end_example.py View on Github external
# TODO:Sven will check: This can probably be done smarter using Space classes?
def get_feed_dict(feed_dict, complex_sample, placeholders):
    if isinstance(complex_sample, dict):
        for k in complex_sample:
            get_feed_dict(feed_dict, complex_sample[k], placeholders[k])
    elif isinstance(complex_sample, tuple):
        for sam, ph in zip(complex_sample, placeholders):
            get_feed_dict(feed_dict, sam, ph)
    else:
        feed_dict[placeholders] = complex_sample


with tf.Session() as sess:
    # Create a messed up, complex Space:
    input_space = Dict(a=Tuple(Continuous(shape=(2,2,3)), Continuous(shape=(3,3,3))),
                       b=Dict(c=Continuous(shape=(1,1,3))))
    print(autograph.to_code(computation_gray))
    # Only needs be done once upon Computation object creation:
    computation_gray_autographd = autograph.to_graph(computation_gray, verbose=True)
    # This is now very cool with Spaces.
    input_ = input_space.get_tensor_variable(name="placeholder")
    # input_ is now a native dict that corresponds to the structure of input_space.

    # Let the wrapper do everything.
    # The wrapper will live in Component.py and should not need to be overwritten ever (I think).
    # We can call it something else, but component will use it all under the hood, automatically.
    gray_ops = generic_wrapper(precomputation_gray, computation_gray_autographd, input_)

    # Test the pipeline.
    sample = input_space.sample()
    feed_dict = {}
    get_feed_dict(feed_dict, sample, input_)
github rlgraph / rlgraph / examples / _end_to_end_example.py View on Github external
# TODO:Sven will check: This can probably be done smarter using Space classes?
def get_feed_dict(feed_dict, complex_sample, placeholders):
    if isinstance(complex_sample, dict):
        for k in complex_sample:
            get_feed_dict(feed_dict, complex_sample[k], placeholders[k])
    elif isinstance(complex_sample, tuple):
        for sam, ph in zip(complex_sample, placeholders):
            get_feed_dict(feed_dict, sam, ph)
    else:
        feed_dict[placeholders] = complex_sample


with tf.Session() as sess:
    # Create a messed up, complex Space:
    input_space = Dict(a=Tuple(Continuous(shape=(2,2,3)), Continuous(shape=(3,3,3))),
                       b=Dict(c=Continuous(shape=(1,1,3))))
    print(autograph.to_code(computation_gray))
    # Only needs be done once upon Computation object creation:
    computation_gray_autographd = autograph.to_graph(computation_gray, verbose=True)
    # This is now very cool with Spaces.
    input_ = input_space.get_tensor_variable(name="placeholder")
    # input_ is now a native dict that corresponds to the structure of input_space.

    # Let the wrapper do everything.
    # The wrapper will live in Component.py and should not need to be overwritten ever (I think).
    # We can call it something else, but component will use it all under the hood, automatically.
    gray_ops = generic_wrapper(precomputation_gray, computation_gray_autographd, input_)

    # Test the pipeline.
    sample = input_space.sample()
    feed_dict = {}