2
<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
3
<html><head><title>Python: module srn</title>
4
</head><body bgcolor="#f0f0f8">
6
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
8
<td valign=bottom> <br>
9
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>srn</strong></big></big></font></td
10
><td align=right valign=bottom
11
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/tilde/programming/SoC/scipy/Lib/sandbox/ann/srn.py">/home/tilde/programming/SoC/scipy/Lib/sandbox/ann/srn.py</a></font></td></tr></table>
12
<p><tt># <a href="#srn">srn</a>.py<br>
13
# by: Fred Mailhot<br>
14
# last mod: 2006-08-18</tt></p>
16
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
17
<tr bgcolor="#aa55cc">
18
<td colspan=3 valign=bottom> <br>
19
<font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
21
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
22
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="numpy.html">numpy</a><br>
23
</td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
24
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
25
<tr bgcolor="#ee77aa">
26
<td colspan=3 valign=bottom> <br>
27
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
29
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
31
<dt><font face="helvetica, arial"><a href="srn.html#srn">srn</a>
34
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
35
<tr bgcolor="#ffc8d8">
36
<td colspan=3 valign=bottom> <br>
37
<font color="#000000" face="helvetica, arial"><a name="srn">class <strong>srn</strong></a></font></td></tr>
39
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
40
<td colspan=2><tt>Class to define, train and test a simple recurrent network<br> </tt></td></tr>
42
<td width="100%">Methods defined here:<br>
43
<dl><dt><a name="srn-__init__"><strong>__init__</strong></a>(self, ni, nh, no, f<font color="#909090">='linear'</font>, w<font color="#909090">=None</font>)</dt><dd><tt>Set up instance of <a href="#srn">srn</a>. Initial weights are drawn from a <br>
44
zero-mean Gaussian w/ variance is scaled by fan-in.<br>
46
ni - <int> # of inputs<br>
47
nh - <int> # of hidden & context units<br>
48
no - <int> # of outputs<br>
49
f - <str> output activation fxn<br>
50
w - <array dtype=Float> weight vector</tt></dd></dl>
52
<dl><dt><a name="srn-errfxn"><strong>errfxn</strong></a>(self, w, x, t)</dt><dd><tt>Return vector of squared-errors for the leastsq optimizer</tt></dd></dl>
54
<dl><dt><a name="srn-fwd_all"><strong>fwd_all</strong></a>(self, x, w<font color="#909090">=None</font>)</dt><dd><tt>Propagate values forward through the net. <br>
56
x - matrix of all input patterns<br>
57
w - 1-d vector of weights<br>
59
y - matrix of all outputs</tt></dd></dl>
61
<dl><dt><a name="srn-pack"><strong>pack</strong></a>(self)</dt><dd><tt>Compile weight matrices w1,b1,wc,w2,b2 from net into a<br>
62
single vector, suitable for optimization routines.</tt></dd></dl>
64
<dl><dt><a name="srn-test_all"><strong>test_all</strong></a>(self, x, t)</dt><dd><tt>Test network on an array (size>1) of patterns<br>
66
x - array of input data<br>
67
t - array of targets<br>
69
sum-squared-error over all data</tt></dd></dl>
71
<dl><dt><a name="srn-train"><strong>train</strong></a>(self, x, t)</dt><dd><tt>Train a multilayer perceptron using scipy's leastsq optimizer<br>
73
x - matrix of input data<br>
74
t - matrix of target outputs<br>
76
post-optimization weight vector</tt></dd></dl>
78
<dl><dt><a name="srn-unpack"><strong>unpack</strong></a>(self)</dt><dd><tt>Decompose 1-d vector of weights w into appropriate weight <br>
79
matrices (w1,b1,w2,b2) and reinsert them into net</tt></dd></dl>
81
</td></tr></table></td></tr></table><p>
82
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
83
<tr bgcolor="#eeaa77">
84
<td colspan=3 valign=bottom> <br>
85
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
87
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
88
<td width="100%"><dl><dt><a name="-main"><strong>main</strong></a>()</dt><dd><tt>Set up a 1-2-1 SRN to solve the temporal-XOR problem from Elman 1990.</tt></dd></dl>
b'\\ No newline at end of file'