Skip to content

Commit

Permalink
ERF: Worked on examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
nwilbert committed Jul 23, 2010
1 parent d7d2ba0 commit 078eb03
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
39 changes: 39 additions & 0 deletions sphinx/source/examples_src/bimdpinv_src/bimdpinv.rst
@@ -0,0 +1,39 @@
.. _examples_bimdpinv:

BiFlow Inverse
==============
::

"""
Example on how calculate the inverse of a BiFlow.

A BiFlow does inherit the 'inverse' method from the mdp.Flow class, but
this doesn't support BiMDP features like messages. If these features are
needed then one can use an alternative way to calucalte the inverse, which
is presented here.
"""

import numpy as np
import bimdp

# create a simple pointless flow
pca_node = bimdp.nodes.PCABiNode()
sfa_node = bimdp.nodes.SFABiNode()
flow = pca_node + sfa_node
x = np.random.random((50,5))
flow.train(x)

x = np.random.random((3,5))
y = flow.execute(x)

# the target value 1 is the absolute index of the sfa_node,
# alternatively one could have used a node_id
inv_x, _ = flow.execute(y, {"method": "inverse"}, 1)
#_, (inv_x, _) = bimdp.show_execution(flow, y, {"method": "inverse"}, 1)
assert(np.all(np.abs(x - inv_x) < 0.0000001))

# compare the result to the standard inverse
inv2_x = flow.inverse(y)
assert(np.all(np.abs(inv2_x - inv_x) < 0.0000001))

print "done."
3 changes: 3 additions & 0 deletions sphinx/source/examples_src/examples.rst
Expand Up @@ -8,6 +8,7 @@ Examples
logmap_src/logmap.rst
lle_src/lle.rst
gng_src/gng.rst
bimdpinv_src/bimdpinv.rst
mlpbackprop_src/mlpbackprop.rst
gradient_src/gradient.rst

Expand All @@ -23,6 +24,8 @@ applications:

The following examples use and illustrate BiMDP:

* :ref:`examples_bimdpinv` - A simple example on the alternative mechanism
to inverse a BiFlow.
* :ref:`examples_mlpbackprop` - Implement backpropagation for a multi layer
perceptron.
* :ref:`examples_graddescent` - Use Newton's method for gradient descent
Expand Down
@@ -0,0 +1,8 @@
.. _examples_mlpbackprop:

Backpropagation
===============

This example shows how to implement the backpropagation learning method in the
BiMDP framework. It uses this to implement a multi layer perceptron.
The example code is available in the MDP examples repository.

0 comments on commit 078eb03

Please sign in to comment.