Model Definition by Yaml fileΒΆ

Phlower offers a way to define models and its order by yaml file.

First of all, we would like to load sample yaml data. Please download sample sample yaml. data.yml

we construct PhlowerSetting object from yaml file.

from phlower.settings import PhlowerSetting

setting = PhlowerSetting.read_yaml("sample_data/model/model.yml")

Order of models must be DAG (Directed Acyclic Graph). To check such conditions, we call resolve function.

setting.model.network.resolve(is_first=True)

In phlower, networks are packed into PhlowerGroupModule. PhlowerGroupModule is directly created from model setting.

draw function generate a file following to mermaid format.

from phlower.nn import PhlowerGroupModule

model = PhlowerGroupModule.from_setting(setting.model.network)
model.draw("images")

The output mermaid file is shown below.

stateDiagram direction LR classDef alignCenter text-align:center state "ENCODER0 nn_type: MLP n_nodes: [10, 20, 100]" as state_0 state "ENCODER1 nn_type: MLP n_nodes: [12, 20, 200]" as state_1 state "Concat nn_type: Concatenator n_nodes: [300, 300]" as state_2 state "GCN0 nn_type: GCN n_nodes: [300, 5]" as state_3 state_0 --> state_2: Pipe state_1 --> state_2: Pipe state_2 --> state_3: Pipe state_3 --> [*] class state_0, state_1, state_2, state_3 alignCenter

According to this image, we can understand details of each model and data flow.

Total running time of the script: (0 minutes 0.009 seconds)

Gallery generated by Sphinx-Gallery