Comments (1)
https://github.com/copilot/c/91bb6b3c-b325-4400-ba0e-85e87af043f7
Q: where does it perform test_episode before first train step?
A: In the BaseTrainer
class from the tianshou.trainer.base
module, testing is performed before the first training step in the reset
method. This is executed when the trainer object is initialized or made into an iterable with __iter__
.
Here is the relevant code snippet for clarification from the reset
method in the class BaseTrainer
:
def reset(self) -> None:
"""Initialize or reset the instance to yield a new iterator from zero."""
self.is_run = False
self.env_step = 0
if self.resume_from_log:
(
self.start_epoch,
self.env_step,
self.gradient_step,
) = self.logger.restore_data()
self.last_rew, self.last_len = 0.0, 0
self.start_time = time.time()
if self.train_collector is not None:
self.train_collector.reset_stat()
if self.train_collector.policy != self.policy or self.test_collector is None:
self.test_in_train = False
if self.test_collector is not None: # Testing starts here
assert self.episode_per_test is not None
assert not isinstance(self.test_collector, AsyncCollector) # Issue 700
self.test_collector.reset_stat()
test_result = test_episode(
self.policy,
self.test_collector,
self.test_fn,
self.start_epoch,
self.episode_per_test,
self.logger,
self.env_step,
self.reward_metric,
)
...
As shown, if a test_collector
is provided, it calls the test_episode
function before the first training step. This allows the model to be evaluated against a testing set before starting training. If a train_collector
is provided, it will also call the reset_stat
on the train_collector
to clear any previous statistics. If the testing policy doesn't match the training policy or no test_collector
is provided, it will not perform testing during the training phase.
from tianshou.
Related Issues (20)
- Use nbqa on notebooks HOT 2
- New html docs issue HOT 10
- Atari_PPO.py set frames_stack=1 can't run HOT 2
- Atari/Breakout render issue HOT 1
- Docu fix: `result = trainer.run()` HOT 2
- Fix CI on windows HOT 1
- puzzle about parameter set-eps HOT 1
- How to successfully run a demo HOT 12
- Hello, I want to use your platform to train the Unreal built external environment, is this possible? HOT 1
- Hierarchical Imitation Learning HOT 4
- example of a2c on atari games HOT 5
- Clean up handling of output_dim
- How to randomly collect actions from the environment in train_step HOT 6
- Wrong output of forward for custom policy HOT 1
- Support MultiBinary action space for SAC or A2C HOT 2
- Clearer separation between the trainer and the algorithm and refactoring of policy classes HOT 1
- When is the reset() function being called in tictactoe? HOT 2
- Rename state_shape to obs_shape HOT 1
- logger and save_best_fn do not work for Custom Environment HOT 1
- Regarding the error related to SEED when I train in a homebrew environment HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tianshou.