提交 876944c7 authored 作者: Eric Larsen's avatar Eric Larsen 提交者: Frederic

Correct Theano's tutorial: corrections in response to reviewer

上级 7b2c5948
...@@ -306,8 +306,8 @@ To perform your tests, you may select either one of the three following methods: ...@@ -306,8 +306,8 @@ To perform your tests, you may select either one of the three following methods:
**theano-nose** **theano-nose**
The method of choice to conduct tests is to run the file ``theano-nose``. In a regular The method of choice to conduct tests is to run the file ``theano-nose``. In a regular
Theano installation, the latter will be on the operating system's path and directly accessible. Theano installation, the latter will be on the operating system's path and directly accessible
Otherwise, it can be accessed in the ``Theano/bin`` folder. The following command from any folder. Otherwise, it can be accessed in the ``Theano/bin`` folder. The following command
lines may be used for the corresponding purposes: lines may be used for the corresponding purposes:
* ``theano-nose``: Run every test found in Theano's path. * ``theano-nose``: Run every test found in Theano's path.
......
...@@ -15,7 +15,7 @@ be implemented on Theano variables: ...@@ -15,7 +15,7 @@ be implemented on Theano variables:
TypeError: object of type 'TensorVariable' has no len() TypeError: object of type 'TensorVariable' has no len()
Python requires that *__len__* returns an integer, yet it cannot be done as Theano's are symbolic variables. However, `var.shape[0]` can be used as a workaround. Python requires that *__len__* returns an integer, yet it cannot be done as Theano's variables are symbolic. However, `var.shape[0]` can be used as a workaround.
This error message cannot be made more explicit because the relevant aspects of Python's This error message cannot be made more explicit because the relevant aspects of Python's
internals cannot be modified. internals cannot be modified.
......
...@@ -51,8 +51,7 @@ components, updates = theano.scan(fn=lambda coeff, power, free_var: ...@@ -51,8 +51,7 @@ components, updates = theano.scan(fn=lambda coeff, power, free_var:
outputs_info=None, outputs_info=None,
sequences=[coefficients, full_range], sequences=[coefficients, full_range],
non_sequences=x) non_sequences=x)
#polynomial = components.sum() polynomial = components.sum()
polynomial1 = components
calculate_polynomial1 = theano.function(inputs=[coefficients, x], calculate_polynomial1 = theano.function(inputs=[coefficients, x],
outputs=polynomial) outputs=polynomial)
......
...@@ -105,7 +105,8 @@ Consider the logistic regression: ...@@ -105,7 +105,8 @@ Consider the logistic regression:
Modify and execute this example to run on CPU (the default) with floatX=float32 and Modify and execute this example to run on CPU (the default) with floatX=float32 and
time the execution using the command line ``time python file.py``. time the execution using the command line ``time python file.py``. Save your code
as it will be useful later on.
.. TODO: To be resolved: .. TODO: To be resolved:
......
...@@ -113,7 +113,7 @@ Having the graph structure, computing automatic differentiation is ...@@ -113,7 +113,7 @@ Having the graph structure, computing automatic differentiation is
simple. The only thing :func:`tensor.grad` has to do is to traverse the simple. The only thing :func:`tensor.grad` has to do is to traverse the
graph from the outputs back towards the inputs through all *apply* graph from the outputs back towards the inputs through all *apply*
nodes (*apply* nodes are those that define which computations the nodes (*apply* nodes are those that define which computations the
graph does). For each such *apply* node, its *op* defines graph does). For each such *apply* node, its *op* defines
how to compute the *gradient* of the node's outputs with respect to its how to compute the *gradient* of the node's outputs with respect to its
inputs. Note that if an *op* does not provide this information, inputs. Note that if an *op* does not provide this information,
it is assumed that the *gradient* is not defined. it is assumed that the *gradient* is not defined.
......
...@@ -60,7 +60,7 @@ The program just computes the ``exp()`` of a bunch of random numbers. ...@@ -60,7 +60,7 @@ The program just computes the ``exp()`` of a bunch of random numbers.
Note that we use the ``shared`` function to Note that we use the ``shared`` function to
make sure that the input *x* is stored on the graphics device. make sure that the input *x* is stored on the graphics device.
.. the following figures have been measured twice on BART3 on 2 Aug 2012 with no other job running simultaneously .. the following figures have been measured twice on BART3 on Aug 2nd 2012 with no other job running simultaneously
If I run this program (in check1.py) with ``device=cpu``, my computer takes a little over 3 seconds, If I run this program (in check1.py) with ``device=cpu``, my computer takes a little over 3 seconds,
whereas on the GPU it takes just over 0.64 seconds. The GPU will not always produce the exact whereas on the GPU it takes just over 0.64 seconds. The GPU will not always produce the exact
...@@ -201,7 +201,7 @@ the CPU implementation! ...@@ -201,7 +201,7 @@ the CPU implementation!
.. code-block:: text .. code-block:: text
With *flag* ``borrow=True``: With *flag* ``borrow=False``:
$ THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python using_gpu_solution_1.py $ THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python using_gpu_solution_1.py
Using gpu device 0: GeForce GTX 580 Using gpu device 0: GeForce GTX 580
...@@ -212,7 +212,7 @@ the CPU implementation! ...@@ -212,7 +212,7 @@ the CPU implementation!
1.62323296] 1.62323296]
Used the gpu Used the gpu
With *flag* ``borrow=False``: With *flag* ``borrow=True``:
$ THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python using_gpu_solution_1.py $ THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python using_gpu_solution_1.py
Using gpu device 0: GeForce GTX 580 Using gpu device 0: GeForce GTX 580
...@@ -297,7 +297,7 @@ see :ref:`aliasing`. ...@@ -297,7 +297,7 @@ see :ref:`aliasing`.
**Exercise** **Exercise**
Consider the logistic regression: Consider again the logistic regression:
.. code-block:: python .. code-block:: python
...@@ -362,7 +362,8 @@ Consider the logistic regression: ...@@ -362,7 +362,8 @@ Consider the logistic regression:
Modify and execute this example to run on GPU with ``floatX=float32`` and Modify and execute this example to run on GPU with ``floatX=float32`` and
time it using the command line ``time python file.py``. time it using the command line ``time python file.py``. (Of course, you may use some of your answer
to the exercise in section :ref:`Configuration Settings and Compiling Mode<using_modes>`.)
Is there an increase in speed from CPU to GPU? Is there an increase in speed from CPU to GPU?
......
...@@ -309,14 +309,14 @@ Test them first, as they are not guaranteed to always provide a speedup. ...@@ -309,14 +309,14 @@ Test them first, as they are not guaranteed to always provide a speedup.
Facts: Facts:
Examine and compare 'Single Op-wise' summaries for CPU and GPU. GPU ops 'GpuFromHost' (and 'HostFromGpu') by themselves Examine and compare 'Single Op-wise' summaries for CPU and GPU. GPU ops 'GpuFromHost' (and 'HostFromGpu') by themselves
consume a large amount of extra time. Furthermore, notice that each of the GPU ops consumes more time than its CPU counterpart. consume a large amount of extra time. Furthermore, notice that each of the GPU ops consumes more time than its CPU counterpart.
An additional experiment would also confirm that adding ou 'out' instance in the GPU version would only bring about a minor An additional experiment also confirms that adding an 'out' instance in the GPU version only brings about a minor
improvement in this situation. improvement in this situation.
Tentative conclusion: Tentative conclusion:
The large number of training steps (10000) generates disproportionate GPU overhead costs. The large number of external training steps (10000) generates disproportionate GPU overhead costs.
Tentative solution: Tentative solution:
Include the training steps inside the definition of the Theano functionA tentative solution would Include the training steps inside the definition of the Theano function.
Implement this solution and put it to test. Implement this solution and put it to test.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论