提交 2b9bcf22 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Remove obsolete (and not linked) documentation on floatX.

上级 daf4ff52
.. _libdoc_floatX:
=======================================================================
:mod:`floatX` -- Switching Between 'float32' and 'float64'
=======================================================================
.. module:: floatX
:platform: Unix, Windows
:synopsis: easy switching between float32 and float64
.. moduleauthor:: LISA
Guide
=====
On the CPU, 'float32' computations are often twice as fast as 'float64'
and are half the size.
On GPUs the speed difference between 'float32'`` and 'float64' is much greater.
Often we develop our code using double-precision expressions, and then wonder if
we might get the same answer much more quickly with single-precision arithmetic.
If we have used ``tensor.dmatrix`` and ``tensor.dvector`` and so on throughout
our code, it could be tedious to switch to single-precision Variables. To make
switching precisions easier, Theano provides the ``floatX`` module.
>>> from theano.floatX import xmatrix, xvector, xtensor4
>>> import numpy
>>> a = xvector('a')
>>> b = xmatrix()
>>> c = xtensor4()
These calls are identical to ``dvector``, ``dmatrix``, and ``dtensor4`` by default, but a
single environment variable can switch them to ``fvector``, ``fmatrix`` and ``ftensor4``.
You can set the floatX precision via ``floatX`` in the :envvar:`THEANO_FLAGS`.
It defaults to ``'float64'``. To set it to ``'float32'`` in *bash* for example, type ``export THEANO_FLAGS=floatX=float64``.
To set it from within your program call :func:`set_floatX`
The current floatX precision is stored in ``theano.config.floatX`` as a string.
Its value is either 'float32' or 'float64'.
So it is easy to allocate a numpy vector of the floatX dtype.
>>> import theano.config as config
>>> print config.floatX # either 'float32' or 'float64'
>>> x = numpy.asarray([1,2,3], dtype=config.floatX)
Reference
==========
.. function:: xscalar(name=None)
Alias for either :func:`dscalar` or :func:`fscalar`
.. function:: xvector(name=None)
Alias for either :func:`dvector` or :func:`fvector`
.. function:: xmatrix(name=None)
Alias for either :func:`dmatrix` or :func:`fmatrix`
.. function:: xrow(name=None)
Alias for either :func:`drow` or :func:`frow`
.. function:: xcol(name=None)
Alias for either :func:`dcol` or :func:`fcol`
.. function:: xtensor3(name=None)
Alias for either :func:`dtensor3` or :func:`ftensor3`
.. function:: xtensor4(name=None)
Alias for either :func:`dtensor4` or :func:`ftensor4`
.. function:: set_floatX(dtype=config.floatX)
Reset the :func:`xscalar`, ... :func:`xtensor4` aliases to return Variables with given dtype.
This is called at import-time when setting floatX in :envvar:`THEANO_FLAGS`.
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论