diprism / fggs

Factor Graph Grammars in Python
MIT License
13 stars 3 forks source link

Print output distribution using symbolic names #181

Closed davidweichiang closed 2 months ago

davidweichiang commented 2 months ago

These are already provided in the FGG file.

chihyang commented 2 months ago

@davidweichiang @ccshan

For edges that have multiple node labels, the corresponding weight result is a tensor in the following format:

For example:

EdgeLabel(name='Ctor[Succ/inst0 Folded/Nat/inst0]', 
          node_labels=(NodeLabel(name='Folded/Nat/inst0'), NodeLabel(name='Nat/inst0')), 
          is_terminal=True)

where

fgg.domains['Folded/Nat/inst0'].size() is 2
fgg.domains['Nat/inst0'].size() is 3

The shape of its weight is:

[2, 3]

For such weights, should the output look like below?

{
'folded/Nat/inst0/site0': {'Zero/inst0': 0, 
                           'Succ/inst0 (folded/Nat/inst0/site0)': 1,
                           'Succ/inst0 (folded/Nat/inst0/site1)': 0 }
'folded/Nat/inst0/site1': {'Zero/inst0': 0,
                           'Succ/inst0 (folded/Nat/inst0/site0)': 0,
                           'Succ/inst0 (folded/Nat/inst0/site1)': 1}
}
ccshan commented 2 months ago

Yes, that looks good!

(I can imagine someday wanting neither a List[List[Number]] nor a Dict[String, Dict[String, Number]] but rather a List[Dict[String, Number]] or a Dict[String, List[Number]], but that's not urgent.)

chihyang commented 2 months ago

Yes, that looks good!

(I can imagine someday wanting neither a List[List[Number]] nor a Dict[String, Dict[String, Number]] but rather a List[Dict[String, Number]] or a Dict[String, List[Number]], but that's not urgent.)

This has been added in 182.

chihyang commented 2 months ago

This one can be closed by #182.