-
Notifications
You must be signed in to change notification settings - Fork 704
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
13 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
Debugging | ||
============== | ||
To make debugging simpler, you can use immediate computing mode in dynet. In this mode, every line of code gets executed immediately, just like imperative programming, so that you can find exactly where goes wrong. | ||
|
||
Further, dynet can automatically check validity of your model, i.e., detecting Inf/NaN, if it is in immediate computing mode. | ||
There are a number of tools to make debugging easier in DyNet. | ||
|
||
C++ | ||
-------------- | ||
Visualization | ||
------------- | ||
|
||
You can switch to the immediate computing mode by calling ComputationGraph::set_immediate_compute as follows: | ||
It is possible to create visualizations of the computation graph by calling the ``print_graphviz()`` function, which can be helpful to debug. When this functionality is used in Python, it is necessary to add the command line argument ``--dynet-viz``. | ||
|
||
Immediate Computation | ||
--------------------- | ||
|
||
In general, DyNet performs symbolic execution. This means that you first create the computation graph, then the computation will actually be performed when you request a value using functions such as ``forward()`` or ``value()``. However, if an error occurs during calculation, this can be hard to debug because the error doesn't occur immediately where the offending graph node is created. To make debugging simpler, you can use immediate computing mode in dynet. In this mode, every computation gets executed immediately, just like imperative programming, so that you can find exactly where goes wrong. | ||
|
||
In C++, you can switch to the immediate computing mode by calling ComputationGraph::set_immediate_compute as follows: | ||
|
||
.. code:: cpp | ||
ComputationGraph cg; | ||
cg.set_immediate_compute(true); | ||
To activate checking validity, you can add the following code after switching to immediate computing mode. | ||
Further, dynet can automatically check validity of your model, i.e., detecting Inf/NaN, if it is in immediate computing mode. To activate checking validity, you can add the following code after switching to immediate computing mode. | ||
|
||
.. code:: cpp | ||
cg.set_check_validity(true); | ||
Python | ||
-------------- | ||
These features in python are in progress. | ||
These features are still in progress for Python (`contributions are welcome! <https://github.com/clab/dynet/issues/315>`_). |