Speeding up actor critic training The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Moderator Election Q&A - Questionnaire 2019 Community Moderator Election ResultsTraining and Testing datasetPicking training dataActor-Critic in Discrete action spacesHow to design two different neural nets for actor and critic RL?Image segmentation training set labelingConfusion about neural network architecture for the actor critic reinforcement learning algorithmTime horizon T in policy gradients (actor-critic)Training a model for object detectionNatural actor-critic with Q function approximationmultipying negated gradients by actions for the loss in actor nn of DDPG
Road tyres vs "Street" tyres for charity ride on MTB Tandem
How do you keep chess fun when your opponent constantly beats you?
Relations between two reciprocal partial derivatives?
How did the audience guess the pentatonic scale in Bobby McFerrin's presentation?
Did the new image of black hole confirm the general theory of relativity?
Is above average number of years spent on PhD considered a red flag in future academia or industry positions?
Take groceries in checked luggage
What information about me do stores get via my credit card?
How to prevent selfdestruct from another contract
Can smartphones with the same camera sensor have different image quality?
How is simplicity better than precision and clarity in prose?
Short and long uuids under /dev/disk/by-uuid
Single author papers against my advisor's will?
Why did all the guest students take carriages to the Yule Ball?
How to copy the contents of all files with a certain name into a new file?
What are these Gizmos at Izaña Atmospheric Research Center in Spain?
how can a perfect fourth interval be considered either consonant or dissonant?
Is there a writing software that you can sort scenes like slides in PowerPoint?
Is a pteranodon too powerful as a beast companion for a beast master?
Why not take a picture of a closer black hole?
Can a novice safely splice in wire to lengthen 5V charging cable?
Windows 10: How to Lock (not sleep) laptop on lid close?
How can I protect witches in combat who wear limited clothing?
Still taught to reverse oxidation half cells in electrochemistry?
Speeding up actor critic training
The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Moderator Election Q&A - Questionnaire
2019 Community Moderator Election ResultsTraining and Testing datasetPicking training dataActor-Critic in Discrete action spacesHow to design two different neural nets for actor and critic RL?Image segmentation training set labelingConfusion about neural network architecture for the actor critic reinforcement learning algorithmTime horizon T in policy gradients (actor-critic)Training a model for object detectionNatural actor-critic with Q function approximationmultipying negated gradients by actions for the loss in actor nn of DDPG
$begingroup$
I'm simulating a very simple system, recommendation system, and I am running an actor-critic model to predict what item I should recommend next. The agent is learning and is doing just fine. However, I feel like I should be able to train faster than what I currently am.
I've looked into the A3C algorithm for training, and since I have an 8 core, 16 threaded Ryzen 7 CPU I assumed that I could simply do the hogwild updates, running several processes in parallel. However, when I run more than two processes in parallel the time it takes to execute an iteration per process becomes exponentially slower. From 0.04 seconds per iteration to over 3 seconds per iteration, when I go from two processes to three and beyond.
For now, I simulate one trajectory at a time and then I do an update to the model. What should I consider for speeding up the training? :)
I also have a powerful graphics card if that could be useful.
Parts of my code:
import torch.multiprocessing as mp
model = model_class(batch_size, position_dims, feedback_dims, args.actions_per_dim,
n_keep_old_states, tensor_input_shape, accept_no_movement=args.accept_no_movement)
model.share_memory()
processes = []
for rank in range(args.n_processes):
p = mp.Process(target=train_hogwild, args=(rank, args, model, d_model_arguments))
# We first train the model across `num_processes` processes
p.start()
processes.append(p)
for p in processes:
p.join()
and the training function run by each process:
def train_hogwild(rank, args, model, d_model_arguments, iterations= 10**7):
env = StepEnv(user_type=args.user_type, accept_no_movement=args.accept_no_movement,
actions_per_dim=args.actions_per_dim)
optimizer = optim.Adam(model.parameters(), lr=args.lr)
for i in range(iterations):
start_position = env.reset()
rewards, log_prob_list, actions, values = model.generate_trajectory(start_position, env, args.max_steps)
value_losses = model.update(optimizer, rewards, log_prob_list, values)
machine-learning reinforcement-learning training pytorch actor-critic
$endgroup$
add a comment |
$begingroup$
I'm simulating a very simple system, recommendation system, and I am running an actor-critic model to predict what item I should recommend next. The agent is learning and is doing just fine. However, I feel like I should be able to train faster than what I currently am.
I've looked into the A3C algorithm for training, and since I have an 8 core, 16 threaded Ryzen 7 CPU I assumed that I could simply do the hogwild updates, running several processes in parallel. However, when I run more than two processes in parallel the time it takes to execute an iteration per process becomes exponentially slower. From 0.04 seconds per iteration to over 3 seconds per iteration, when I go from two processes to three and beyond.
For now, I simulate one trajectory at a time and then I do an update to the model. What should I consider for speeding up the training? :)
I also have a powerful graphics card if that could be useful.
Parts of my code:
import torch.multiprocessing as mp
model = model_class(batch_size, position_dims, feedback_dims, args.actions_per_dim,
n_keep_old_states, tensor_input_shape, accept_no_movement=args.accept_no_movement)
model.share_memory()
processes = []
for rank in range(args.n_processes):
p = mp.Process(target=train_hogwild, args=(rank, args, model, d_model_arguments))
# We first train the model across `num_processes` processes
p.start()
processes.append(p)
for p in processes:
p.join()
and the training function run by each process:
def train_hogwild(rank, args, model, d_model_arguments, iterations= 10**7):
env = StepEnv(user_type=args.user_type, accept_no_movement=args.accept_no_movement,
actions_per_dim=args.actions_per_dim)
optimizer = optim.Adam(model.parameters(), lr=args.lr)
for i in range(iterations):
start_position = env.reset()
rewards, log_prob_list, actions, values = model.generate_trajectory(start_position, env, args.max_steps)
value_losses = model.update(optimizer, rewards, log_prob_list, values)
machine-learning reinforcement-learning training pytorch actor-critic
$endgroup$
add a comment |
$begingroup$
I'm simulating a very simple system, recommendation system, and I am running an actor-critic model to predict what item I should recommend next. The agent is learning and is doing just fine. However, I feel like I should be able to train faster than what I currently am.
I've looked into the A3C algorithm for training, and since I have an 8 core, 16 threaded Ryzen 7 CPU I assumed that I could simply do the hogwild updates, running several processes in parallel. However, when I run more than two processes in parallel the time it takes to execute an iteration per process becomes exponentially slower. From 0.04 seconds per iteration to over 3 seconds per iteration, when I go from two processes to three and beyond.
For now, I simulate one trajectory at a time and then I do an update to the model. What should I consider for speeding up the training? :)
I also have a powerful graphics card if that could be useful.
Parts of my code:
import torch.multiprocessing as mp
model = model_class(batch_size, position_dims, feedback_dims, args.actions_per_dim,
n_keep_old_states, tensor_input_shape, accept_no_movement=args.accept_no_movement)
model.share_memory()
processes = []
for rank in range(args.n_processes):
p = mp.Process(target=train_hogwild, args=(rank, args, model, d_model_arguments))
# We first train the model across `num_processes` processes
p.start()
processes.append(p)
for p in processes:
p.join()
and the training function run by each process:
def train_hogwild(rank, args, model, d_model_arguments, iterations= 10**7):
env = StepEnv(user_type=args.user_type, accept_no_movement=args.accept_no_movement,
actions_per_dim=args.actions_per_dim)
optimizer = optim.Adam(model.parameters(), lr=args.lr)
for i in range(iterations):
start_position = env.reset()
rewards, log_prob_list, actions, values = model.generate_trajectory(start_position, env, args.max_steps)
value_losses = model.update(optimizer, rewards, log_prob_list, values)
machine-learning reinforcement-learning training pytorch actor-critic
$endgroup$
I'm simulating a very simple system, recommendation system, and I am running an actor-critic model to predict what item I should recommend next. The agent is learning and is doing just fine. However, I feel like I should be able to train faster than what I currently am.
I've looked into the A3C algorithm for training, and since I have an 8 core, 16 threaded Ryzen 7 CPU I assumed that I could simply do the hogwild updates, running several processes in parallel. However, when I run more than two processes in parallel the time it takes to execute an iteration per process becomes exponentially slower. From 0.04 seconds per iteration to over 3 seconds per iteration, when I go from two processes to three and beyond.
For now, I simulate one trajectory at a time and then I do an update to the model. What should I consider for speeding up the training? :)
I also have a powerful graphics card if that could be useful.
Parts of my code:
import torch.multiprocessing as mp
model = model_class(batch_size, position_dims, feedback_dims, args.actions_per_dim,
n_keep_old_states, tensor_input_shape, accept_no_movement=args.accept_no_movement)
model.share_memory()
processes = []
for rank in range(args.n_processes):
p = mp.Process(target=train_hogwild, args=(rank, args, model, d_model_arguments))
# We first train the model across `num_processes` processes
p.start()
processes.append(p)
for p in processes:
p.join()
and the training function run by each process:
def train_hogwild(rank, args, model, d_model_arguments, iterations= 10**7):
env = StepEnv(user_type=args.user_type, accept_no_movement=args.accept_no_movement,
actions_per_dim=args.actions_per_dim)
optimizer = optim.Adam(model.parameters(), lr=args.lr)
for i in range(iterations):
start_position = env.reset()
rewards, log_prob_list, actions, values = model.generate_trajectory(start_position, env, args.max_steps)
value_losses = model.update(optimizer, rewards, log_prob_list, values)
machine-learning reinforcement-learning training pytorch actor-critic
machine-learning reinforcement-learning training pytorch actor-critic
asked Mar 30 at 21:22
Carl RynegardhCarl Rynegardh
321112
321112
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "557"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f48278%2fspeeding-up-actor-critic-training%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Data Science Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f48278%2fspeeding-up-actor-critic-training%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown