tensorforce package

Subpackages

Submodules

tensorforce.exception module

exception tensorforce.exception.TensorForceError

Bases: exceptions.Exception

TensorForce error

__init__

x.init(…) initializes x; see help(type(x)) for signature

args
message

tensorforce.meta_parameter_recorder module

class tensorforce.meta_parameter_recorder.MetaParameterRecorder(current_frame)

Bases: object

Class to record MetaParameters as well as Summary/Description for TensorBoard (TEXT & FILE will come later).

General:

  • format_type: used to configure data conversion for TensorBoard=0, TEXT & JSON (not Implemented), etc
__init__(current_frame)

Init the MetaPrameterRecord with “Agent” parameters by passing inspect.currentframe() from Agent Class.

The Init will search back to find the parent class to capture all passed parameters and store them in “self.meta_params”.

NOTE: Currently only optimized for TensorBoard output.

TODO: Add JSON Export, TEXT EXPORT

Parameters:current_frame – Frame value from class to obtain metaparameters[= inspect.currentframe()]
build_metagraph_list()

Convert MetaParams into TF Summary Format and create summary_op.

Returns:Merged TF Op for TEXT summary elements, should only be executed once to reduce data duplication.
convert_data_to_string(data, indent=0, format_type=0, separator=None, eol=None)
convert_dictionary_to_string(data, indent=0, format_type=0, separator=None, eol=None)
convert_list_to_string(data, indent=0, format_type=0, eol=None, count=True)
convert_ndarray_to_md(data, format_type=0, eol=None)
merge_custom(custom_dict)
text_output(format_type=1)

tensorforce.util module

class tensorforce.util.SavableComponent

Bases: object

Component that can save and restore its own state.

__init__

x.init(…) initializes x; see help(type(x)) for signature

get_savable_variables()

Returns the list of all the variables this component is responsible to save and restore.

Returns:The list of variables that will be saved or restored.
register_saver_ops()

Registers the saver operations to the graph in context.

restore(sess, save_path)

Restores the values of the managed variables from disk location.

Parameters:
  • sess – The session for which to save the managed variables.
  • save_path – The path used to save the data to.
save(sess, save_path, timestep=None)

Saves this component’s managed variables.

Parameters:
  • sess – The session for which to save the managed variables.
  • save_path – The path to save data to.
  • timestep – Optional, the timestep to append to the file name.
Returns:

Checkpoint path where the model was saved.

tensorforce.util.get_object(obj, predefined_objects=None, default_object=None, kwargs=None)

Utility method to map some kind of object specification to its content, e.g. optimizer or baseline specifications to the respective classes.

Parameters:
  • obj – A specification dict (value for key ‘type’ optionally specifies the object, options as follows), a module path (e.g., my_module.MyClass), a key in predefined_objects, or a callable (e.g., the class type object).
  • predefined_objects – Dict containing predefined set of objects, accessible via their key
  • default_object – Default object is no other is specified
  • kwargs – Arguments for object creation

Returns: The retrieved object

tensorforce.util.map_tensors(fn, tensors)
tensorforce.util.np_dtype(dtype)

Translates dtype specifications in configurations to numpy data types. :param dtype: String describing a numerical type (e.g. ‘float’) or numerical type primitive.

Returns: Numpy data type

tensorforce.util.prepare_kwargs(raw, string_parameter='name')

Utility method to convert raw string/diction input into a dictionary to pass into a function. Always returns a dictionary.

Parameters:raw – string or dictionary, string is assumed to be the name of the activation activation function. Dictionary will be passed through unchanged.

Returns: kwargs dictionary for **kwargs

tensorforce.util.prod(xs)

Computes the product along the elements in an iterable. Returns 1 for empty iterable.

Parameters:xs – Iterable containing numbers.

Returns: Product along iterable.

tensorforce.util.rank(x)
tensorforce.util.shape(x, unknown=-1)
tensorforce.util.strip_name_scope(name, base_scope)
tensorforce.util.tf_dtype(dtype)

Translates dtype specifications in configurations to tensorflow data types.

Parameters:dtype – String describing a numerical type (e.g. ‘float’), numpy data type, or numerical type primitive.

Returns: TensorFlow data type

Module contents

exception tensorforce.TensorForceError

Bases: exceptions.Exception

TensorForce error

__init__

x.init(…) initializes x; see help(type(x)) for signature

args
message