Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
alf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Philipp Sauer
alf
Commits
a7de949b
Unverified
Commit
a7de949b
authored
3 years ago
by
hnyu
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add snapshot section (#905)
parent
2c0a8cbf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/notes/knowledge_base.rst
+71
-0
71 additions, 0 deletions
docs/notes/knowledge_base.rst
with
71 additions
and
0 deletions
docs/notes/knowledge_base.rst
+
71
−
0
View file @
a7de949b
...
...
@@ -251,6 +251,77 @@ It is possible to directly implement a batched ``AlfEnvironment`` without follow
the above steps. `suite_carla <../api/alf.environments.html#module-alf.environments.suite_carla>`_
is such an example.
Snapshot
--------
Sometimes we might want to play an old model that was trained a long time ago,
even though ALF code has been changed since then. So by default, ALF stores a
snapshot (all python files) under the root dir of a training job. This snapshot
has a path like ``<training_root_dir>/alf``. To disable storing a snapshot, when
training or grid searching, you can specify a flag ``--nostore_snapshot`` in the
command line.
``alf.bin.play`` will by default use the current ALF code for playing. To play a
trained model with its snapshot, you can specify the flag ``--use_alf_snapshot``.
By doing so, ``alf.bin.play`` will give a higher priority to the ALF snapshot under
the training directory.
To correctly use a snapshot, it is important to avoid relative paths/imports
when writing your conf files. For example, suppose a conf file
imports ``sac_conf.py`` under the same directory, as in the following:
.. code-block:: python
# sac_conf1.py # under 'alf/examples'
import sac_conf # under 'alf/examples'
algo_cls = sac_conf.SacAlgorithm
...
When this conf is played with a snapshot, it is supposed to import the ``sac_conf.py``
file of the ALF **snapshot**. However, if ``alf.bin.play`` is run in the current
``alf/examples`` that also contains the newest version of ``sac_conf.py``,
the old (desired) ``sac_conf.py`` will be shadowed. As another example,
.. code-block:: python
# sac_conf1.py # under 'alf/examples'
import sys
sys.path.append("./sac")
import sac_conf # under 'alf/examples/sac'
algo_cls = sac_conf.SacAlgorithm
...
which will append the wrong path (depending on what the current path is) to
``sys.path`` when playing with a snapshot.
When playing with a snapshot, one thing is always guaranteed: the module ``alf``
is always under the correct python path. So you should always ensure that modules
are imported relative to the root module ``alf``. The perfectly safe way of writing
the above examples are:
.. code-block:: python
# sac_conf1.py # under 'alf/examples'
from alf.examples import sac_conf
algo_cls = sac_conf.SacAlgorithm
...
and
.. code-block:: python
# sac_conf1.py # under 'alf/examples'
from alf.examples.sac import sac_conf
algo_cls = sac_conf.SacAlgorithm
...
In this way, no matter whether you are playing with a snapshot or not, the correct
python files are used.
.. note::
When playing with a snapshot, if the behaviors are unexpected, remember to check
if you're using relative paths incorrectly.
Differences with the Tensorflow version of ALF
----------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment