This page is about ``theano.function``, the interface for compiling graphs into callable objects.
The signature for this function is:
.. code-block:: python
def function(inputs, outputs, mode='FAST_RUN'):
...
You've already seen example usage in the basic tutorial... something like this:
>>> x = theano.tensor.dscalar()
>>> f = theano.function([x], 2*x)
>>> print f(4) # prints 8.0
The idea here is that we've compiled the symbolic graph (``2*x``) into a function that can be called on a number and will do some computations.
Inputs
======
The ``inputs`` argument to ``theano.function`` is a list, containing the ``Result`` instances for which values will be specified at the time of the function call. But inputs can be more than just Results.
``In`` instances let us attach properties to ``Results`` to tell function more about how to use them.
**In(result, name=None, value=None, update=None, mutable=False)** returns an ``In`` instance:
- ``result``: a Result instance.
This will be assigned a value before running the function,
not computed from its owner.
- ``name``: Any type. (If autoname_input=True, defaults to result.name).
If name is a valid Python identifier, this input can be set by
``kwarg``, and its value can be accessed by ``self.<name>``.
Default: ``None``
- ``value``: literal or Container
This is the default value of the Input.
Default: ``None``
- ``update``: Result instance
This expression Result will replace ``value`` after each function call.
Default: ``None``
- ``mutable``: Bool (requires value)
If ``True``, permit the compiled function to modify the python object being used as the default value.
Default: ``False``
- ``autoname``: Bool
``True``: if ``name`` is None and the Result has a name, it will be taken
as the input's name.
``False``: the name is the exact value passed as the name parameter
(possibly ``None``).
Default: ???
Value: initial and default values
---------------------------------
A non-None `value` argument makes an In() instance an optional parameter
of the compiled function. For example, in the following code we are