7.2.3. Transformation Operators on Graphs
|
(lsh/libgraph/gtransform.lsh) |
7.2.3.0. (new GTrans)
|
[CLASS] (lsh/libgraph/gtransform.lsh) |
A transformer is the object which embodies the rules used for creating a
new graph from one or two graphs using
g-transform or g-compose .
Class GTrans is the base class for all
transformers.
- Method check
is used for selecting links in the initial graph(s) for which structures
will be created between two nodes of the destination graph.
- Method vcost and
fcost compute the cost of these structures without actually
building them. Method vcost (Viterbi's
cost) computes the cost of the best path. Method
fcost (Forward's cost) computes the logadded cost of all
paths.
- Method build build a structure in
the resulting graph on the basis of the information provided by the
corresponding links in the parent graphs. This involves computing cost,
label and data.
- Method bprop is used during
training to update the gradient with respect to the cost of the initial
graph. The implentation of this method requires that the transformer
remembers the association between the structures created by
build and the initial links. This memory is cleaned by method
reset .
The base class GTrans accepts all
links of the product graph. The cost in the link of the product graph
will be the sum of the costs of the corresponding links in both graphs.
The label and data component are copied from the second and first graph
respectively.
See: (==> gtrans check
link1 link2 )
See: (==> gtrans vcost
link1 link2 )
See: (==> gtrans fcost
link1 link2 )
See: (==> gtrans build
ngraph nnodefrom
nnodeto link1
link2 )
See: (==> gtrans
remember rememberp )
See: (==> gtrans reset)
See: (==> gtrans bprop)
7.2.3.1. (==> gtrans check link1 link2)
|
[MSG] (lsh/libgraph/gtransform.lsh) |
Tells g-transform or
g-compose if they must create a structure in the new graph
corresponding to the given links of the parent graphs. A structure may
be as simple as a single link or as complex as a subgraph.
- In
the case of g-transform , arguments
link1 and link2 are equal
and identify a link of the initial graph. This function returns
t if a new structure corresponding to this link must be
created in the new graph
- In the case of g-compose ,
argument link1 and
link2 identify two links in the two initial graph. This
function returns t if a new structure
corresponding to these links must be created in the new graph
7.2.3.2. (==> gtrans vcost link1 link2)
|
[MSG] (lsh/libgraph/gtransform.lsh) |
Given two links link1 and
link2 in two graphs, this method returns a floating point
number indicating the cost of the best path in the structure
corresponding to links link1 and
link2 .
The default function just adds the costs of both links.
7.2.3.3. (==> gtrans fcost link1 link2)
|
[MSG] (lsh/libgraph/gtransform.lsh) |
Given two links link1 and
link2 in two graphs, this method returns a floating point
number indicating the loadadded cost of all paths in the structure
corresponding to links link1 and
link2 .
The default function just calls vcost
.
7.2.3.4. (==> gtrans build ngraph nnodefrom nnodeto link1 link2)
|
[MSG] (lsh/libgraph/gtransform.lsh) |
Given to links link1 and
link2 in two graphs (for which method
check indicates that we should build something in the
resulting graph), method build creates
a new structure between nodes nnodefrom
and nnodeto in graph
ngraph . This task involves computing cost, label and data
for the new links.
The default function just builds a single new link whose label comes
from link2 and whose data slot comes
from link1 .
7.2.3.5. (==> gtrans bprop)
|
[MSG] (lsh/libgraph/gtransform.lsh) |
Propagates the gradients of the links of the destination graph into the
the corresponding links of the initial graph. The resulting gradients
are accumulated into the fields dcost
of the corresponding links.
If running the transformer involves parametric operations (e.g. running
a network), the gradients are also propagated along these operations and
finally accumulated into the parameter vector.
To achieve this task (optional), the transformer must remember all
structures build since its creation.
7.2.3.6. (==> gtrans remember rememberp)
|
[MSG] (lsh/libgraph/gtransform.lsh) |
Sets or resets memoryless mode. Argument
rememberp is a boolean specifying if it is useful to remember
the result of the next calls to the method build
of the transformer.
7.2.3.7. (==> gtrans reset)
|
[MSG] (lsh/libgraph/gtransform.lsh) |
Resets the data remembered by the transformer for a possible call of
method bprop .
7.2.3.8. (g-copy graph ngraph nstart nend)
|
(lsh/libgraph/gtransform.lsh) |
Copies graph graph between nodes
nstart and nend of a new
graph ngraph . This function only
considers the nodes and links that we can reach from both the starting
node and the end node. The other nodes and link are not copied.
WARNING: This function merely copies the data
pointers. The corresponding data are not copied into the new pool. You
can change these data pointer within a new pass.
7.2.3.9. (g-transform graph trans)
|
(lsh/libgraph/gtransform.lsh) |
Transforms graph graph according to
transformer trans . The resulting
graph is bu1ild by calling method build
of the transformer for all links in the initial graph for which method
check returns true.
This function ideally should only builds the nodes and the links which
are reachable from both the startnode and the endnode. Yet function
g-tranform may build extra nodes and links if the final graph
has cycle(s) or if the transformer method build
builds unecessary nodes.
See: (new GTrans)
7.2.3.10. (g-compose graph1 graph2 trans)
|
(lsh/libgraph/gtransform.lsh) |
Composes graphs graph1 and
graph2 according to transformer trans
. The resulting graph is build by calling method
build of the transformer between all nodes of the product
graph for which method check returns
true.
This function ideally should only builds the nodes and the links which
are reachable from both the startnode and the endnode. Yet function
g-compose may build extra nodes and links if the final graph
has cycle(s) or if the transformer method build
builds unecessary nodes.
See: (new GTrans)