Comments (9)
@kaiks said "For model_name - I don't see it included in your PR ..."
I redid DQNAgent for my own purpose (essentially same) and I added the attribute 'model_name'. RLCard doesn't have it.
@kaiks said "For save_path and save_every it makes sense to store them if you just want to continue training..."
Yes, I want to continue training. I also use save_path to know where 'fig.png' and 'log.txt' and 'performance.csv' should be stored. I also have some other related files to store in that path.
from rlcard.
@billh0420 Just trying to ensure I understand it correctly. Do you mean adding these fields to the dictionary?
from rlcard.
Since these field values are not checkpointed (except for learning rate), their values will not be restored when reloaded. The learning rate probably is restored (didn't check but it seems like it would be). But, it wouldn't hurt to pass it (the learning rate) again to the DQNAgent init.
from rlcard.
`
def checkpoint_attributes(self):
'''
Return the current checkpoint attributes (dict)
Checkpoint attributes are used to save and restore the model in the middle of training
Saves the model state dict, optimizer state dict, and all other instance variables
'''
return {
'agent_type': 'DQNAgent',
'q_estimator': self.q_estimator.checkpoint_attributes(),
'memory': self.memory.checkpoint_attributes(),
'total_t': self.total_t,
'train_t': self.train_t,
'epsilon_start': self.epsilons.min(),
'epsilon_end': self.epsilons.max(),
'epsilon_decay_steps': self.epsilon_decay_steps,
'discount_factor': self.discount_factor,
'update_target_estimator_every': self.update_target_estimator_every,
'batch_size': self.batch_size,
'num_actions': self.num_actions,
'train_every': self.train_every,
'device': self.device,
# add the following:
'use_raw': self.use_raw,
'replay_memory_init_size': self.replay_memory_init_size,
'model_name': self.model_name,
'save_path': self.save_path,
'save_every': self.save_every
}
`
from rlcard.
`
@classmethod
def from_checkpoint(cls, checkpoint):
'''
Restore the model from a checkpoint
Args:
checkpoint (dict): the checkpoint attributes generated by checkpoint_attributes()
'''
print("\nINFO - Restoring model from checkpoint...")
agent_instance = cls(
replay_memory_size=checkpoint['memory']['memory_size'],
update_target_estimator_every=checkpoint['update_target_estimator_every'],
discount_factor=checkpoint['discount_factor'],
epsilon_start=checkpoint['epsilon_start'],
epsilon_end=checkpoint['epsilon_end'],
epsilon_decay_steps=checkpoint['epsilon_decay_steps'],
batch_size=checkpoint['batch_size'],
num_actions=checkpoint['num_actions'],
device=checkpoint['device'],
state_shape=checkpoint['q_estimator']['state_shape'],
mlp_layers=checkpoint['q_estimator']['mlp_layers'],
train_every=checkpoint['train_every'],
# add the following:
replay_memory_init_size=checkpoint['replay_memory_init_size'],
save_every=checkpoint['save_every'],
learning_rate=checkpoint['q_estimator']['learning_rate'],
model_name=checkpoint['model_name'],
save_path=checkpoint['save_path'],
use_raw=checkpoint['use_raw']
)
etc.
`
from rlcard.
@billh0420 It makes sense to me. I agree that it is better to restore than initiate again. Do you want me to fix it, or you fix it with a PR?
from rlcard.
I will fix it with a PR. Can I delete the line "self.use_raw = False" in the init since 'use_raw' is never referenced?
from rlcard.
@billh0420 Yes, sure. I agree with it, as it is never referenced.
from rlcard.
Hi @billh0420! I contributed the checkpoint code so I can provide some context. Thanks for your fixes.
learning_rate=checkpoint['learning_rate'],
This is actually a property of the estimator, not of the agent, and so adding it to the agent is a bit redundant.
For model_name
- I don't see it included in your PR, but we already have agent_type
. I wonder if the intention is the same?
For save_path
and save_every
it makes sense to store them if you just want to continue training, but I was building training pipelines and had to modify these every time anyway.
replay_memory_init_size
is indeed an oversight - good catch. In most cases not including it won't matter, because the agent's memory will already be full at the time of the checkpoint, so the condition:
tmp = self.total_t - self.replay_memory_init_size
if tmp>=0 #...
will always be true.
from rlcard.
Related Issues (20)
- `last_landlord_action` and `last_teammate_action` in `DoudizhuEnv` are wrong HOT 1
- 执行run_rl.py报错 HOT 2
- Leakage of actions to the other agent
- how to train mahjong game? HOT 5
- nolimitholdem Flop下注順序錯誤? HOT 1
- Question about doudizhu action space. HOT 1
- calc reward? HOT 2
- How do I run it on a Mac?
- 训练只能占一个gpu吗
- How to save agent? HOT 1
- Q: Player, Agent, Model HOT 1
- How to access the DeepCFR agent? Not seeing it in the Agents anymore + Other questions about scoping new game addition HOT 2
- Training only uses ~50% of CPU HOT 1
- can we integrate "Equim-chan / Mortal" algorithm to rlcard for mahjong games?
- In Mahjong game prediction, it appears that the order of state['current_hand'] influences the result of eval_step, what could be the reason? HOT 1
- mahjong judge_hu seems has bug
- Where is Simple Doudizhu? How to Make the Env?
- several issues about training a no-limit hold'em agent
- Suggestion to improve BJ game to mirror real life play
- Beginner question
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 rlcard.