Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
sphinx/source/examples_src/mlpbackprop_src - Kopie (2)/mlpbackprop.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |