提交 58a2fe2b authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Merged

syntax: glob
*.o
*.orig
*.pyc
*.pyo
*.so
*.sw?
*~
Theano.egg-info
\#*\#
build
compiled/*.cpp
......@@ -11,12 +18,6 @@ doc/.build/
doc/indexes/oplist.txt
doc/indexes/typelist.txt
html
*.o
*.orig
pdf
pull.sh
*.pyc
*.pyo
*.so
*.sw?
Theano.egg-info
setuptools-*.egg
......@@ -77,7 +77,7 @@ attribute.
For detailed documentation on the Exception, see :api:`BadDestroyMap`.
For detailed documentation on the ``destroy_map`` attribute, see :ref:`_inplace`.
For detailed documentation on the ``destroy_map`` attribute, see :ref:`inplace`.
BadViewMap
......@@ -89,7 +89,7 @@ optimization system via the ``view_map`` attribute.
For detailed documentation on the Exception, see :api:`BadViewMap`.
For detailed documentation on the ``view_map`` attribute, see :ref:`_views`.
For detailed documentation on the ``view_map`` attribute, see :ref:`views`.
StochasticOrder
......
......@@ -5,21 +5,20 @@
Advanced Topics
===============
Structure
=========
.. toctree::
:maxdepth: 2
:maxdepth: 2
debug_faq
debugmode
env
features
optimization
compilation
ccodegen
function
module
pipeline
profilemode
unittest
pipeline
unittest
profilemode
debug_faq
debugmode
.. env
.. features
.. optimization
.. compilation
.. ccodegen
.. function
.. module
......@@ -10,7 +10,7 @@ compiling a Theano function.
Definition of the computation graph
===================================
-----------------------------------
By creating Theano :ref:`Variables <variable>` using
``theano.tensor.lscalar`` or ``theano.tensor.dmatrix`` or by using
......@@ -22,9 +22,9 @@ in the :ref:`graphstructures` article.
Compilation of the computation graph
====================================
------------------------------------
Once the user has built a computation graph, he can use
Once the user has built a computation graph, she can use
``theano.function`` or a ``theano.Method`` in a ``theano.module`` in
order to make one or more functions that operate on real data. Both
function and Method take a list of input :ref:`Variables <variable>`
......@@ -37,7 +37,7 @@ computation graph in the compilation phase:
Step 1 - Create an Env
======================
^^^^^^^^^^^^^^^^^^^^^^
The subgraph given by the end user is wrapped in a structure called
:ref:`env`. That structure defines several hooks on adding and
......@@ -56,7 +56,7 @@ inputs declared as immutable.
Step 2 - Execute main Optimizer
===============================
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Once the Env is made, an :ref:`optimizer <optimization>` is produced
by the :ref:`mode` passed to ``function`` or to the Method/Module's
......@@ -68,7 +68,7 @@ The optimizer is typically obtained through :ref:`optdb <optdb>`.
Step 3 - Execute linker to obtain a thunk
=========================================
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Once the computation graph is optimized, the :ref:`linker` is
extracted from the Mode. It is then called with the Env as argument to
......@@ -99,21 +99,10 @@ case if ``borrow`` was True, the thunk would be allowed to reuse (or
Step 4 - Wrap the thunk in a pretty package
===========================================
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The thunk returned by the linker along with input and output
containers is unwieldy. ``function`` and ``Method`` hide that
complexity away so that it can be used like a normal function with
arguments and return values.
......@@ -10,7 +10,7 @@ an argument when compiling your graph. Using ProfileMode is a three-step
process.
Creating a ProfileMode Instance
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-------------------------------
First create a ProfileMode instance.
......@@ -33,7 +33,7 @@ find where most of the computation time is being spent. In this context,
'fast_run' optimizer and ``gof.OpWiseCLinker`` are the most appropriate choices.
Compiling your Graph with ProfileMode
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Once the ProfileMode instance is created, simply compile your graph as you
would normally, by specifying the mode parameter.
......@@ -45,7 +45,7 @@ would normally, by specifying the mode parameter.
>>> minst = m.make(mode=profmode)
Retrieving Timing Information
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Once your graph is compiled, simply run the program or operation you wish to
profile, then call ``profmode.print_summary()``. This will provide you with
......
......@@ -15,7 +15,7 @@ Unit Testing revolves around the following principles:
This page is in no way meant to replace tutorials on Python's unittest module, for this we refer the reader to the `official documentation <http://docs.python.org/library/unittest.html>`_. We will however adress certain specificities about how unittests relate to theano.
How to Run Unit Tests ?
=======================
-----------------------
Running all unit tests
......@@ -36,7 +36,7 @@ Running a specific unit test
Folder Layout
=============
-------------
"tests" directories are scattered throughout theano. Each tests subfolder is
meant to contain the unittests which validate the .py files in the parent folder.
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="298.12207"
height="286.03781"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.45.1"
sodipodi:docbase="/home/olivier/hg/theano"
sodipodi:docname="apply1_2.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.0"
inkscape:export-filename="/home/olivier/hg/theano/apply.png"
inkscape:export-xdpi="120.76"
inkscape:export-ydpi="120.76">
<defs
id="defs4">
<marker
inkscape:stockid="Dot_m"
orient="auto"
refY="0.0"
refX="0.0"
id="Dot_m"
style="overflow:visible">
<path
id="path4340"
d="M -2.5,-1.0 C -2.5,1.7600000 -4.7400000,4.0 -7.5,4.0 C -10.260000,4.0 -12.5,1.7600000 -12.5,-1.0 C -12.5,-3.7600000 -10.260000,-6.0 -7.5,-6.0 C -4.7400000,-6.0 -2.5,-3.7600000 -2.5,-1.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;marker-end:none"
transform="scale(0.4) translate(7.4, 1)" />
</marker>
<marker
inkscape:stockid="Dot_l"
orient="auto"
refY="0.0"
refX="0.0"
id="Dot_l"
style="overflow:visible">
<path
id="path4337"
d="M -2.5,-1.0 C -2.5,1.7600000 -4.7400000,4.0 -7.5,4.0 C -10.260000,4.0 -12.5,1.7600000 -12.5,-1.0 C -12.5,-3.7600000 -10.260000,-6.0 -7.5,-6.0 C -4.7400000,-6.0 -2.5,-3.7600000 -2.5,-1.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;marker-end:none"
transform="scale(0.8) translate(7.4, 1)" />
</marker>
<marker
inkscape:stockid="Arrow2Lstart"
orient="auto"
refY="0"
refX="0"
id="Arrow2Lstart"
style="overflow:visible">
<path
id="path4293"
style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.97309,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
transform="matrix(1.1,0,0,1.1,1.1,0)" />
</marker>
<marker
inkscape:stockid="Arrow1Lstart"
orient="auto"
refY="0"
refX="0"
id="Arrow1Lstart"
style="overflow:visible">
<path
id="path4275"
d="M 0,0 L 5,-5 L -12.5,0 L 5,5 L 0,0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
transform="matrix(0.8,0,0,0.8,10,0)" />
</marker>
<marker
inkscape:stockid="Arrow1Lend"
orient="auto"
refY="0"
refX="0"
id="Arrow1Lend"
style="overflow:visible">
<path
id="path4278"
d="M 0,0 L 5,-5 L -12.5,0 L 5,5 L 0,0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
transform="matrix(-0.8,0,0,-0.8,-10,0)" />
</marker>
<marker
inkscape:stockid="Arrow1Mend"
orient="auto"
refY="0"
refX="0"
id="Arrow1Mend"
style="overflow:visible">
<path
id="path4284"
d="M 0,0 L 5,-5 L -12.5,0 L 5,5 L 0,0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
transform="matrix(-0.4,0,0,-0.4,-4,0)" />
</marker>
<marker
inkscape:stockid="Arrow1Mstart"
orient="auto"
refY="0"
refX="0"
id="Arrow1Mstart"
style="overflow:visible">
<path
id="path4281"
d="M 0,0 L 5,-5 L -12.5,0 L 5,5 L 0,0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
transform="matrix(0.4,0,0,0.4,4,0)" />
</marker>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
gridtolerance="10000"
guidetolerance="10"
objecttolerance="10"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.4142136"
inkscape:cx="255.9959"
inkscape:cy="191.5532"
inkscape:document-units="px"
inkscape:current-layer="layer1"
inkscape:window-width="1680"
inkscape:window-height="1030"
inkscape:window-x="0"
inkscape:window-y="0" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-240.86593,-100.33369)">
<rect
style="fill:#5599ff;fill-rule:evenodd;stroke:#000000;stroke-width:0.77611327;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect2184"
width="149.22389"
height="54.223885"
x="339.93231"
y="238.6571" />
<text
xml:space="preserve"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="388.49954"
y="269.95786"
id="text4470"><tspan
sodipodi:role="line"
id="tspan4472"
x="388.49954"
y="269.95786"
style="font-size:18px;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;font-family:Courier 10 Pitch">Apply</tspan></text>
<rect
style="fill:#5599ff;fill-rule:evenodd;stroke:#000000;stroke-width:0.77780414;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect4492"
width="149.2222"
height="15.222196"
x="339.9332"
y="222.61548" />
<rect
style="fill:#5599ff;fill-rule:evenodd;stroke:#000000;stroke-width:0.77780414;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect4483"
width="149.2222"
height="15.222196"
x="339.91492"
y="293.67752" />
<g
id="g8467"
transform="translate(110.2947,-116.37302)"
style="stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none">
<path
transform="matrix(0.90677,0,0,1.0746904,0.5745625,-32.177075)"
d="M 187.15544 385.49426 A 21.620844 18.242588 0 1 1 143.91375,385.49426 A 21.620844 18.242588 0 1 1 187.15544 385.49426 z"
sodipodi:ry="18.242588"
sodipodi:rx="21.620844"
sodipodi:cy="385.49426"
sodipodi:cx="165.53459"
id="path8457"
style="fill:#87deaa;fill-opacity:1;stroke:#000000;stroke-width:1.01300073;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
sodipodi:type="arc" />
<text
id="text8459"
y="394.30408"
x="151.00809"
style="font-size:38.98389435px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="394.30408"
x="151.00809"
id="tspan8461"
sodipodi:role="line">+</tspan></text>
</g>
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Dot_m);marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline"
d="M 347.13075,266.30169 L 280.97106,265.86799"
id="path8463"
inkscape:connector-type="polyline"
inkscape:connection-end="#g8467" />
<text
xml:space="preserve"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="308.77267"
y="259.82309"
id="text9514"><tspan
sodipodi:role="line"
id="tspan9516"
x="308.77267"
y="259.82309">op</tspan></text>
<text
xml:space="preserve"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="424.25516"
y="333.46909"
id="text9518"><tspan
sodipodi:role="line"
id="tspan9520"
x="424.25516"
y="333.46909">owner</tspan></text>
<text
xml:space="preserve"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="493.24387"
y="234.14835"
id="text9522"><tspan
sodipodi:role="line"
id="tspan9524"
x="493.24387"
y="234.14835">inputs</tspan></text>
<text
xml:space="preserve"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="493.71262"
y="305.09174"
id="text9526"><tspan
sodipodi:role="line"
id="tspan9528"
x="493.71262"
y="305.09174">outputs</tspan></text>
<rect
ry="11.309009"
y="159.52519"
x="349.08124"
height="37.13615"
width="46.799088"
id="rect19190"
style="fill:#b35b4f;fill-opacity:1;stroke:#000000;stroke-width:0.79999995;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<text
xml:space="preserve"
style="font-size:23.51551628px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="366.89929"
y="185.69189"
id="text19200"><tspan
sodipodi:role="line"
id="tspan19202"
x="366.89929"
y="185.69189"
style="font-size:23.51551628px;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none">x</tspan></text>
<rect
ry="7.3372421"
rx="7.3372421"
y="134.86392"
x="300.77298"
height="19.022192"
width="58.017704"
id="rect19204"
style="fill:#c88fd5;fill-opacity:1;stroke:#000000;stroke-width:0.56307727;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<text
id="text19206"
y="148.37491"
x="308.72882"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="148.37491"
x="308.72882"
id="tspan19208"
sodipodi:role="line">matrix</tspan></text>
<path
id="path19210"
d="M 353.53683,179.12906 L 329.27775,179.12906 L 329.27775,154.10602"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Dot_m)" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Dot_m)"
d="M 372.64527,162.11475 C 372.64527,115.4457 372.64527,115.4457 372.64527,115.4457"
id="path19212" />
<text
xml:space="preserve"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="356.38177"
y="109.08174"
id="text19214"><tspan
sodipodi:role="line"
id="tspan19216"
x="356.38177"
y="109.08174">None</tspan></text>
<rect
style="fill:#b35b4f;fill-opacity:1;stroke:#000000;stroke-width:0.79999995;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect19218"
width="46.799088"
height="37.13615"
x="431.08124"
y="159.52519"
ry="11.309009" />
<text
id="text19224"
y="185.69189"
x="448.89929"
style="font-size:23.51551628px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:Bitstream Vera Sans"
xml:space="preserve"><tspan
style="font-size:23.51551628px;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none"
y="185.69189"
x="448.89929"
id="tspan19226"
sodipodi:role="line">y</tspan></text>
<rect
style="fill:#c88fd5;fill-opacity:1;stroke:#000000;stroke-width:0.56307727;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect19228"
width="58.017704"
height="19.022192"
x="382.77298"
y="134.86392"
rx="7.3372421"
ry="7.3372421" />
<text
xml:space="preserve"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="390.72882"
y="148.37491"
id="text19230"><tspan
sodipodi:role="line"
id="tspan19232"
x="390.72882"
y="148.37491">matrix</tspan></text>
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Dot_m)"
d="M 435.53683,179.12906 L 411.27775,179.12906 L 411.27775,154.10602"
id="path19234" />
<path
id="path19236"
d="M 454.64527,162.11475 C 454.64527,115.4457 454.64527,115.4457 454.64527,115.4457"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Dot_m)" />
<text
id="text19238"
y="109.08174"
x="438.38177"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="109.08174"
x="438.38177"
id="tspan19240"
sodipodi:role="line">None</tspan></text>
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Dot_m);marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 372.86394,230.00276 L 372.66107,197.10627"
id="path19242"
inkscape:connector-type="polyline" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Dot_m);marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 455.78696,230.00276 L 454.98829,197.10627"
id="path19244"
inkscape:connector-type="polyline" />
<rect
ry="11.309009"
y="348.83536"
x="393.08124"
height="37.13615"
width="46.799088"
id="rect19246"
style="fill:#b35b4f;fill-opacity:1;stroke:#000000;stroke-width:0.79999995;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<text
xml:space="preserve"
style="font-size:23.51551628px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="410.89929"
y="375.00204"
id="text19252"><tspan
sodipodi:role="line"
id="tspan19254"
x="410.89929"
y="375.00204"
style="font-size:23.51551628px;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none">z</tspan></text>
<rect
ry="7.3372421"
rx="7.3372421"
y="324.17407"
x="344.77298"
height="19.022192"
width="58.017704"
id="rect19256"
style="fill:#c88fd5;fill-opacity:1;stroke:#000000;stroke-width:0.56307727;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<text
id="text19258"
y="337.68506"
x="352.72882"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="337.68506"
x="352.72882"
id="tspan19260"
sodipodi:role="line">matrix</tspan></text>
<path
id="path19262"
d="M 397.53683,368.4392 L 373.27775,368.4392 L 373.27775,343.41616"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Dot_m)" />
<text
id="text19274"
y="147.46909"
x="460.25516"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="147.46909"
x="460.25516"
id="tspan19276"
sodipodi:role="line">owner</tspan></text>
<text
xml:space="preserve"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="296.25516"
y="173.46909"
id="text19278"><tspan
sodipodi:role="line"
id="tspan19280"
x="296.25516"
y="173.46909">type</tspan></text>
<path
inkscape:connector-type="polyline"
id="path21431"
d="M 418.00152,353.75266 L 416.8028,304.37924"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Dot_m);marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow1Lstart);marker-end:url(#Dot_m);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 418.00152,351.75266 L 416.8028,302.37924"
id="path21433"
inkscape:connector-type="polyline" />
</g>
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="744.09448819"
height="1052.3622047"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.45.1"
sodipodi:docbase="/home/olivier/hg/theano"
sodipodi:docname="apply2.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape">
<defs
id="defs4">
<marker
inkscape:stockid="Arrow2Lstart"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow2Lstart"
style="overflow:visible">
<path
id="path4293"
style="font-size:12.0;fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round"
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
transform="scale(1.1) translate(1,0)" />
</marker>
<marker
inkscape:stockid="Arrow1Lstart"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow1Lstart"
style="overflow:visible">
<path
id="path4275"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none"
transform="scale(0.8) translate(12.5,0)" />
</marker>
<marker
inkscape:stockid="Arrow1Lend"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow1Lend"
style="overflow:visible;">
<path
id="path4278"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;"
transform="scale(0.8) rotate(180) translate(12.5,0)" />
</marker>
<marker
inkscape:stockid="Arrow1Mend"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow1Mend"
style="overflow:visible;">
<path
id="path4284"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;"
transform="scale(0.4) rotate(180) translate(10,0)" />
</marker>
<marker
inkscape:stockid="Arrow1Mstart"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow1Mstart"
style="overflow:visible">
<path
id="path4281"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none"
transform="scale(0.4) translate(10,0)" />
</marker>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
gridtolerance="10000"
guidetolerance="10"
objecttolerance="10"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.4800532"
inkscape:cx="374.98511"
inkscape:cy="692.66663"
inkscape:document-units="px"
inkscape:current-layer="layer1"
inkscape:window-width="1680"
inkscape:window-height="1030"
inkscape:window-x="0"
inkscape:window-y="0" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="fill:#5599ff;fill-rule:evenodd;stroke:#000000;stroke-width:0.77611327;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect2184"
width="149.22389"
height="54.223885"
x="339.93231"
y="238.6571" />
<text
xml:space="preserve"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="388.49954"
y="269.95786"
id="text4470"><tspan
sodipodi:role="line"
id="tspan4472"
x="388.49954"
y="269.95786"
style="font-size:18px;font-family:Courier 10 Pitch">Apply</tspan></text>
<rect
style="fill:#5599ff;fill-rule:evenodd;stroke:#000000;stroke-width:0.77780408;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect4492"
width="149.2222"
height="15.222196"
x="339.9332"
y="222.61548" />
<path
sodipodi:type="arc"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.78328949;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path7411"
sodipodi:cx="293.10434"
sodipodi:cy="252.11807"
sodipodi:rx="5.0164557"
sodipodi:ry="4.7775769"
d="M 298.1208 252.11807 A 5.0164557 4.7775769 0 1 1 288.08788,252.11807 A 5.0164557 4.7775769 0 1 1 298.1208 252.11807 z"
transform="matrix(0.9967197,0,0,1.0465556,80.719902,-33.716585)" />
<path
sodipodi:type="arc"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.78328949;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path8382"
sodipodi:cx="293.10434"
sodipodi:cy="252.11807"
sodipodi:rx="5.0164557"
sodipodi:ry="4.7775769"
d="M 298.1208 252.11807 A 5.0164557 4.7775769 0 1 1 288.08788,252.11807 A 5.0164557 4.7775769 0 1 1 298.1208 252.11807 z"
transform="matrix(0.9967197,0,0,1.0465556,163.84177,-33.716585)" />
<rect
style="fill:#5599ff;fill-rule:evenodd;stroke:#000000;stroke-width:0.77780408;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect4483"
width="149.2222"
height="15.222196"
x="339.91492"
y="293.67752" />
<path
sodipodi:type="arc"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.78328949;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path8384"
sodipodi:cx="293.10434"
sodipodi:cy="252.11807"
sodipodi:rx="5.0164557"
sodipodi:ry="4.7775769"
d="M 298.1208 252.11807 A 5.0164557 4.7775769 0 1 1 288.08788,252.11807 A 5.0164557 4.7775769 0 1 1 298.1208 252.11807 z"
transform="matrix(0.9967197,0,0,1.0465556,123.78942,37.471974)" />
<path
sodipodi:type="arc"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.78328949;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path8455"
sodipodi:cx="293.10434"
sodipodi:cy="252.11807"
sodipodi:rx="5.0164557"
sodipodi:ry="4.7775769"
d="M 298.1208 252.11807 A 5.0164557 4.7775769 0 1 1 288.08788,252.11807 A 5.0164557 4.7775769 0 1 1 298.1208 252.11807 z"
transform="matrix(0.9967197,0,0,1.0465556,60.378242,2.4814436)" />
<g
id="g8467"
transform="translate(110.2947,-116.37302)">
<path
transform="matrix(0.90677,0,0,1.0746904,0.5745625,-32.177075)"
d="M 187.15544 385.49426 A 21.620844 18.242588 0 1 1 143.91375,385.49426 A 21.620844 18.242588 0 1 1 187.15544 385.49426 z"
sodipodi:ry="18.242588"
sodipodi:rx="21.620844"
sodipodi:cy="385.49426"
sodipodi:cx="165.53459"
id="path8457"
style="fill:#87deaa;fill-opacity:1;stroke:#000000;stroke-width:0.80000001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
sodipodi:type="arc" />
<text
id="text8459"
y="394.30408"
x="151.00809"
style="font-size:38.98389435px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="394.30408"
x="151.00809"
id="tspan8461"
sodipodi:role="line">*</tspan></text>
</g>
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;marker-end:url(#Arrow1Lend);stroke-opacity:1;display:inline"
d="M 347.13075,266.30169 L 280.97106,265.86799"
id="path8463"
inkscape:connector-type="polyline"
inkscape:connection-start="#path8455"
inkscape:connection-end="#g8467" />
<rect
style="fill:#b35b4f;fill-opacity:1;stroke:#000000;stroke-width:0.52622312;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect9460"
width="46.893723"
height="26.624182"
x="349.1749"
y="156.98724"
ry="8.1078167" />
<text
xml:space="preserve"
style="font-size:23.6940155px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="380.6936"
y="177.84793"
id="text9451"><tspan
sodipodi:role="line"
id="tspan9453"
x="380.6936"
y="177.84793">y</tspan></text>
<path
sodipodi:type="arc"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.78328949;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path9458"
sodipodi:cx="293.10434"
sodipodi:cy="252.11807"
sodipodi:rx="5.0164557"
sodipodi:ry="4.7775769"
d="M 298.1208 252.11807 A 5.0164557 4.7775769 0 1 1 288.08788,252.11807 A 5.0164557 4.7775769 0 1 1 298.1208 252.11807 z"
transform="matrix(0.9967197,0,0,1.0465556,70.681922,-92.542809)" />
<rect
style="fill:#b35b4f;fill-opacity:1;stroke:#000000;stroke-width:0.52622312;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect9464"
width="46.893723"
height="26.624182"
x="431.26645"
y="156.64944"
ry="8.1078167" />
<text
xml:space="preserve"
style="font-size:23.6940155px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="462.78519"
y="177.51013"
id="text9466"><tspan
sodipodi:role="line"
id="tspan9468"
x="462.78519"
y="177.51013">z</tspan></text>
<path
sodipodi:type="arc"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.78328949;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path9470"
sodipodi:cx="293.10434"
sodipodi:cy="252.11807"
sodipodi:rx="5.0164557"
sodipodi:ry="4.7775769"
d="M 298.1208 252.11807 A 5.0164557 4.7775769 0 1 1 288.08788,252.11807 A 5.0164557 4.7775769 0 1 1 298.1208 252.11807 z"
transform="matrix(0.9967197,0,0,1.0465556,152.77358,-92.880619)" />
<rect
style="fill:#b35b4f;fill-opacity:1;stroke:#000000;stroke-width:0.52622312;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect9472"
width="46.893723"
height="26.624182"
x="393.43008"
y="352.58823"
ry="8.1078167" />
<path
sodipodi:type="arc"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.78328949;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path9478"
sodipodi:cx="293.10434"
sodipodi:cy="252.11807"
sodipodi:rx="5.0164557"
sodipodi:ry="4.7775769"
d="M 298.1208 252.11807 A 5.0164557 4.7775769 0 1 1 288.08788,252.11807 A 5.0164557 4.7775769 0 1 1 298.1208 252.11807 z"
transform="matrix(0.9967197,0,0,1.0465556,114.9371,103.05828)" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow1Lstart);marker-mid:url(#Arrow2Lstart);marker-end:url(#Arrow1Lend);stroke-opacity:1"
d="M 416.01143,306.73743 L 416.67835,352.32511"
id="path9484"
inkscape:connector-type="polyline"
inkscape:connection-start="#path8384"
inkscape:connection-end="#rect9472" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
d="M 455.87035,224.72912 L 455.0001,183.53674"
id="path9486"
inkscape:connector-type="polyline"
inkscape:connection-start="#path8382"
inkscape:connection-end="#rect9464" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
d="M 372.84098,224.72912 L 372.67643,183.87454"
id="path9488"
inkscape:connector-type="polyline"
inkscape:connection-end="#rect9460"
inkscape:connection-start="#path7411" />
<text
xml:space="preserve"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="308.77267"
y="259.82309"
id="text9514"><tspan
sodipodi:role="line"
id="tspan9516"
x="308.77267"
y="259.82309">op</tspan></text>
<text
xml:space="preserve"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="424.25516"
y="333.46909"
id="text9518"><tspan
sodipodi:role="line"
id="tspan9520"
x="424.25516"
y="333.46909">owner</tspan></text>
<text
xml:space="preserve"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="493.24387"
y="234.14835"
id="text9522"><tspan
sodipodi:role="line"
id="tspan9524"
x="493.24387"
y="234.14835">inputs</tspan></text>
<text
xml:space="preserve"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="493.71262"
y="305.09174"
id="text9526"><tspan
sodipodi:role="line"
id="tspan9528"
x="493.71262"
y="305.09174">outputs</tspan></text>
<rect
style="fill:#c88fd5;fill-opacity:1;stroke:#000000;stroke-width:0.56307727;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect9530"
width="58.017704"
height="19.022192"
x="305.00552"
y="126.72179"
rx="7.3372421"
ry="7.3372421" />
<text
xml:space="preserve"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="312.96136"
y="140.23277"
id="text9532"><tspan
sodipodi:role="line"
id="tspan9534"
x="312.96136"
y="140.23277">matrix</tspan></text>
<rect
ry="7.3372421"
rx="7.3372421"
y="126.72179"
x="385.00552"
height="19.022192"
width="58.017704"
id="rect9536"
style="fill:#c88fd5;fill-opacity:1;stroke:#000000;stroke-width:0.56307727;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<text
id="text9538"
y="140.23277"
x="392.9614"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="140.23277"
x="392.9614"
id="tspan9540"
sodipodi:role="line">matrix</tspan></text>
<rect
style="fill:#c88fd5;fill-opacity:1;stroke:#000000;stroke-width:0.56307727;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect9542"
width="58.017704"
height="19.022192"
x="349.00552"
y="322.04611"
rx="7.3372421"
ry="7.3372421" />
<text
xml:space="preserve"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="356.96136"
y="335.55713"
id="text9544"><tspan
sodipodi:role="line"
id="tspan9546"
x="356.96136"
y="335.55713">matrix</tspan></text>
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 357.76937,170.98692 L 333.51029,170.98692 L 333.51029,145.96388"
id="path19045" />
<path
id="path19047"
d="M 439.12067,170.98692 L 414.86159,170.98692 L 414.86159,145.96388"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<rect
y="434.6571"
x="301.93231"
height="54.223885"
width="149.22389"
id="rect19075"
style="fill:#5599ff;fill-rule:evenodd;stroke:#000000;stroke-width:0.77611327;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<text
id="text19077"
y="465.95782"
x="350.49954"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
xml:space="preserve"><tspan
style="font-size:18px;font-family:Courier 10 Pitch"
y="465.95782"
x="350.49954"
id="tspan19079"
sodipodi:role="line">Apply</tspan></text>
<rect
y="418.61548"
x="301.9332"
height="15.222196"
width="149.2222"
id="rect19081"
style="fill:#5599ff;fill-rule:evenodd;stroke:#000000;stroke-width:0.77780408;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
transform="matrix(0.9967197,0,0,1.0465556,42.719902,162.28341)"
d="M 298.1208 252.11807 A 5.0164557 4.7775769 0 1 1 288.08788,252.11807 A 5.0164557 4.7775769 0 1 1 298.1208 252.11807 z"
sodipodi:ry="4.7775769"
sodipodi:rx="5.0164557"
sodipodi:cy="252.11807"
sodipodi:cx="293.10434"
id="path19083"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.78328949;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
sodipodi:type="arc" />
<path
transform="matrix(0.9967197,0,0,1.0465556,125.84177,162.28341)"
d="M 298.1208 252.11807 A 5.0164557 4.7775769 0 1 1 288.08788,252.11807 A 5.0164557 4.7775769 0 1 1 298.1208 252.11807 z"
sodipodi:ry="4.7775769"
sodipodi:rx="5.0164557"
sodipodi:cy="252.11807"
sodipodi:cx="293.10434"
id="path19085"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.78328949;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
sodipodi:type="arc" />
<rect
y="489.67755"
x="301.91492"
height="15.222196"
width="149.2222"
id="rect19087"
style="fill:#5599ff;fill-rule:evenodd;stroke:#000000;stroke-width:0.77780408;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
transform="matrix(0.9967197,0,0,1.0465556,85.789422,233.47197)"
d="M 298.1208 252.11807 A 5.0164557 4.7775769 0 1 1 288.08788,252.11807 A 5.0164557 4.7775769 0 1 1 298.1208 252.11807 z"
sodipodi:ry="4.7775769"
sodipodi:rx="5.0164557"
sodipodi:cy="252.11807"
sodipodi:cx="293.10434"
id="path19089"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.78328949;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
sodipodi:type="arc" />
<path
transform="matrix(0.9967197,0,0,1.0465556,22.378242,198.48144)"
d="M 298.1208 252.11807 A 5.0164557 4.7775769 0 1 1 288.08788,252.11807 A 5.0164557 4.7775769 0 1 1 298.1208 252.11807 z"
sodipodi:ry="4.7775769"
sodipodi:rx="5.0164557"
sodipodi:cy="252.11807"
sodipodi:cx="293.10434"
id="path19091"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.78328949;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
sodipodi:type="arc" />
<g
transform="translate(72.294702,79.626981)"
id="g19093">
<path
sodipodi:type="arc"
style="fill:#87deaa;fill-opacity:1;stroke:#000000;stroke-width:0.80000001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path19095"
sodipodi:cx="165.53459"
sodipodi:cy="385.49426"
sodipodi:rx="21.620844"
sodipodi:ry="18.242588"
d="M 187.15544 385.49426 A 21.620844 18.242588 0 1 1 143.91375,385.49426 A 21.620844 18.242588 0 1 1 187.15544 385.49426 z"
transform="matrix(0.90677,0,0,1.0746904,0.5745625,-32.177075)" />
<text
xml:space="preserve"
style="font-size:38.98389435px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="151.00809"
y="394.30408"
id="text19097"><tspan
sodipodi:role="line"
id="tspan19099"
x="151.00809"
y="394.30408">+</tspan></text>
</g>
<path
inkscape:connector-type="polyline"
id="path19101"
d="M 309.13075,462.30169 L 242.97106,461.86799"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;marker-end:url(#Arrow1Lend);stroke-opacity:1;display:inline" />
<rect
ry="8.1078167"
y="352.98724"
x="311.1749"
height="26.624182"
width="46.893723"
id="rect19103"
style="fill:#b35b4f;fill-opacity:1;stroke:#000000;stroke-width:0.52622312;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<text
id="text19105"
y="373.8479"
x="342.6936"
style="font-size:23.6940155px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="373.8479"
x="342.6936"
id="tspan19107"
sodipodi:role="line">x</tspan></text>
<path
transform="matrix(0.9967197,0,0,1.0465556,32.681922,103.45719)"
d="M 298.1208 252.11807 A 5.0164557 4.7775769 0 1 1 288.08788,252.11807 A 5.0164557 4.7775769 0 1 1 298.1208 252.11807 z"
sodipodi:ry="4.7775769"
sodipodi:rx="5.0164557"
sodipodi:cy="252.11807"
sodipodi:cx="293.10434"
id="path19109"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.78328949;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
sodipodi:type="arc" />
<rect
ry="8.1078167"
y="548.5882"
x="355.43008"
height="26.624182"
width="46.893723"
id="rect19119"
style="fill:#b35b4f;fill-opacity:1;stroke:#000000;stroke-width:0.52622312;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<text
id="text19121"
y="569.44891"
x="386.94882"
style="font-size:23.6940155px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="569.44891"
x="386.94882"
id="tspan19123"
sodipodi:role="line">e</tspan></text>
<path
transform="matrix(0.9967197,0,0,1.0465556,76.937102,299.05828)"
d="M 298.1208 252.11807 A 5.0164557 4.7775769 0 1 1 288.08788,252.11807 A 5.0164557 4.7775769 0 1 1 298.1208 252.11807 z"
sodipodi:ry="4.7775769"
sodipodi:rx="5.0164557"
sodipodi:cy="252.11807"
sodipodi:cx="293.10434"
id="path19125"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.78328949;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
sodipodi:type="arc" />
<path
inkscape:connector-type="polyline"
id="path19127"
d="M 378.01143,502.73743 L 378.67836,548.32513"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow1Lstart);marker-mid:url(#Arrow2Lstart);marker-end:url(#Arrow1Lend);stroke-opacity:1" />
<path
inkscape:connector-type="polyline"
id="path19129"
d="M 417.87035,420.72912 L 417.00011,379.53673"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1" />
<path
inkscape:connector-type="polyline"
id="path19131"
d="M 334.84098,420.72912 L 334.67644,379.87453"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1" />
<text
id="text19133"
y="455.82309"
x="270.77267"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="455.82309"
x="270.77267"
id="tspan19135"
sodipodi:role="line">op</tspan></text>
<text
id="text19137"
y="529.46906"
x="386.25516"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="529.46906"
x="386.25516"
id="tspan19139"
sodipodi:role="line">owner</tspan></text>
<text
id="text19141"
y="430.14832"
x="455.24387"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="430.14832"
x="455.24387"
id="tspan19143"
sodipodi:role="line">inputs</tspan></text>
<text
id="text19145"
y="501.09174"
x="455.71262"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="501.09174"
x="455.71262"
id="tspan19147"
sodipodi:role="line">outputs</tspan></text>
<rect
ry="7.3372421"
rx="7.3372421"
y="322.72177"
x="267.00552"
height="19.022192"
width="58.017704"
id="rect19149"
style="fill:#c88fd5;fill-opacity:1;stroke:#000000;stroke-width:0.56307727;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<text
id="text19151"
y="336.23276"
x="274.96136"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="336.23276"
x="274.96136"
id="tspan19153"
sodipodi:role="line">matrix</tspan></text>
<rect
ry="7.3372421"
rx="7.3372421"
y="552.04608"
x="237.00554"
height="19.022192"
width="58.017704"
id="rect19161"
style="fill:#c88fd5;fill-opacity:1;stroke:#000000;stroke-width:0.56307727;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<text
id="text19163"
y="565.55713"
x="244.96138"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="565.55713"
x="244.96138"
id="tspan19165"
sodipodi:role="line">matrix</tspan></text>
<path
id="path19167"
d="M 319.76937,366.98692 L 295.51029,366.98692 L 295.51029,341.96388"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
inkscape:connector-type="polyline"
id="path19171"
d="M 363.68961,562.84291 L 295.30478,561.94276"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1" />
<text
id="text19173"
y="556.4682"
x="319.41959"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="556.4682"
x="319.41959"
id="tspan19175"
sodipodi:role="line">type</tspan></text>
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 401.76937,366.98692 L 377.51029,366.98692 L 377.51029,341.96388"
id="path19177" />
<text
xml:space="preserve"
style="font-size:10.838377px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="425.91193"
y="370.5032"
id="text19179"><tspan
sodipodi:role="line"
id="tspan19181"
x="425.91193"
y="370.5032">tmp</tspan></text>
</g>
</svg>
......@@ -158,9 +158,3 @@ version that it produces in the code I gave above.
div = BinaryDoubleOp(name = 'div',
fn = lambda x, y: x / y,
ccode = "%(z)s = %(x)s / %(y)s;")
**Next:** `Views and inplace operations`_
.. _Views and inplace operations: ../inplace.html
......@@ -440,9 +440,3 @@ Final version
return ""
double = Double()
**Next:** `Implementing the arithmetic Ops in C`_
.. _Implementing the arithmetic Ops in C: cop.html
......@@ -266,16 +266,3 @@ Final version
We add one utility function, ``__str__``. That way, when we print
``double``, it will print out something sensible.
**Next:** `Making arithmetic Ops on double`_
.. _Making arithmetic Ops on double: op.html
......@@ -150,9 +150,3 @@ with numpy arrays may be found :ref:`here <predefinedtypes>`.
You, the user---not the system architecture---have to choose whether your
program will use 32- or 64-bit integers (``i`` prefix vs. the ``l`` prefix)
and floats (``f`` prefix vs. the ``d`` prefix).
**Next:** `More examples`_
.. _More examples: examples.html
......@@ -255,8 +255,5 @@ array(5.9000000000000004)
array(5.9000000000000004)
**Next:** `Using Module`_
.. _Using Module: module.html
.. _automatic differentiation: http://en.wikipedia.org/wiki/Automatic_differentiation
......@@ -47,12 +47,12 @@ Here we instantiate an empty Module.
>>> m.state = T.dscalar()
>>> m.inc = T.dscalar('inc')
Then we declare a Variable for use with our Module. That Variable will
be a :ref:`member` of the Module, which means that it will be
accessible as a field of the object we will create later (for reading
and writing). It will also be accessible from any :ref:`method`
defined in our Module.
Then we declares for use with our Module.
Since we assign these input Variables as attributes of the Module,
they will be *member Variables* of the Module.
Member Variables are special in a few ways, which we will see shortly.
.. note::
......@@ -60,11 +60,6 @@ defined in our Module.
be given the name 'state' automatically.
>>> m.inc = T.dscalar('inc')
The ``inc`` variable doesn't need to be declared as a member of ``m`` because
we only use it as a Method input.
.. note::
Since we made it a member of ``m``, the ``acc`` object will have an
......@@ -74,9 +69,10 @@ we only use it as a Method input.
>>> m.new_state = m.state + m.inc
This line creates a Variable corresponding to some symbolic computation. It
doesn't matter to Theano whether we put it inside ``m`` or not. Feel free to
put such results of symbolic computation wherever is most convenient.
This line creates a Variable corresponding to some symbolic computation.
Although this line also assigns a Variable to a Module attribute, it does not
become a member Variable like state and inc because it represents an expression
result.
>>> m.add = Method(m.inc, m.new_state, {m.state: m.new_state})
......@@ -97,16 +93,18 @@ Calling ``make`` on ``m`` creates an object that can do real
computation and whose attributes contain values such as numbers and numpy
ndarrays.
The keyword arguments given to make are optional and are used to
assign initial values to each Member. If a Member is omitted, the
initial value is None.
At this point something special happens for our member Variables too.
In the 'acc' object, make allocates room to store numbers for m's member
Variables. By using the string 'state' as a keyword argument, we tell Theano to
store the number 0 for the member Variable called 'state'. By not mentioning
the 'inc' variable, we associate None to the 'inc' Variable.
>>> acc.state, acc.inc
array(0.0), None
Since state was declared as a Member, we can access it easily using
'.state'.
Since 'state' was declared as a member Variable of 'm', we can access it's value
in the 'acc' object by the same attribute. Ditto for 'inc'.
.. note::
......@@ -118,18 +116,24 @@ Since state was declared as a Member, we can access it easily using
>>> acc.add(2)
array(2.0)
>>> acc.state
array(2.0)
>>> acc.state, acc.inc
array(2.0), None
When we call the ``acc.add`` method, all the updates given to the
corresponding Method's ``updates`` field are performed. We only had
When we call the ``acc.add`` method, the value 2 is used for the symbolic 'm.inc'
The first line evaluates the output and all the updates given to the
'acc' Method's ``updates`` field. We only had
one update which mapped ``state`` to ``new_state`` and you can see
that it works as intended, adding the argument to the internal state.
Note also that 'acc.inc' is still None after our call. Since 'm.inc' was listed
as an input the Method, the method got it's own private storage container for
'm.inc'. If we had left 'm.inc' out of the Method input list, then it the
method would have used the module's storage for ``m.inc`` instead.
>>> acc.state = 39.99
The state is also easy to set. When we manually set the value of a member
The state can also be set. When we manually set the value of a member
attribute like this, then subsequent calls to the methods of our module will
use the new value.
......@@ -282,3 +286,4 @@ WRITEME
......@@ -166,14 +166,3 @@ Ops
There are a lot of operations available in the ``theano.tensor`` package.
See :ref:`oplist`.
**Next:** `Wrapping up`_
.. _Wrapping up: wrapup.html
......@@ -42,8 +42,8 @@ source_suffix = '.txt'
master_doc = 'contents'
# General substitutions.
project = 'theano'
copyright = '2008-2009, LISA lab'
project = 'Theano'
copyright = '2008--2009, LISA lab'
# The default replacements for |version| and |release|, also used in various
# other places throughout the built documents.
......@@ -64,7 +64,7 @@ today_fmt = '%B %d, %Y'
# List of directories, relative to source directories, that shouldn't be searched
# for source files.
#exclude_dirs = []
exclude_dirs = ['images']
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
......@@ -101,7 +101,7 @@ html_style = 'default.css'
# The name of an image file (within the static path) to place at the top of
# the sidebar.
#html_logo = None
html_logo = 'images/theano_logo-200x67.png'
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
......@@ -111,7 +111,7 @@ html_style = 'default.css'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['.static']
html_static_path = ['.static', 'images']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
......@@ -119,7 +119,7 @@ html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
......@@ -159,18 +159,19 @@ htmlhelp_basename = 'theanodoc'
#latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
latex_font_size = '11pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, document class [howto/manual]).
latex_documents = [
('contents', 'theano.tex', 'theano Documentation',
'LISA lab', 'manual'),
'LISA lab, University of Montreal', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
#latex_logo = 'images/snake_theta2-trans.png'
latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
......
......@@ -6,7 +6,7 @@ Contents
========
.. toctree::
:maxdepth: 3
:maxdepth: 2
LICENSE
introduction
......@@ -16,8 +16,9 @@ Contents
advanced_tutorial/index
advanced/index
indexes/index
examples/index
glossary
links
internal/index
sandbox/index
.. examples/index
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="345.86591"
height="115.13724"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.45.1"
sodipodi:docbase="/home/olivier/hg/theano"
sodipodi:docname="theano_logo.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.0"
inkscape:export-filename="/home/olivier/hg/theano/theano_logo_big.png"
inkscape:export-xdpi="273.58655"
inkscape:export-ydpi="273.58655">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
gridtolerance="10000"
guidetolerance="10"
objecttolerance="10"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.979899"
inkscape:cx="248.50886"
inkscape:cy="97.530852"
inkscape:document-units="px"
inkscape:current-layer="layer1"
inkscape:window-width="1680"
inkscape:window-height="1030"
inkscape:window-x="0"
inkscape:window-y="0"
showguides="true"
inkscape:guide-bbox="true" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-219.06115,-88.23416)">
<path
id="path5572"
d="M 245.99986,202.38198 C 235.76172,199.76305 230.3317,195.18454 224.56469,184.30815 C 220.37775,176.41173 219.14676,170.92373 219.06742,159.80009 C 219.02952,154.48681 219.14363,153.33451 219.96737,150.71192 L 220.91072,147.70853 L 222.03485,150.91475 C 223.32792,154.60284 224.5932,157.2101 225.42491,157.90035 C 225.91931,158.31066 226.04839,157.45384 226.31509,151.99127 C 226.48664,148.47733 226.74177,144.59829 226.88203,143.3712 C 227.13637,141.14611 227.14306,141.13711 229.37079,140.02194 C 233.6165,137.89661 241.51289,137.62549 255.7355,139.11671 C 262.25557,139.80033 276.27711,139.65881 278.302,138.88894 C 280.15154,138.18575 280.55926,136.52884 280.07117,131.69921 C 279.49474,125.99537 279.0548,124.08561 277.22091,119.32634 C 272.4649,106.98367 264.75123,100.69911 254.31572,100.6648 C 244.91721,100.6339 237.20308,106.18784 232.64521,116.26692 C 228.63554,125.13371 226.84755,134.63837 225.79128,152.70119 L 225.49476,157.77183 L 224.6018,156.08339 C 220.32764,148.00176 218.55416,134.3005 220.39244,123.56361 C 221.81624,115.24763 224.72248,108.02444 229.43922,101.07873 C 233.51167,95.08179 239.33503,91.22689 247.37024,89.20891 C 252.54529,87.90924 256.08615,87.90924 261.2612,89.20891 C 269.29641,91.22689 275.11977,95.08179 279.19222,101.07873 C 283.85913,107.95107 286.81123,115.24029 288.1872,123.28884 C 289.11587,128.72102 289.26704,136.96138 288.48572,139.5625 C 287.80095,141.84221 282.75423,149.25874 282.58446,148.23482 C 282.51467,147.81394 282.66002,147.09129 282.90745,146.62895 C 283.60255,145.33016 282.97412,144.79606 281.91813,145.78812 C 281.09814,146.55845 280.95497,146.57992 280.4772,146.00425 C 279.46931,144.78981 279.09827,146.0508 280.02317,147.54731 C 281.09294,149.27824 281.11194,149.86163 280.09855,149.86163 C 279.6655,149.86163 279.2114,150.02307 279.08945,150.2204 C 278.12451,151.78171 263.15706,152.14918 251.27333,150.90331 C 242.48708,149.98217 235.49959,150.17874 233.86598,151.393 C 232.52086,152.39282 230.73981,155.92513 230.13832,158.78596 C 229.56685,161.50406 229.89814,169.75383 230.71167,173.06316 C 231.53272,176.40313 234.44347,181.26714 237.48117,184.37536 C 245.97324,193.06457 259.99042,193.16426 268.52866,184.59618 C 272.82158,180.28826 276.28725,173.36771 275.26986,171.13477 C 275.01206,170.56897 274.80113,169.46845 274.80113,168.68918 C 274.80113,167.27252 276.03299,164.34881 276.84003,163.85004 C 277.97809,163.14668 279.2633,160.34344 279.2633,158.56453 C 279.2633,156.50464 279.81574,155.1351 280.64665,155.1351 C 281.94053,155.1351 281.78744,149.84815 280.42796,147.58266 C 279.38328,145.84176 279.47773,145.48404 280.68309,146.61641 C 281.46075,147.34699 281.69721,147.42235 281.69721,146.93962 C 281.69721,146.59338 282.00521,146.05957 282.38164,145.75336 C 282.9932,145.2559 283.02559,145.28301 282.68588,146.00793 C 282.47678,146.45415 282.35906,148.62448 282.4243,150.8309 C 282.5319,154.47038 282.63024,154.91126 283.48431,155.58307 C 284.25335,156.18799 284.4647,156.82757 284.6386,159.07597 C 284.78839,161.01273 285.24037,162.64716 286.16384,164.59151 C 287.23183,166.84012 287.43789,167.69463 287.27043,169.18035 C 287.15459,170.2081 286.70684,171.3939 286.24597,171.89349 C 285.2295,172.99536 281.11174,180.12521 280.69642,181.50246 C 279.94371,183.99856 277.41503,189.23736 275.76462,191.71994 C 273.21329,195.55768 270.45935,197.86457 265.70147,200.14953 C 258.59319,203.56326 253.06615,204.18955 245.99986,202.38198 z "
style="fill:#000000;fill-opacity:1" />
<text
xml:space="preserve"
style="font-size:15.53327274px;font-style:normal;font-weight:normal;fill:#7799ee;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="285.01266"
y="186.09427"
id="text5574"
transform="scale(1.0402212,0.961334)"><tspan
sodipodi:role="line"
id="tspan5576"
x="285.01266"
y="186.09427"
style="font-size:93.19962311px;font-weight:normal;fill:#7799ee;fill-opacity:1;font-family:MgOpen Modata"
dx="0 -4.2857141 -6.4285722 -5 -5.7142901 -6.0714293"
dy="0 0 -1.3672954 0.35714287 1.0101526 -1.0101526">Theano</tspan></text>
</g>
</svg>
.. _install:
=================
Installing Theano
=================
......@@ -9,7 +9,7 @@ Installing Theano
If you are a member of LISA Labo, have a look at :ref:`lisa_labo` for
lab-specific installation instructions.
------------
Requirements
------------
......@@ -43,7 +43,6 @@ The following libraries and software are optional:
To download bleeding-edge
------------
Easy install
------------
......@@ -63,7 +62,6 @@ on your system:
.. Theano, when we figure out where to put it.
--------------
Manual install
--------------
......@@ -124,7 +122,6 @@ You may also download the latest source directly as a gzip'd tar file:
`<http://pylearn.org/hg/theano/archive/tip.tar.gz>`__.
---------------------------
Configuring the environment
---------------------------
......@@ -161,7 +158,7 @@ automatic code generation, but that way is much, much slower.
running unit tests.
Setting this value will make the unit tests deterministic.
---
Mac
---
......@@ -185,7 +182,7 @@ Mac
TODO: check if this is still valid
-------
Windows
-------
......@@ -194,7 +191,6 @@ never even been tested, so feel free to explore this uncharted
territory and inform us of your progress!
----------------------------
Generating the documentation
----------------------------
......
......@@ -64,4 +64,33 @@ old changes by hand.
For more info, check out the `homepage <http://www.selenic.com/mercurial/wiki/>`_ and `hg book <http://hgbook.red-bean.com/hgbook.html>`_.
Tip: Commit before pull
------------------------
"This is the general rule of thumb when using Mercurial: finish your work
and commit it before you start pulling in stuff from the outside world."
-Martin Geisler
(http://www.selenic.com/pipermail/mercurial/2008-April/018817.html)
Tip: Graph logs
---------------
Update your .hgrc::
[ui]
username = Foo Bar <barfoo@iro.umontreal.ca>
[extensions]
hgext.graphlog =
Now try::
hg glog
Troubleshooting
---------------
If you get message: "abort: push
creates new remote heads!", read `this thread
<http://www.selenic.com/pipermail/mercurial/2008-April/018804.html>`_
to understand.
......@@ -5,13 +5,15 @@
Internal documentation
======================
Structure
=========
If you're feeling ambitious, go fix some `pylint
<http://lgcm.iro.umontreal.ca/auto_theano_pylint/pylint_global.html>` errors!
.. toctree::
:maxdepth: 2
dev_start_guide
hg_primer
lisa_labo
mammouth
metadocumentation
python
hg_primer
.. _lisa_labo::
===============================
LISA Labo specific instructions
===============================
Tips for running at LISA
------------------------
Use the fast BLAS library that Fred installed, by setting
`THEANO_BLAS_LDFLAGS=-lgoto`.
Tips for running on a cluster
-----------------------------
OUTDATED(was for mammouth1, should be updated for mammouth2)
Use something like the following in your .bashrc:
.. code-block:: bash
#use the intel math-kernel library for BLAS routines
THEANO_BLAS_LDFLAGS=-lmkl
# use up to two threads in the MKL routines
OMP_NUM_THREADS=2
# IMPORTANT!
# Use the local-temporary directory as a cache.
# If several jobs start simultaneously and use a common
# cache, then the cache may be corrupted.
# Theano is not process-safe or thread-safe in this sense.
THEANO_COMPILEDIR=/ltmp/<username>_theano
You may also need to run the following from your shell:
.. code-block:: bash
module add python # for the current shell session
module initadd python # for this and future sessions
Lastly, if ``./filename.py`` doesn't work, try ``python filename.py``.
......@@ -4,13 +4,17 @@ Running Theano on Mammouth
To run Theano on the Mammouth cluster, follow these simple steps:
* Make sure to source Fred's .local.bashrc file. It contains all the goodies for using the latest and greatest (optimized) libraries (numpy, scipy, etc.)
>>> source /home/bastienf/.local.bashrc
* Make sure to source Fred's .local.bashrc file. It contains all
the goodies for using the latest and greatest (optimized) libraries
(numpy, scipy, etc.)
* set THEANO_BLAS_LDFLAGS='-lmkl -lguide -fopenmp'
>>> source /home/bastienf/.local.bashrc
Note: the -lguide flag works, however the fix should probably be considered temporary.
Intel has deprecated libguide.so in favor of the newer library libiomp5.so. However,
both libraries are mutually exclusive and one component (theano, numpy or scipy?) already
seems to be using libguide.so (hence -liomp5 causes a linking error when compiling thunks)
Perhaps even put this in your ``.bashrc``
* ``set THEANO_BLAS_LDFLAGS='-lmkl -lguide -fopenmp'``
Note: the -lguide flag works, however the fix should probably be considered temporary.
Intel has deprecated libguide.so in favor of the newer library libiomp5.so. However,
both libraries are mutually exclusive and one component (theano, numpy or scipy?) already
seems to be using libguide.so (hence -liomp5 causes a linking error when compiling thunks)
......@@ -51,6 +51,16 @@ API documentation is processed by `epydoc
<http://epydoc.sourceforge.net/manual-othermarkup.html#restructuredtext>`__
for details about how to use reST with epydoc documentation.
Use ReST for API and Sphinx documentation
-----------------------------------------
* ReST is standardized. epydoc is not. trac wiki-markup is not.
This means that ReST can be cut-and-pasted between epydoc, code, other
docs, and TRAC. This is a huge win!
* ReST is extensible: we can write our own roles and directives to automatically link to WIKI, for example.
* ReST has figure and table directives, and can be converted (using a standard tool) to latex documents.
* No text documentation has good support for math rendering, but ReST is closest: it has three renderer-specific solutions (render latex, use latex to build images for html, use itex2mml to generate MathML)
How to build documentation
---------------------------------------
......@@ -80,6 +90,7 @@ When you push to the main repository, the following file is run::
It calls ``epydoc`` and ``sphinx`` on the code.
*It would be nice to explain this stuff in a little more depth:*
* Who calls refresh-epydoc.sh ?
* What exactly does it do?
* Where does the output go?
......@@ -135,6 +146,7 @@ TO WRITE
---------------------------------------
*There is other stuff to document here, e.g.:*
* where the documentation is getting built, and epy.
* How epydoc and sphinx are integrated
* Explain the special magic in ./doc/scripts/docgen.py
......
.. _python:
================
Python booster
================
`This page
<http://wordaligned.org/articles/essential-python-reading-list>`_ will
give you a warm feeling in your stomach.
Non-Basic Python features
-------------------------
Theano doesn't use your grandfather's python.
* properties
a specific attribute that has get and set methods which python automatically invokes.
See [http://www.python.org/doc/newstyle/ New style classes].
* static methods vs. class methods vs. instance methods
* Decorators:
.. code-block:: python
@f
def g():
...
runs function ``f`` before each invocation of ``g``.
See `PEP 0318 <http://www.python.org/dev/peps/pep-0318/>`_.
``staticmethod`` is a specific decorator, since python 2.2
* ``__metaclass__`` is kinda like a decorator for classes. It runs the metaclass __init__ after the class is defined
* ``setattr`` + ``getattr`` + ``hasattr``
* ``*args`` is a tuple like argv in C++, ``**kwargs`` is a keyword args version
* ``pass`` is no-op.
* functions (function objects) can have attributes too. This technique
is often used to define a function's error messages.
.. code-block:: python
def f(): return f.a
f.a = 5
f() # returns 5
* Warning about mutual imports:
* script a.py file defined a class A.
* script a.py imported file b.py
* file b.py imported a, and instantiated a.A()
* script a.py instantiated its own A(), and passed it to a function in b.py
* that function saw its argument as being of type __main__.A, not a.A.
Incidentally, this behaviour is one of the big reasons to put autotests in
different files from the classes they test!
If all the test cases were put into <file>.py directly, then during the test
cases, all <file>.py classes instantiated by unit tests would have type
``__main__.<classname>``, instead of type ``<file>.<classname>``. This should never
happen under normal usage, and can cause problems (like the one you are/were
experiencing).
......@@ -7,17 +7,16 @@ Introduction
Theano is a Python library that allows you to define, optimize, and
efficiently evaluate mathematical expressions involving multi-dimensional
arrays. Theano was written at the LISA_ lab to support the development
of efficient machine learning algorithms while minimizing human time. We
use it especially in gradient-based learning techniques.
arrays. Using Theano, it is not uncommon to see speed improvements of
ten-fold over using pure NumPy.
Theano melds some aspects of a computer algebra system (CAS) with
aspects of an optimizing compiler. It can even transform some or all
of the expression into C code and compile it into native machine
instructions. This combination of CAS with optimizing compilation
is particularly useful for computational fields in which complicated
mathematical expressions are evaluated numerous times over large data
sets.
aspects of an optimizing compiler. It can even transform some or
all of the mathematical expression into C code and compile it into
native machine instructions. This combination of CAS with optimizing
compilation is particularly useful for computational fields in which
complicated mathematical expressions are evaluated repeatedly and evaluation
speed is critical.
Theano supports a range of numerical types in multiple dimensions and
a number of well-tested operations. It also allows you to compute the
......@@ -36,10 +35,12 @@ not limited to:
* using inplace operations wherever it is safe to do so.
Theano defines several optimizations which improve the numerical
stability of computations. It also provides a framework to add and test
new optimizers.
stability of computations.
Theano was named after the `Greek mathematician`_, who may have
Theano was written at the LISA_ lab to support the development
of efficient machine learning algorithms while minimizing human time. We
use it especially in gradient-based learning techniques.
Theano is named after the `Greek mathematician`_, who may have
been Pythagoras' wife.
Theano is released under a BSD license (:ref:`link <license>`)
......
.. _links:
=====
Links
=====
......@@ -9,7 +9,7 @@ This page lists links to various resources.
Theano requirements
===================
-------------------
- mercurial_: A distributed revision control system (RCS).
- nosetests_: A system for unit tests.
......@@ -19,7 +19,7 @@ Theano requirements
Libraries we might want to look at or use
=========================================
-----------------------------------------
This is a sort of memo for developers and would-be developers.
......
......@@ -2,14 +2,22 @@
.. _numpy:
===============
***************
NumPy refresher
===============
***************
Here are some quick guides to NumPy:
* `Numpy quick guide for Matlab users <http://www.scipy.org/NumPy_for_Matlab_Users>`__
* `More detailed table showing the NumPy equivalent of Matlab commands <http://www.scribd.com/doc/26685/Matlab-Python-and-R>`__
.. TODO [DefineBroadcasting Broadcasting]
.. Broadcastable - Implicitly assume that all previous entries are true.
.. [TODO: More doc, e.g. see _test_tensor.py]
---------------------------------------
Matrix conventions for machine learning
---------------------------------------
=======================================
Rows are horizontal and columns are vertical.
Every row is an example. Therefore, inputs[10,5] is a matrix of 10 examples with 5 dimensions per.
......
The following may go either in:
a) numpy refresher.
b) more details of broadcasting in the types section.
=== broadcastable ===
The {{{broadcastable}}} field of a {{{Tensor}}} must be a tuple of boolean values. Each value corresponds to a dimension of the {{{Tensor}}} and specifies whether the {{{Tensor}}} can be "broadcasted" along that dimension.
A value of {{{True}}} means two things:
* The size of the corresponding dimension will necessarily be 1.
* If needed, the {{{Tensor}}} can be ''broadcasted'' or ''replicated'' along the corresponding dimension to emulate a larger {{{Tensor}}}.
A value of {{{False}}} means that the corresponding dimension can take any nonnegative value and that the {{{Tensor}}} cannot be replicated along it (regardless of whether it is 1 or not).
Example: to define a ''row'' type, set broadcastable to {{{(True, False)}}}: this means the shape must be like {{{(1, n)}}}. If you add a row of shape {{{(1, n)}}} to a matrix of shape {{{(m, n)}}}, the row will be "broadcasted" or "replicated" {{{m}}} times along the first dimension, producing a virtual matrix of the correct size {{{(m, n)}}}. Therefore, adding a row to a matrix will add the row to each row of the matrix. If the value of {{{broadcastable}}} for the first dimension of the row was {{{False}}}, the operation would instead raise an exception complaining that the dimensions are not the same.
Similarly, the broadcastable pattern for a column is {{{(False, True)}}}: this means the shape must be like {{{(m, 1)}}}, therefore adding a column to a matrix will add that column to each column of the matrix. Several Ops, such as {{{DimShuffle}}}, can add or remove broadcastable dimensions.
The length of {{{broadcastable}}} is the number of dimensions of the {{{Tensor}}}.
Want to know about Theano's `function design
<http://groups.google.com/group/theano-dev/browse_thread/thread/fd4c6947d8a20510>`?
'''Historical Interest. This has been addressed for now. 20080904'''
There are several [http://en.wikipedia.org/wiki/Comparison_of_free_software_hosting_facilities project hosting services] online, but none is perfect for theano.
Wishlist:
- version control (mercurial)
- bugtracker (TRAC, ideally)
- wiki
- release file hosting
- mailing list
- reliability of hosting service
Currently, [http://sharesource.org/ sharesource] and [http://www.assembla.com/ assembla] are the only hosting services that support mercurial that I know of. Sharesource is young, but supports all the required features. I'll make an account, and see what I can do with it...
Should we get a domain name? To my dismay, theano.org, theano.com and theano.net are all taken. The first two seem legit, but theano.net doesn't look like it has anything on it and expires on May 29, so maybe there's a chance we can snag it? -ob
We could also get [http://www.theano.io]. -jpt
--------
On Fri, May 09, 2008 at 03:49:31PM -0400, Joseph Turian wrote:
> Another option for backup:
>
> Since we have access to LGCM, there is a single SQLite db file (AFAIK)
> that we can back up periodically.
> e.g. cron job to gzip and email it to us once a week.
There are instructions for how to backup a Trac site, i just haven't gotten
around to it. Currently, the whole directory is rsynced to the lisa account,
which is close to ok, but not quite.
> Besides mailing list, is there anything else we need? Besides figuring
> out how to administer trac? :}
Writing scripts to update p-omega1/.ssh/authorized_keys2 automatically from
certain user accounts' authorized_keys2 file. I've written this script, but not
really tested it.
Hooking up mercurial to trac would be nice, so we can associate commits and
tickets.
lgcm's uptime is usually about a week or two at max, so there's the pain in the
ass of having to re-log in, start up a screen session, find the directories,
restart trac, restart hg serve. We should be restarting hg serve for tlearn too
soon.
Even if I do set up the authorized_keys2 script to do the right thing, the users
on TRAC and the users on the system are totally independent, so adding a new
user is non-standard and only I can do it right now.
My choices seem to be:
- document all these hoops and good ideas
- fix them so they are easier to use and document
- replace them with hosting service
All of these options take time, mental effort, and the support of our
development group (look the large number of messages today on the topic)... so
i'm trying to find the least of all evils. The Right Thing doesn't seem to have
appeared yet.
Theano uses several tricks to obtain good performance:
* common sub-expression elimination
* [custom generated] C code for many operations
* pre-allocation of temporary storage
* loop fusion (which gcc normally can't do)
On my neural net experiments for my course projects, I was getting around 10x
speed improvements over basic numpy by using theano.
[More specific speed tests would be nice.]
With a little work, Theano could also implement more sophisticated
optimizations:
* automatic ordering of matrix multiplications
* profile-based memory layout decisions (e.g. row-major vs. col-major)
* gcc intrinsics to use MMX, SSE2 parallelism for faster element-wise arithmetic
* conditional expressions
Other software to look at and maybe recommend to users:
* [http://www.pytables.org/moin PyTables] - This is looking really
promising for dataset storage and experiment logging... This might
actually be useful for large data sets.
* [http://matplotlib.sourceforge.net/ MatPlotLib] - visualization tools
(plot curves interactively, like matlab's figure window)
* [http://www.pythonware.com/products/pil/ PIL] - Python Image Library:
write your matrices out in png! (Kinda a weird recommendation, I think)
* [http://www.logilab.org/857 pylint] - Syntax checker for python to
help beautify your code. (We'd be hypocrites to recommend this :)
* [http://www.winpdb.org/ Winpdb] - A Platform Independent Python
Debugger. (Except it doesn't really help you debug Theano graphs)
* [http://wiki.python.org/moin/IntegratedDevelopmentEnvironments Python Integrated Development Environments] - for all your coding needs
......@@ -87,8 +87,17 @@ Several things should be learned from the above example:
TODO: Rewrite this documentation to do things in a smarter way.
Speed
-----
For faster sparse code:
* Construction: lil_format is fast for many inserts.
* Operators: "Since conversions to and from the COO format are
quite fast, you can use this approach to efficiently implement lots
computations on sparse matrices." (Nathan Bell on scipy mailing list)
Misc
----------------------------------------
----
The sparse equivalent of dmatrix is csc_matrix and csr_matrix.
:api:`TrueDot` vs. :api:`StructuredDot`
......
......@@ -13,7 +13,7 @@ from setuptools import setup, find_packages
setup(name="Theano",
version="0.1",
description="Optimizing compiler for mathematical expressions",
long_description="""Theano is a Python library that allows you to define, optimize, and efficiently evaluate mathematical expressions involving multi-dimensional arrays. Theano was written at the LISA lab to support the development of efficient machine learning algorithms while minimizing human time. We use it especially in gradient-based learning techniques.""",
long_description="""Theano is a Python library that allows you to define, optimize, and efficiently evaluate mathematical expressions involving multi-dimensional arrays. Using Theano, it is not uncommon to see speed improvements of ten-fold over using pure NumPy."""
author="LISA laboratory, University of Montreal",
author_email="theano-dev@googlegroups.com",
packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]),
......
"""Provides `DebugMode`, an evaluation mode for debugging theano internals."""
__docformat__ = "restructuredtext en"
import time, copy, sys
import time, copy, sys, copy_reg
from StringIO import StringIO
import numpy
......@@ -1123,6 +1123,9 @@ class _Maker(FunctionMaker): #inheritance buys a few helper functions
fn = self.function_builder(_fn, _i, _o, self.indices, self.outputs, defaults, self.unpack_single, self)
return fn
def _pickle_DebugMode_Maker(maker):
raise NotImplementedError('DebugMode is not picklable (yet)')
copy_reg.pickle(_Maker, _pickle_DebugMode_Maker)
########################
#
......
......@@ -13,7 +13,7 @@ from .. import gof
import sys
import copy
from mode import *
import mode as mode_module
from io import *
def infer_reuse_pattern(env, outputs_to_disown):
......@@ -95,6 +95,10 @@ def std_env(input_specs, output_specs, accept_inplace = False):
env.extend(Supervisor(input for spec, input in zip(input_specs, inputs) if not (spec.mutable or (hasattr(env, 'destroyers') and env.destroyers(input)))))
return env, map(SymbolicOutput, updates)
class AliasedMemoryError(Exception):
"""Memory is aliased that should not be"""
pass
###
### Function
......@@ -140,27 +144,75 @@ class Function(object):
"""
input_storage = None
"""list of Container instances"""
output_storage = None
"""list of Container instances"""
indices = None
"""list of (SymbolicInput|SymbolicInputKit, indices, [SymbolicInput,...]), one tuple for
each input
The first tuple element is the SymbolicInput object for the corresponding function input.
The second and third tuple elements are used only by Kits, which are deprecated.
"""
defaults = None
""" list of 3-tuples, one 3-tuple for each input.
Tuple element 0: Bool: Is this input required at each function call?
Tuple element 1: Bool: Should this inputs value be reverted after each call?
Tuple element 2: Any: The value associated with this input.
"""
unpack_single = None
"""Bool: for outputs lists of length 1, should the 0'th element be returned directly?"""
maker = None
"""FunctionMaker instance"""
fn = None
"""a function that evaluates the graph. Typically a linker's make_thunk method created this
function."""
finder = None
"""Dictionary mapping several kinds of things to containers.
We set an entry in finder for:
- the index of the input
- the variable instance the input is based on
- the name of the input
All entries map to the container or to DUPLICATE if an ambiguity is detected
"""
inv_finder = None
"""Dict. Reverse lookup of `finder`.
It maps container -> SymbolicInput
"""
def __init__(self, fn, input_storage, output_storage, indices, outputs, defaults, unpack_single, maker):
"""
fn -> a function returned by some linker's make_thunk method
input_storage -> list of Container instances used by fn to fetch the inputs
output_storage -> list of Container instances used by fn to store the outputs in
indices -> list of (SymbolicInput|SymbolicInputKit, indices, [SymbolicInput,...]), one tuple for each input
defaults -> list of (required (bool), refeed (bool), value), one tuple for each input
required -> whether this input is required or optional
refeed -> whether this input's contents must be reverted to value after each call or not
value -> the initial or default value of the input
unpack_single -> if the function has one output and unpack_single is True, return that output. Else,
return [output].
maker -> FunctionMaker instance used to make this Function (used for copy)
Initialize attributes. create finder, inv_finder.
"""
self.fn = fn
self.input_storage = input_storage
self.output_storage = output_storage
self.indices = indices
self.outputs = outputs
self.defaults = defaults
self.unpack_single = unpack_single
self.maker = maker
containers = list(self.input_storage)
# we'll be popping stuff off this `containers` object. It's a copy
containers = list(self.input_storage)
finder = {}
inv_finder = {}
......@@ -183,11 +235,6 @@ class Function(object):
c.data = value
c.required = required
c.provided = 0 # this is a count of how many times the input has been provided (reinitialized to 0 on __call__)
# We set an entry in finder for:
# - the index of the input
# - the variable instance the input is based on
# - the name of the input
# All entries map to the container or to DUPLICATE if an ambiguity is detected
finder[i] = c
finder[input.variable] = c
finder[input.name] = c if input.name not in finder else DUPLICATE
......@@ -222,10 +269,6 @@ class Function(object):
self.finder = finder
self.inv_finder = inv_finder
self.outputs = outputs
self.defaults = defaults
self.unpack_single = unpack_single
self.maker = maker
# this class is important in overriding the square-bracket notation:
# fn.value[x]
......@@ -254,6 +297,8 @@ class Function(object):
s.provided += 1
else:
s(value)
def __contains__(self, item):
return finder.__contains__(item)
# this class is important in overriding the square-bracket notation:
# fn.container[x]
......@@ -261,11 +306,16 @@ class Function(object):
class ContainerAttribute(object):
def __getitem__(self, item):
return finder[item]
def __contains__(self, item):
return finder.__contains__(item)
# You cannot set the container
self._value = ValueAttribute()
self._container = ContainerAttribute()
def __contains__(self, item):
return self.value.__contains__(item)
def __getitem__(self, item):
return self.value[item]
......@@ -336,18 +386,20 @@ class Function(object):
value = property(
lambda self: self._value,
None, #not settable
doc="""TODOC""")
None, # this property itself is not settable
doc="""dictionary-like access to the values associated with Variables""")
container = property(
lambda self: self._container,
None,
doc="""TODOC""")
None, # this property itself is not settable
doc="""dictionary-like access to the containers associated with Variables""")
# pickling/deepcopy support for Function
def _pickle_Function(f):
#copy of the input storage list
ins = list(f.input_storage)
defaults = []
for (input, indices, inputs), (required, refeed, default) in zip(f.indices, f.defaults):
if isinstance(input, SymbolicInputKit):
li = len(indices)
......@@ -362,7 +414,7 @@ def _pickle_Function(f):
inputs_data = [x.data for x in f.input_storage]
#HACK to detect aliased storage.
# HACK to detect aliased storage.
# aliased relationships will not be preserved across the pickle operation
if not (f.pickle_aliased_memory_strategy == 'ignore'):
all_data = defaults + inputs_data
......@@ -381,8 +433,6 @@ def _pickle_Function(f):
rval = (_constructor_Function, (f.maker, defaults, inputs_data))
return rval
class AliasedMemoryError(Exception):pass
def _constructor_Function(maker, defaults, data):
f = maker.create(defaults, trustme = True)
assert len(f.input_storage) == len(data)
......@@ -501,7 +551,7 @@ class FunctionMaker(object):
raise TypeError("Unknown output type: %s (%s)", type(output), output)
def __init__(self, inputs, outputs,
mode = default_mode, accept_inplace = False, function_builder = Function):
mode = None, accept_inplace = False, function_builder = Function):
"""
:type inputs: a list of SymbolicInput instances
......@@ -510,12 +560,14 @@ class FunctionMaker(object):
case the functions produced by FunctionMaker will return
their output value directly
:param mode: a Mode instance telling FunctionMaker how to optimize and link
:param mode: a Mode instance telling FunctionMaker how to optimize and link. None
means to use the `default_mode`.
:param accept_inplace: True iff it is acceptable to have inplace operations
in the graph from the inputs to the outputs
"""
mode = mode if mode is not None else mode_module.default_mode
# Handle the case where inputs and/or outputs is a single Variable (not in a list)
unpack_single = False
......@@ -536,7 +588,7 @@ class FunctionMaker(object):
self.env = env
# Fetch the mode and then the optimizer and linker
mode = predefined_modes.get(mode, mode)
mode = mode_module.predefined_modes.get(mode, mode)
optimizer, linker = mode.optimizer, copy.copy(mode.linker)
# optimize the env
......@@ -545,7 +597,7 @@ class FunctionMaker(object):
# initialize the linker
if not hasattr(linker, 'accept'):
raise ValueError("'linker' parameter of FunctionFactory should be a Linker with an accept method " \
"or one of %s" % predefined_linkers.keys())
"or one of %s" % mode_module.predefined_linkers.keys())
#the 'no_borrow' outputs are the ones for which that we can't return the internal storage pointer.
no_borrow = [output for output, spec in zip(env.outputs, outputs+additional_outputs) if not spec.borrow]
......@@ -659,7 +711,8 @@ class FunctionMaker(object):
def _pickle_FunctionMaker(fm):
return (_constructor_FunctionMaker, (fm.inputs, fm.outputs[0] if fm.unpack_single else fm.outputs, fm.mode, fm.accept_inplace))
rval = (_constructor_FunctionMaker, (fm.inputs, fm.outputs[0] if fm.unpack_single else fm.outputs, fm.mode, fm.accept_inplace))
return rval
def _constructor_FunctionMaker(*args):
return FunctionMaker(*args)
......@@ -691,7 +744,7 @@ def register_checker(checker):
def function(inputs, outputs, mode=default_mode, accept_inplace = False):
def function(inputs, outputs, mode=None, accept_inplace = False):
"""
Return a function calculating the outputs from the inputs.
......@@ -701,8 +754,8 @@ def function(inputs, outputs, mode=default_mode, accept_inplace = False):
value of the returned function will match the format of this argument (either the value
itself or a list of one or more return values)
:param mode: a descriptive string or a Mode instance. (See below for descriptive string
list).
:param mode: a descriptive string or a Mode instance. (Default of None means to use
`mode.default_mode` (See below for descriptive string list).
Currently, the library provides the following mode strings:
......@@ -738,6 +791,7 @@ def function(inputs, outputs, mode=default_mode, accept_inplace = False):
f[<kitname>] = seed #re-seed the elements of a RandomKit
"""
mode = mode if mode is not None else mode_module.default_mode
inputs = map(convert_function_input, inputs)
if outputs is None:
......@@ -747,7 +801,7 @@ def function(inputs, outputs, mode=default_mode, accept_inplace = False):
defaults = [getattr(input, 'value', None) for input in inputs]
mode = predefined_modes.get(mode, mode)
mode = mode_module.predefined_modes.get(mode, mode)
if isinstance(mode, (list, tuple)): # "mode comparison" semantics
if not mode:
raise ValueError("Please provide at least one mode.")
......
import numpy
import sys
import numpy, scipy
import scipy.sparse
from theano import gof
......@@ -34,9 +35,8 @@ class BROKEN_ON_PURPOSE_StructuredDotCSC(gof.Op):
(a_nrows, b.shape[0]),
copy = False)
# TODO: todense() is automatic in 0.7.0, just remove the following line:
# out[0] = numpy.asarray(a.dot(b).todense())
out[0] = a.dot(b)+0.5 if self.py_offset else a.dot(b) #ERROR TO ADD THIS CRAPPY OFFSET
#assert _is_dense(out[0])
z = a * b
out[0] = z+0.5 if self.py_offset else z #ERROR TO ADD THIS CRAPPY OFFSET
def c_code(self, node, name, (a_val, a_ind, a_ptr, a_nrows, b), (z,), sub):
return """
......
......@@ -381,24 +381,102 @@ class T_picklefunction(unittest.TestCase):
x,s = T.scalars('xs')
f = function([x, In(a, value=1.0,name='a'), In(s, value=0.0, update=s+a*x, mutable=True)], s+a*x)
print f.maker.function_builder
g = copy.deepcopy(f)
try:
g = copy.deepcopy(f)
except NotImplementedError, e:
if e[0].startswith('DebugMode is not picklable'):
return
else:
raise
#if they both return, assume that they return equivalent things.
#print [(k,id(k)) for k in f.finder.keys()]
#print [(k,id(k)) for k in g.finder.keys()]
self.failIf(g.container[x].storage is f.container[x].storage)
self.failIf(g.container[a].storage is f.container[a].storage)
self.failIf(g.container[s].storage is f.container[s].storage)
self.failIf(g.container[0].storage is f.container[0].storage)
self.failIf(g.container[1].storage is f.container[1].storage)
self.failIf(g.container[2].storage is f.container[2].storage)
self.failIf(x in g.container)
self.failIf(x in g.value)
self.failIf(g.value[a] is f.value[a]) # should not have been copied
self.failIf(g.value[s] is f.value[s]) # should have been copied because it is mutable.
self.failIf((g.value[s] != f.value[s]).any()) # its contents should be identical
self.failIf(g.value[1] is f.value[1]) # should not have been copied
self.failIf(g.value[2] is f.value[2]) # should have been copied because it is mutable.
self.failIf((g.value[2] != f.value[2]).any()) # its contents should be identical
self.failUnless(f(2, 1) == g(2)) #they should be in sync, default value should be copied.
self.failUnless(f(2, 1) == g(2)) #they should be in sync, default value should be copied.
f(1,2) # put them out of sync
self.failIf(f(1, 2) == g(1, 2)) #they should not be equal anymore.
def test_pickle(self):
a = T.scalar() # the a is for 'anonymous' (un-named).
x,s = T.scalars('xs')
f = function([x, In(a, value=1.0,name='a'), In(s, value=0.0, update=s+a*x, mutable=True)], s+a*x)
try:
g = cPickle.loads(cPickle.dumps(f))
except NotImplementedError, e:
if e[0].startswith('DebugMode is not picklable'):
return
else:
raise
#if they both return, assume that they return equivalent things.
#print [(k,id(k)) for k in f.finder.keys()]
#print [(k,id(k)) for k in g.finder.keys()]
self.failIf(g.container[0].storage is f.container[0].storage)
self.failIf(g.container[1].storage is f.container[1].storage)
self.failIf(g.container[2].storage is f.container[2].storage)
self.failIf(x in g.container)
self.failIf(x in g.value)
self.failIf(g.value[1] is f.value[1]) # should not have been copied
self.failIf(g.value[2] is f.value[2]) # should have been copied because it is mutable.
self.failIf((g.value[2] != f.value[2]).any()) # its contents should be identical
self.failUnless(f(2, 1) == g(2)) #they should be in sync, default value should be copied.
self.failUnless(f(2, 1) == g(2)) #they should be in sync, default value should be copied.
f(1,2) # put them out of sync
self.failIf(f(1, 2) == g(1, 2)) #they should not be equal anymore.
def test_optimizations_preserved(self):
a = T.dvector() # the a is for 'anonymous' (un-named).
x = T.dvector('x')
s = T.dvector('s')
xm = T.dmatrix('x')
sm = T.dmatrix('s')
f = function([a, x, s, xm, sm], ((a.T.T)*(tensor.dot(xm, (sm.T.T.T)) + x).T * (x/x) + s))
old_default_mode = compile.mode.default_mode
try:
str_f = cPickle.dumps(f)
compile.mode.default_mode = mode_module.Mode(linker='py', optimizer=None)
g = cPickle.loads(str_f)
#print g.maker.mode
#print compile.mode.default_mode
except NotImplementedError, e:
if e[0].startswith('DebugMode is not pickl'):
g = 'ok'
finally:
compile.mode.default_mode = old_default_mode
if g == 'ok':
return
assert f.maker is not g.maker
assert f.maker.env is not g.maker.env
tf = f.maker.env.toposort()
tg = f.maker.env.toposort()
assert len(tf) == len(tg)
for nf, ng in zip(tf, tg):
assert nf.op == ng.op
assert len(nf.inputs) == len(ng.inputs)
assert len(nf.outputs) == len(ng.outputs)
assert [i.type for i in nf.inputs] == [i.type for i in ng.inputs]
assert [i.type for i in nf.outputs] == [i.type for i in ng.outputs]
# class T_function_examples(unittest.TestCase):
# def test_accumulator(self):
# """Test low-level interface with state."""
......
......@@ -900,9 +900,8 @@ class EquilibriumOptimizer(NavigatorOptimizer):
lopt_change = self.process_node(env, node, lopt)
process_count[lopt] += 1 if lopt_change else 0
changed |= lopt_change
except:
finally:
self.detach_updater(env, u)
raise
self.detach_updater(env, u)
if max_use_abort:
print >> sys.stderr, "WARNING: EquilibriumOptimizer max'ed out"
......
......@@ -120,7 +120,7 @@ class EquilibriumDB(DB):
return opt.EquilibriumOptimizer(opts,
max_depth=5,
max_use_ratio=10,
failure_callback=opt.NavigatorOptimizer.warn)
failure_callback=opt.NavigatorOptimizer.warn_inplace)
class SequenceDB(DB):
......
......@@ -378,6 +378,8 @@ CSR = CSM('csr')
class CSMGrad(gof.op.Op):
def __init__(self, kmap=None):
self.kmap = kmap
if self.kmap is None:
self.view_map = {0 : [1]}
def __eq__(self, other):
return type(self) == type(other) and _kmap_eq(self.kmap, other.kmap)
......@@ -676,7 +678,8 @@ class StructuredDot(gof.Op):
if a.shape[1] != b.shape[0]:
raise ValueError('shape mismatch in StructuredDot.perform', (a.shape, b.shape))
variable = a.dot(b)
#variable = a.dot(b) # deprecated
variable = a * b
assert _is_dense(variable) # scipy 0.7 automatically converts to dense
# dot of an NxM sparse matrix, with a Mx1 dense matrix, returns vector not matrix
......@@ -738,7 +741,8 @@ class StructuredDotCSC(gof.Op):
a = sparse.csc_matrix((a_val, a_ind, a_ptr),
(a_nrows, b.shape[0]),
copy = False)
out[0] = a.dot(b)
#out[0] = a.dot(b)
out[0] = a * b
assert _is_dense(out[0]) # scipy 0.7 automatically converts to dense
def c_code(self, node, name, (a_val, a_ind, a_ptr, a_nrows, b), (z,), sub):
......@@ -881,7 +885,8 @@ class StructuredDotCSR(gof.Op):
a = sparse.csr_matrix((a_val, a_ind, a_ptr),
(len(a_ptr)-1, b.shape[0]),
copy = True) #use view_map before setting this to False
out[0] = a.dot(b)
#out[0] = a.dot(b)
out[0] = a * b
assert _is_dense(out[0]) # scipy 0.7 automatically converts to dense, but not .6 sometimes
def c_code(self, node, name, (a_val, a_ind, a_ptr, b), (z,), sub):
......
......@@ -185,11 +185,11 @@ class test_structureddot(unittest.TestCase):
imvals = 1.0 * numpy.arange(bsize*spmat.shape[1]).reshape(bsize,spmat.shape[1])
outvals = f(kernvals,imvals)
# compare to scipy
c = spmat.dot(imvals.T)
c = spmat * (imvals.T)
assert _is_dense(c)
assert numpy.all(outvals == c)
tensor.verify_grad(None, buildgraphCSC, [kernvals,imvals])
tensor.verify_grad(buildgraphCSC, [kernvals,imvals])
##
# Test compressed-sparse row matrices ###
......@@ -207,11 +207,11 @@ class test_structureddot(unittest.TestCase):
imvals = 1.0 * numpy.arange(bsize*spmat.shape[1]).reshape(bsize,spmat.shape[1])
outvals = f(kernvals,imvals)
# compare to scipy
c = spmat.dot(imvals.T)
c = spmat * (imvals.T)
assert _is_dense(c)
assert numpy.all(outvals == c)
tensor.verify_grad(None, buildgraphCSR, [kernvals,imvals])
tensor.verify_grad( buildgraphCSR, [kernvals,imvals])
if __name__ == '__main__':
......
......@@ -858,7 +858,7 @@ class MaxAndArgmax(Op):
axis = x.type.ndim - 1
axis = _as_tensor_variable(axis)
inputs = [x, axis]
broadcastable = [False] * (x.type.ndim - 1)
broadcastable = [False] * (x.type.ndim - 1) #TODO: be less conservative
outputs = [tensor(x.type.dtype, broadcastable),
tensor(axis.type.dtype, broadcastable)]
return Apply(self, inputs, outputs)
......
......@@ -706,32 +706,17 @@ class Canonizer(gof.LocalOptimizer):
return False
new = self.merge_num_denum(num, denum)
if new.dtype != out.dtype:
if new.type.dtype != out.type.dtype:
#new = T.fill(out, new)
elem_op = T.Elemwise(scalar.Identity(scalar.specific_out(getattr(scalar, out.type.dtype))))
new = T.fill(out, elem_op(new))
if new.broadcastable != out.broadcastable:
#this case is tricky... we need to provide exactly the same kind of broadcastable
#pattern, but only if legal...
dlen = len(new.broadcastable) - len(out.broadcastable)
if dlen > 0:
#try to take the leading ranks of new.broadcastable, which should be broadcastable
# ranks
#if this means skipping over nonbroadcastable ranks, then DimShuffle will fail
dimshuffle_op = T.DimShuffle(new.broadcastable,
range(dlen, len(new.broadcastable)))
new = dimshuffle_op(new)
elif dlen < 0:
#we have to boost up a scalar or something
dimshuffle_op = T.DimShuffle(new.broadcastable,
['x' for x in range(-dlen)] + range(0, len(new.broadcastable)))
new = dimshuffle_op(new)
new = elem_op(new)
if new.type.broadcastable != out.type.broadcastable:
new = T.fill(out, new)
# if our if's above worked, this should be true. OTW investigate.
if new.type != out.type:
print >> sys.stderr, 'CANONIZE FAILED: new out = ', new, out
print >> sys.stderr, 'CANONIZE FAILED: new, out = ', new, ',', out, 'types', new.type, ',', out.type
assert new.type == out.type
return [new]
......
import traceback
import traceback, StringIO
import operator
from theano.tensor import *
......@@ -628,18 +628,26 @@ class T_max_and_argmax(unittest.TestCase):
self.failUnless(numpy.all(i == numpy.argmax(data,0)))
def test2_invalid(self):
n = as_tensor_variable(numpy.random.rand(2,3))
old_stderr = sys.stderr
sys.stderr = StringIO.StringIO()
try:
eval_outputs(max_and_argmax(n,3))
assert False
except ValueError, e:
return
self.fail()
pass
finally:
sys.stderr = old_stderr
def test2_invalid_neg(self):
n = as_tensor_variable(numpy.random.rand(2,3))
old_stderr = sys.stderr
sys.stderr = StringIO.StringIO()
try:
eval_outputs(max_and_argmax(n,-3))
assert False
except ValueError, e:
return
self.fail()
pass
finally:
sys.stderr = old_stderr
def test2_valid_neg(self):
n = as_tensor_variable(numpy.random.rand(2,3))
v,i = eval_outputs(max_and_argmax(n,-1))
......@@ -678,13 +686,16 @@ class T_subtensor(unittest.TestCase):
n = as_tensor_variable(numpy.ones(3))
t = n[7]
self.failUnless(isinstance(t.owner.op, Subtensor))
old_stderr = sys.stderr
sys.stderr = StringIO.StringIO()
try:
tval = eval_outputs([t])
assert 0
except Exception, e:
if e[0] != 'index out of bounds':
raise
return
self.fail()
finally:
sys.stderr = old_stderr
def test1_err_subslice(self):
n = as_tensor_variable(numpy.ones(3))
try:
......@@ -748,20 +759,28 @@ class T_subtensor(unittest.TestCase):
n = as_tensor_variable(numpy.ones((2,3))*5)
t = n[0,4]
self.failUnless(isinstance(t.owner.op, Subtensor))
old_stderr = sys.stderr
sys.stderr = StringIO.StringIO()
try:
tval = eval_outputs([t])
assert 0
except IndexError, e:
return
self.fail()
pass
finally:
sys.stderr = old_stderr
def test2_err_bounds1(self):
n = as_tensor_variable(numpy.ones((2,3))*5)
t = n[4:5,2]
self.failUnless(isinstance(t.owner.op, Subtensor))
old_stderr = sys.stderr
sys.stderr = StringIO.StringIO()
try:
tval = eval_outputs([t])
except Exception, e:
if e[0] != 'index out of bounds':
raise
finally:
sys.stderr = old_stderr
def test2_ok_elem(self):
n = as_tensor_variable(numpy.asarray(range(6)).reshape((2,3)))
t = n[0,2]
......@@ -1364,12 +1383,19 @@ class t_dot(unittest.TestCase):
def not_aligned(self, x, y):
z = dot(x,y)
# constant folding will complain to stderr that things are not aligned
# this is normal, testers are not interested in seeing that output.
old_stderr = sys.stderr
sys.stderr = StringIO.StringIO()
try:
tz = eval_outputs([z])
assert False # should have raised exception
except ValueError, e:
self.failUnless(
e[0].split()[1:4] == ['are', 'not', 'aligned'] or # reported by numpy
e[0].split()[2:5] == ['do', 'not', 'agree'], e) # reported by blas return self.fail()
finally:
sys.stderr = old_stderr
def test_align_1_1(self): self.not_aligned(self.rand(5), self.rand(6))
def test_align_1_2(self): self.not_aligned(self.rand(5), self.rand(6,4))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论