--- title: Architectures keywords: fastai sidebar: home_sidebar summary: "Classes to create hierachy architectures from array configurations." description: "Classes to create hierachy architectures from array configurations." nb_path: "nbs/08_architectures.ipynb" ---
{% raw %}
{% endraw %} {% raw %}
%load_ext autoreload
%autoreload 2
{% endraw %} {% raw %}
/home/ruperty/anaconda3/envs/dev37/lib/python3.7/site-packages/ipykernel/ipkernel.py:287: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.
  and should_run_async(code)
{% endraw %} {% raw %}
{% endraw %} {% raw %}

class BaseArchitecture[source]

BaseArchitecture(name=None, config=None, env=None, inputs=None, history=None, error_collector=None, namespace=None) :: ABC

Base class of an array architecture. This class is not used direclty by developers, but defines the functionality common to all.

{% endraw %} {% raw %}
/home/ruperty/anaconda3/envs/dev37/lib/python3.7/site-packages/ipykernel/ipkernel.py:287: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.
  and should_run_async(code)
{% endraw %} {% raw %}

class ProportionalArchitecture[source]

ProportionalArchitecture(name='proportional', config=None, env=None, input_indexes=None, history=False, error_collector=None, namespace=None, **cargs) :: BaseArchitecture

Proportional Architecture

{% endraw %} {% raw %}
{% endraw %} {% raw %}

class DynamicArchitecture[source]

DynamicArchitecture(name='dynamic', structure=None, config=None, env=None, input_indexes=None, inputs_names=None, top_input_indexes=None, history=False, error_collector=None, suffixes=False, namespace=None, **cargs) :: BaseArchitecture

Dynamic Architecture

{% endraw %} {% raw %}
{% endraw %} {% raw %}

run_from_properties_file[source]

run_from_properties_file(root_dir='.', path='.', file=None, nevals=None, runs=500, history=True, verbose=False, test=False, move=None, draw=False, plots_figsize=(15, 4), render=True, layout=None, early_termination=False, plots=None, seed=None, print_properties=False, figsize=(12, 12), summary=False, hpct_verbose=None, error_collector_type=None, error_response_type=None)

{% endraw %} {% raw %}
{% endraw %} {% raw %}

load_properties[source]

load_properties(root_dir=None, file_path=None, file_name=None, nevals=None, seed=None, print_properties=False, gens=None, pop_size=None, evolve=False)

{% endraw %} {% raw %}
{% endraw %} {% raw %}

setup_environment[source]

setup_environment(properties, render=False, seed=None, early_termination=None, error_collector_type=None, error_response_type=None)

{% endraw %} {% raw %}
{% endraw %} {% raw %}

create_hierarchy[source]

create_hierarchy(env, error_collector, properties, history=False, suffixes=False)

{% endraw %} {% raw %}
{% endraw %} {% raw %}
from pct.environments import VelocityModel
from pct.structure import ArchitectureStructure
from pct.functions import IndexedParameter
from pct.hierarchy import PCTHierarchy
from pct.structure import LevelKey
from pct.nodes import PCTNode

env = VelocityModel(name='VModel')
namespace=env.namespace
inputs=[2]
structure = ArchitectureStructure()
config = {'parameters': {}, 'level0': [[[1.0864011617580416, -1.0342161642584196], [-8.899524671308557, -8.976856229389936]], [-0.7295091920311653, -4.460573287694404], [0, 0], [[-4.146713118740296, 1.2794655139677662]]]}
pa = DynamicArchitecture(structure=structure, config=config, env=env, input_indexes=inputs, namespace=namespace) #, error_collector=te)

pa()
#hpct = pa.get_hierarchy()
#hpct.summary()
#move={'VModel': [-0.2, -0.3],'Input0': [-0.3, 0],'OL0C0ws': [-0.4, 0],'OL0C1ws': [0.6, 0]}
#hpct.draw(move=move, with_edge_labels=True, figsize=(14,14))
{% endraw %} {% raw %}
from pct.environments import Pendulum
from pct.functions import Constant

pen = Pendulum(name='Pendulum',render=True)
namespace = pen.namespace
#print(namespace)
inputs=[2, 3]
config = {'level0': [[[0, 0, 1], [0, 0, 1]], [74.7727669099358, 37.42447782017047, 70.45900090605967], [[1, 0, 1]]], 'level1': [[[1, 0, 1], [1, 1, 1]], [0.028281504070566288, 0.29618653732851286], [[-49.05302284318027, 46.949638698585005], [-96.63198831250754, -29.78373183094591], [-3.8249493797145107, -60.95121501461629]]], 'level2': [[[1, 0], [0, 1]], [0.633350421196448, 0.5607290603484817], [[41.217164164869104, -76.70635343790484], [83.21744682425535, -96.9311066757899]], [1, 2]], 'parameters': {}}
for key in config.keys():
    print(key, config[key])
pa = ProportionalArchitecture(config=config, env=pen, input_indexes=inputs, namespace=namespace)
pa()
hpct = pa.get_hierarchy()
hpct.draw(move={'Pendulum': [-0.2, -0.3],'Input0': [-0.3, 0], 'Input1': [0.3, 0]})
/home/ruperty/anaconda3/envs/dev37/lib/python3.7/site-packages/gym/core.py:173: DeprecationWarning: WARN: Function `env.seed(seed)` is marked as deprecated and will be removed in the future. Please use `env.reset(seed=seed) instead.
  "Function `env.seed(seed)` is marked as deprecated and will be removed in the future. "
level0 [[[0, 0, 1], [0, 0, 1]], [74.7727669099358, 37.42447782017047, 70.45900090605967], [[1, 0, 1]]]
level1 [[[1, 0, 1], [1, 1, 1]], [0.028281504070566288, 0.29618653732851286], [[-49.05302284318027, 46.949638698585005], [-96.63198831250754, -29.78373183094591], [-3.8249493797145107, -60.95121501461629]]]
level2 [[[1, 0], [0, 1]], [0.633350421196448, 0.5607290603484817], [[41.217164164869104, -76.70635343790484], [83.21744682425535, -96.9311066757899]], [1, 2]]
parameters {}
/home/ruperty/anaconda3/envs/dev37/lib/python3.7/site-packages/matplotlib/backend_bases.py:57: DeprecationWarning: PILLOW_VERSION is deprecated and will be removed in Pillow 9 (2022-01-02). Use __version__ instead.
  from PIL import PILLOW_VERSION
{% endraw %} {% raw %}
pen = Pendulum(name='Pendulum',render=True)
namespace = pen.namespace
inputs=[2, 3]
config = {'level0': [[[0], [0]], [60.92750637861888], [[1]]], 'level1': [[[1], [1]], [0.8221926728404025, 0.5936199577845901], [[2.941087338758976, -68.59700733589955]], [1, 2]], 'parameters': {}}
for key in config.keys():
    print(key, config[key])
pa = ProportionalArchitecture(config=config, env=pen, input_indexes=inputs, namespace = namespace)
pa()
hpct = pa.get_hierarchy()
hpct.draw(move={'Pendulum': [-0.2, -0.3],'Input0': [-0.3, 0], 'Input1': [0.3, 0]})
/home/ruperty/anaconda3/envs/dev37/lib/python3.7/site-packages/ipykernel/ipkernel.py:287: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.
  and should_run_async(code)
/home/ruperty/anaconda3/envs/dev37/lib/python3.7/site-packages/gym/core.py:173: DeprecationWarning: WARN: Function `env.seed(seed)` is marked as deprecated and will be removed in the future. Please use `env.reset(seed=seed) instead.
  "Function `env.seed(seed)` is marked as deprecated and will be removed in the future. "
level0 [[[0], [0]], [60.92750637861888], [[1]]]
level1 [[[1], [1]], [0.8221926728404025, 0.5936199577845901], [[2.941087338758976, -68.59700733589955]], [1, 2]]
parameters {}
{% endraw %} {% raw %}
pen = Pendulum(name='Pendulum',render=True)
namespace = pen.namespace
inputs=[2]
config = {'level0': [[[1]], [62.82423385532463], [[0]], [1]], 'parameters': {}}
for key in config.keys():
    print(key, config[key])
    
pa = ProportionalArchitecture(config=config, env=pen, input_indexes=inputs, namespace = namespace)
pa()
hpct = pa.get_hierarchy()
hpct.draw(move={'Pendulum': [-0.2, -0.3],'Input0': [-0.3, 0]})
level0 [[[1]], [62.82423385532463], [[0]], [1]]
parameters {}
{% endraw %}