Skip to content
Snippets Groups Projects
Commit 5c2d8fb9 authored by Ishtiaq Ahmad's avatar Ishtiaq Ahmad
Browse files

Upload New File

parent 291f1bb6
No related branches found
No related tags found
No related merge requests found
function critic = update_critic(actornet, critic, batch, critic_lr, gamma,fed_loss)
states = cat(1, batch.state);
rewards = cat(1, batch.reward);
next_states = cat(1, batch.next_state);
action = select_action(actornet, next_states);
target_next_Q_values = predict(critic, dlarray(next_states,'BC'),action);
rewards = reshape(rewards, [],size(target_next_Q_values,2));
target_Q_values = rewards + gamma .* target_next_Q_values;
target_Q_values = reshape(target_Q_values, 1,[]);
averageGrad = [];
averageSqGrad = [];
critic_gradients = gradient_critic(critic, dlarray(states,'BC'), action,fed_loss,target_Q_values);
critic = adamupdate(critic, critic_gradients,averageGrad,averageSqGrad,1000,critic_lr);
end
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment