提交 0d4f392c authored 作者: james@crane's avatar james@crane

merged

"""
WRITEME: Some module-level documentation.
Theano is an optimizing compiler in Python, built to evaluate complicated expressions
(especially matrix-valued ones) as quickly as possible.
Theano compiles expression graphs (see :doc:`graph` ) that are built by Python code.
The expressions in these graphs are called `Apply` nodes and the variables in these graphs are called `Result` nodes.
Here is how to make a link into the wiki: check out the :wiki:`DefineGraph()`.
You compile a graph by calling `function`, which takes a graph, and returns a callable object.
One of theano's most important features is that `function` can transform your graph before
compiling it.
It can replace simple expressions with faster or more numerically stable implementations.
To learn more, check out:
- Joseph Turian's n00b walk through ( :wiki:`UserBasic` )
- an introduction to extending theano ( :wiki:`UserAdvanced` )
- Terminology Glossary (:wiki:`glossary`)
- Index of Howto documents (:wiki:`IndexHowto`)
"""
......
graph /graph.html
tensor /graph.html
result /graph.html
howto /graph.html
graph graph.html
tensor graph.html
result graph.html
howto graph.html
""" Defines base clases `Op` and `Op_clinker`.
"""Defines base classes `Op`, `PureOp`, and `CLinkerOp`
The `Op` class is the base interface for all operations
compatible with `gof`'s :doc:`graph` routines.
"""
__docformat__ = "restructuredtext en"
......@@ -11,20 +12,20 @@ import utils
import traceback
class Op_clinker(utils.object2):
class CLinkerOp(object):
"""
Interface definition for `Op` subclasses compiled by `CLinker`.
A subclass should implement
A subclass should implement WRITEME.
WRITEME: structure of automatically generated C code.
WRITEME: structure of automatically generated C code. Put this in doc/code_structure.txt
"""
def c_code(self, node, name, inputs, outputs, sub):
"""Required: Return the C implementation of an Op.
Returns C code that does the computation associated to this L{Op},
Returns C code that does the computation associated to this `Op`,
given names for the inputs and outputs.
:Parameters:
......@@ -137,15 +138,7 @@ class Op_clinker(utils.object2):
"""
raise utils.AbstractFunctionError()
#TODO:
# This is a somewhat ugly use of inheritance because Op is an abstract interface that has
# nothing to do with code generation.
#
# Better would be for Op subclasses wanting to work with the CLinker to have a second
# inheritance from Op_clinker.
class Op(Op_clinker):
class PureOp(object):
"""
An :term:`Op` is a type of operation.
......@@ -161,9 +154,6 @@ class Op(Op_clinker):
- performing the calculation of outputs from given inputs (via the `perform`),
- producing c code to perform calculation of outputs from inputs (via `c_code`,
`c_code_cleanup`, `c_support_code`, `c_headers`, `c_libraries`, `c_compile_args`)
- [optionally] building gradient-calculating graphs (via `grad`).
......@@ -186,7 +176,7 @@ class Op(Op_clinker):
def make_node(self, *inputs):
"""
Contract: return an Apply instance representing the
Required: return an Apply instance representing the
application of this Op to the provided inputs.
All subclasses should over-ride this function.
......@@ -198,8 +188,7 @@ class Op(Op_clinker):
raise utils.AbstractFunctionError(self)
def __call__(self, *inputs):
"""
Return some or all output[s] of `make_node`.
"""Optional: Return some or all output[s] of `make_node`.
It is called by code such as:
......@@ -232,7 +221,7 @@ class Op(Op_clinker):
def perform(self, node, inputs, output_storage):
"""
Contract: Calculate the function on the inputs and put the results in the
Required: Calculate the function on the inputs and put the results in the
output storage. Return None.
:Parameters:
......@@ -254,4 +243,6 @@ class Op(Op_clinker):
"""
raise utils.AbstractFunctionError(self)
class Op(utils.object2, PureOp, CLinkerOp):
"""Convenience class to bundle `PureOp` and `CLinkerOp`"""
pass
......@@ -120,13 +120,9 @@ separate-classes: no
# Use this URL prefix to configure the string returned for external API.
#external-api-root: epydoc:http://epydoc.sourceforge.net/api
external-api: wiki
external-api-root: wiki:http://lgcm.iro.umontreal.ca/theano/wiki/
external-api-file: wiki:wiki.idx
external-api: doc
external-api-root: doc:http://lgcm.iro.umontreal.ca/doc/
external-api-file: doc:doc/doc.idx
external-api: wiki doc
external-api-root: wiki:http://lgcm.iro.umontreal.ca/theano/wiki/ doc:http://lgcm.iro.umontreal.ca/auto_theano/doc/
external-api-file: wiki:wiki.idx doc:doc/doc.idx
### Graph options
......
DefineGraph DefineGraph
DefineTensorResult DefineTensor#TensorResult
Connection.cursor() NothingInvalid.html
wiki.DefineGraph DefineGraph
wiki.DefineTensorResult DefineTensor#TensorResult
wiki.HowtoList HowtoList
wiki.UserBasic UserBasic
wiki.UserAdvanced UserAdvanced
wiki.TerminologyGlossary TerminologyGlossary
wiki.glossary TerminologyGlossary
wiki.IndexHowto IndexHowto
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论