提交 0b92e2d1 authored 作者: James Bergstra's avatar James Bergstra

added doc to function_module

上级 8f174da2
...@@ -623,32 +623,47 @@ def function(inputs, outputs, mode='FAST_RUN', accept_inplace = False): ...@@ -623,32 +623,47 @@ def function(inputs, outputs, mode='FAST_RUN', accept_inplace = False):
""" """
Return a function calculating the outputs from the inputs. Return a function calculating the outputs from the inputs.
inputs -> list of SymbolicInput or In instances :param inputs: list of `SymbolicInput` or `In` instances
outputs -> a SymbolicOutput or a list of SymbolicOutput or Out instances
The return value of the returned function will match the format of this :param outputs: a SymbolicOutput or a list of `SymbolicOutput` or `Out` instances. The return
argument (either the value itself or a list of one or more return values) value of the returned function will match the format of this argument (either the value
mode -> a descriptive string or a Mode instance; descriptive strings can be one of: itself or a list of one or more return values)
* SANITY_CHECK TODO: NotImplemented
* FAST_COMPILE (apply only optimization that are fast to apply) :param mode: a descriptive string or a Mode instance. (See below for descriptive string
* FAST_RUN (default) (optimize without too much time) list).
* EXPENSIVE_OPTIMIZATION TODO: NotImplemented
accept_inplace -> True iff the graph can contain inplace operations Currently, the library provides the following mode strings:
prior to the optimization phase (default is False)
- SANITY_CHECK TODO: NotImplemented
Every element of the input list will be upgraded to an In instance if necessary,
- FAST_COMPILE (apply only optimization that are fast to apply)
- FAST_RUN (default) (optimize without too much time)
- EXPENSIVE_OPTIMIZATION TODO: NotImplemented
:param accept_inplace: True iff the graph can contain inplace operations prior to the
optimization phase (default is False)
Every element of the input list will be upgraded to an `In` instance if necessary,
using the following rules: using the following rules:
* a Result instance r will be upgraded like In(r) - a `Result` instance r will be upgraded like `In`(r)
* a tuple (name, r) will be In(r, name=name)
* a tuple (r, val) will be In(r, value=value, autoname=True) - a tuple (name, r) will be `In`(r, name=name)
* a tuple ((r,up), val) will be In(r, value=value, update=up, autoname=True)
* a tuple (name, r, val) will be In(r, name=name, value=value) - a tuple (r, val) will be `In`(r, value=value, autoname=True)
* a tuple (name, (r,up), val) will be In(r, name=name, value=val, update=up, autoname=True)
- a tuple ((r,up), val) will be `In`(r, value=value, update=up, autoname=True)
- a tuple (name, r, val) will be `In`(r, name=name, value=value)
- a tuple (name, (r,up), val) will be `In`(r, name=name, value=val, update=up, autoname=True)
Similarly, every element of the output list will be upgraded to an Similarly, every element of the output list will be upgraded to an
Out instance if necessary: `Out` instance if necessary:
* a Result instance r will be upgraded like Out(r) * a `Result` instance r will be upgraded like `Out`(r)
Random Numbers Random Numbers
...@@ -656,7 +671,9 @@ def function(inputs, outputs, mode='FAST_RUN', accept_inplace = False): ...@@ -656,7 +671,9 @@ def function(inputs, outputs, mode='FAST_RUN', accept_inplace = False):
If your computation involves random numbers, then you have to pass the `RandomKit` as an If your computation involves random numbers, then you have to pass the `RandomKit` as an
input argument. That RandomKit must have a name to be able to seed the generator. To seed input argument. That RandomKit must have a name to be able to seed the generator. To seed
the generator, use the __getitem__ method: the generator, use the `__setitem__` method:
..code-block: python
f[<kitname>] = seed #re-seed the elements of a RandomKit f[<kitname>] = seed #re-seed the elements of a RandomKit
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论