Guest User

Untitled

a guest
Jun 23rd, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. //<![CDATA[
  2.  
  3. // a few things don't have var in front of them - they update already existing variables the game needs
  4. lanesSide = 4;
  5. patchesAhead = 25;
  6. patchesBehind = 5;
  7. trainIterations = 1000000;
  8.  
  9. // the number of other autonomous vehicles controlled by your network
  10. otherAgents = 0; // max of 10
  11.  
  12. var num_inputs = (lanesSide * 2 + 1) * (patchesAhead + patchesBehind);
  13. var num_actions = 5;
  14. var temporal_window = 0;
  15. var network_size = num_inputs * temporal_window + num_actions * temporal_window + num_inputs;
  16.  
  17. var layer_defs = [];
  18. layer_defs.push({
  19. type: 'input',
  20. out_sx: 1,
  21. out_sy: 1,
  22. out_depth: network_size
  23. });
  24. layer_defs.push({
  25. type: 'fc',
  26. num_neurons: 250,
  27. activation: 'relu'
  28. });
  29.  
  30. layer_defs.push({
  31. type: 'fc',
  32. num_neurons: 230,
  33. activation: 'relu'
  34. });
  35.  
  36.  
  37. layer_defs.push({
  38. type: 'regression',
  39. num_neurons: num_actions
  40. });
  41.  
  42. var tdtrainer_options = {
  43. learning_rate: 0.001,
  44. momentum: 0.0,
  45. batch_size: 64,
  46. l2_decay: 0.01
  47. };
  48.  
  49. var opt = {};
  50. opt.temporal_window = temporal_window;
  51. opt.experience_size = 3000;
  52. opt.start_learn_threshold = 500;
  53. opt.gamma = 0.7;
  54. opt.learning_steps_total = 10000;
  55. opt.learning_steps_burnin = 1000;
  56. opt.epsilon_min = 0.0;
  57. opt.epsilon_test_time = 0.0;
  58. opt.layer_defs = layer_defs;
  59. opt.tdtrainer_options = tdtrainer_options;
  60.  
  61. brain = new deepqlearn.Brain(num_inputs, num_actions, opt);
  62.  
  63. learn = function (state, lastReward) {
  64. brain.backward(lastReward);
  65. var action = brain.forward(state);
  66.  
  67. draw_net();
  68. draw_stats();
  69.  
  70. return action;
  71. }
  72.  
  73. //]]>
Add Comment
Please, Sign In to add comment