291 Commits

Author SHA1 Message Date
Arec Jamgochian
e0d205bbd7 updating experiment B vecenv 2022-02-28 21:44:10 -08:00
ebuehrle
910615cc00 Add best config from previous runs 2022-03-01 06:34:51 +01:00
ebuehrle
7a134d98c9 120 episodes per rolloout 2022-02-28 22:41:39 +01:00
ebuehrle
261e35eae8 More policy iterations per epoch 2022-02-28 22:39:28 +01:00
ebuehrle
a9314c4657 Copy over config files 2022-02-28 12:23:28 +01:00
ebuehrle
a37995694d Load policy config in evaluation 2022-02-28 12:23:02 +01:00
Arec Jamgochian
62c28d0cfa adding big tune run options 2022-02-28 03:04:59 -08:00
Arec Jamgochian
6f181a7351 Merge branch 'main' of https://github.com/sisl/InteractionImitation into main 2022-02-28 01:57:28 -08:00
Arec Jamgochian
81e38f55ab adding shail-etienne policies 2022-02-28 01:57:25 -08:00
ebuehrle
51eb810f5c COnfigure HAIL in eval_experiments 2022-02-28 10:52:26 +01:00
ebuehrle
8cc71f07de Configure HAIL in eval script 2022-02-28 10:45:19 +01:00
ebuehrle
57076793c1 Add configs for SHAIL 2022-02-28 10:43:12 +01:00
ebuehrle
da6d1d812c Add some configs 2022-02-28 10:33:10 +01:00
Arec Jamgochian
88cae70477 fixing big in loading precalculated metrics for averaging 2022-02-28 00:59:30 -08:00
Arec Jamgochian
7814c7c30d ignoring pngs 2022-02-28 00:37:30 -08:00
Arec Jamgochian
5533faab40 adding metric pkls 2022-02-28 00:36:52 -08:00
Arec Jamgochian
1ee3805aba adding trained test policies, as well as fixing evaluate script and commands 2022-02-27 23:51:12 -08:00
Arec Jamgochian
e37911eeff removing gail-trpo since performance is about the same as gail, adding experiment evaluation script, updating metric averaging to work 2022-02-27 23:03:28 -08:00
Arec Jamgochian
e110570092 adding final bc configs, updating experiment to validate in longer intervals 2022-02-27 20:40:24 -08:00
Arec Jamgochian
5f77398fd0 commiting json files and intermediate settings used to run baseline methods around 02-26, 16ocklock. Next will set off big tuning runs for gail, gailtrpo, and bc (with committed values) 2022-02-27 16:27:01 -08:00
Arec Jamgochian
2cacdf691f Merge branch 'main' of https://github.com/sisl/InteractionImitation into main 2022-02-27 14:30:32 -08:00
Arec Jamgochian
e52b658aff adding all bestconfigs from big tune run (not sure what happened in last commit) 2022-02-27 14:29:49 -08:00
Arec Jamgochian
578459e37b best_configs/hail_expA.json 2022-02-27 14:27:29 -08:00
ebuehrle
25e4d5679f Make envs independent in BC experiment 2022-02-27 22:53:12 +01:00
Arec Jamgochian
7f1557144c committing etiennes best configs, leading to 73% success rate in shail expB 2022-02-27 13:43:59 -08:00
ebuehrle
7039468e46 Add tuning script for BC. Todo: if enough GPUs, enable resources in run function 2022-02-27 17:30:33 +01:00
ebuehrle
cc3848e8e0 Remove unused parameters 2022-02-27 15:02:32 +01:00
ebuehrle
4443492d3e Add tuning script for GAIL (TRPO) 2022-02-27 14:38:40 +01:00
ebuehrle
4b4fa7e09a Add tuning script for GAIL (PPO) 2022-02-27 14:14:08 +01:00
Arec Jamgochian
569e0756ca getting loading of configs, overwriting with seeds, running with tune, and moving back to directory working. adding check for either training or testing, and allowing specification of number of test cpus to split seeds over 2022-02-27 02:25:16 -08:00
Arec Jamgochian
21cbd1c956 getting best shail/hail configs outsave up and running, adding shell for test runs 2022-02-27 01:22:39 -08:00
Arec Jamgochian
acb4fdc518 renaming shail policy file, removing ogail file since its unnecessary 2022-02-27 00:00:42 -08:00
Arec Jamgochian
3280041efa committing what is hopefully final run of sgail for both experiments, A and B 2022-02-26 23:48:58 -08:00
Arec Jamgochian
3b9051505e naming convention doesnt like env key, leakyrelu is no bueno, running quick experiment to see which option sets can work with our time left. the options that look 4s ahead are definitely out of the questions, possibly the 2s ones aswell 2022-02-26 16:02:29 -08:00
ebuehrle
71e3c5f816 Parametrize discriminator architecture 2022-02-26 14:53:29 +01:00
ebuehrle
35e6fb299c Use collision rate as main metric 2022-02-26 14:28:58 +01:00
ebuehrle
1e24612347 Merge branch 'main' of https://github.com/sisl/InteractionImitation 2022-02-26 14:06:22 +01:00
ebuehrle
6876cf9625 Track collision rate 2022-02-26 13:50:53 +01:00
ebuehrle
dc9cbf329b Enable safe options on evaluation env 2022-02-26 12:24:25 +01:00
ebuehrle
f9d3cceed5 Save checkpoints and config to folder, move params to config 2022-02-26 12:23:42 +01:00
Arec Jamgochian
c28c6c05b7 added ogail script and splitting up feasability on next line to avoid calculating it unnecessarily (though it might be fine as is) 2022-02-25 18:39:33 -08:00
Arec Jamgochian
fa98601fa6 fixing issues with lazylinear sequential, setting off a big run 2022-02-25 17:48:56 -08:00
Arec Jamgochian
2dfd7e3c2b add policy saving 2022-02-25 17:00:46 -08:00
Arec Jamgochian
59083ebce3 making option list indexable to visualize in tensorboard. noticing run from last night had much better performance under more long options, unclear if due to choice or environment factors, like episodes lasting longer. making stoponcollision and seed parameters. fixing ability to see reward metrics under ray/tune/, problem was they were being returned as tensors, not floats 2022-02-25 16:36:14 -08:00
Arec Jamgochian
d1f23e6d25 readding expertdata to gitignore, just manually adding expert joint state and action files 2022-02-25 01:27:02 -08:00
Arec Jamgochian
46564231ef changing gitignore to upload expert data for evaluation, adding multiple roundabout trackfile environments in vecenv 2022-02-25 01:21:16 -08:00
Arec Jamgochian
bf9ce84fe4 changing when directory name gets saved 2022-02-25 00:42:44 -08:00
Arec Jamgochian
99aa50a08b added support for different activations, number of hidden layers, options, running a big run over this 2022-02-25 00:00:04 -08:00
Arec Jamgochian
7feea74eb8 adding stablebaselines, adding safe loading for nonCuda cluster 2022-02-24 23:18:02 -08:00
ebuehrle
5a5d8a7aff WIP: Support different plan lengths 2022-02-25 01:32:54 +01:00
ebuehrle
02c1813b00 Incrementing agent expert data, smaller policy network 2022-02-25 01:23:15 +01:00
Johannes Fischer
0d193d4af3 Scratch for horner scheme 2022-02-24 15:12:29 +01:00
ebuehrle
febceed651 Add expert data 2022-02-23 18:17:30 +01:00
ebuehrle
336cf02278 Parameterize hidden layer size of policy, add some candidates to grid search 2022-02-23 18:14:23 +01:00
ebuehrle
7f64ec7bb0 Move hyperparameters to config object
ToDo: parameterize network architectures
2022-02-23 18:00:19 +01:00
ebuehrle
406c4ad9ee Fix tune by moving file 2022-02-23 17:41:41 +01:00
ebuehrle
f037c119cc Set up for ray tune 2022-02-23 16:55:13 +01:00
ebuehrle
91f88983b0 Add learning rate schedule to SHAIL-PPO 2022-02-23 14:22:02 +01:00
Arec
68b066ec53 adding success rate, total distance, and survive time 2022-02-22 00:48:35 -08:00
Arec
e7f4f6a871 wrapping all environments in timelimit to stop runs longer than 100s, since some others were erroring 2022-02-21 17:54:29 -08:00
Arec
e7f8385628 updating rwse to work at different times, updating correct testing environment from roundabout, removing the assertion that a collision implies done in the evaluator, using nanmean and nanstd in averaging 2022-02-21 15:55:16 -08:00
ebuehrle
daa4825f17 Add GAIL-PPO 2022-02-21 22:21:13 +01:00
ebuehrle
a89317e1d5 Correct checkpoint file path 2022-02-21 22:11:34 +01:00
ebuehrle
b89f5db9d8 Add SHAIL policy with more options 2022-02-21 22:07:44 +01:00
ebuehrle
953a93a541 Add two checkpoints for SHAIL-PPO 2022-02-21 17:33:08 +01:00
ebuehrle
a242edc5d3 Fix predict for reparameterized modules
Better way would probably be to rewrite flat_grad and reparam
2022-02-21 13:29:53 +01:00
ebuehrle
2da0e05782 Implement rwse 2022-02-21 11:05:19 +01:00
Arec
8c4ff03208 adding average absolute delta v, and tracking positions and setting up architecture to implement rwse 2022-02-21 00:06:39 -08:00
Arec
d2932951f6 adding metric saving and averaging over seeds 2022-02-20 23:22:46 -08:00
Arec Jamgochian
a7102a29df Merge pull request #4 from sisl/options
Integrate options env and policy
2022-02-20 20:20:28 -08:00
ebuehrle
ce22516893 Fix imports 2022-02-18 10:18:10 +01:00
ebuehrle
84351e77f2 Add SHAIL-PPO 2022-02-18 06:54:52 +01:00
ebuehrle
1624e1a349 Add SHAIL 2022-02-17 23:51:40 +01:00
ebuehrle
9de6bfe9a3 Add GAIL 2022-02-17 22:58:00 +01:00
ebuehrle
cd58ce2898 Remove old code 2022-02-17 22:43:41 +01:00
ebuehrle
5bd8b42d9f Merge updated files 2022-02-17 22:41:55 +01:00
ebuehrle
b78f95bab5 More checkpoints, adjustments for collision check 2022-02-16 10:19:50 +01:00
ebuehrle
c5e68ca33a Add model checkpoint 2022-02-15 22:01:28 +01:00
ebuehrle
c6a4c10605 Integrate options env and policy 2022-02-15 18:36:53 +01:00
ebuehrle
072c0ff417 Copy files 2022-02-15 14:03:22 +01:00
ebuehrle
a3b9b3e250 Port TRPO, PPO, GAIL 2022-02-15 11:07:08 +01:00
Arec
530ac95d61 Merge branch 'test' into main 2022-02-05 21:50:16 -08:00
Arec
3e6fce42ee BUG FIXES: moving around when policy is loaded, adding BaseAlgorithm abstract classes, correcting metrics, normalizng actions if idm environment is a normalized action one, manually updating environment graph when using idm, implementing idm forward class 2022-02-05 21:48:56 -08:00
Arec
795e1c08b6 adding metric comparisons and updating (note: pre-debug) init 2022-02-04 15:51:17 -08:00
Arec
d1f9e3d7c4 adding main test sequence. must debug and add summary and comparison metric generators tomorrow 2022-02-02 22:29:05 -08:00
Arec
31912416f1 adding pbar to evaluator and making metric save optional, adding typing to baselines 2022-02-02 22:19:40 -08:00
Arec
3ce86b31f7 adding Prop controller and IDMRulePolicy 2022-02-02 15:43:23 -08:00
Arec
3991306da0 updating evaluation wrapper to only store relevant variables during execution 2022-01-31 16:28:13 -08:00
ebuehrle
a60cc18874 PPO lidar + random agent 2022-01-22 08:05:16 +01:00
ebuehrle
18af0de2a4 Add experiment for PPO on lidar observations 2022-01-22 07:49:48 +01:00
ebuehrle
52d4b5a36c Refactor LL buffer 2022-01-21 10:22:33 +01:00
Arec
3b60c14319 removing old implementation for rollout_and_save, and helper functions that were necessary for it 2022-01-18 18:03:38 -08:00
Arec
427a9e4f1b adding rollout and trajectory flattening utilities. including old implementation in this commit 2022-01-18 17:53:56 -08:00
Arec
2c1dc6ca33 committing changes to start testing framework, removing shuffling of data 2022-01-17 15:47:40 -08:00
Arec
d34fa5774d adding functions to save joint expert states and actions for repeated use in metrics, adding option to flatten loaded trajectories, adding class to not shuffle trajectories when saving experts to make sure it lines up with the joint states. checked that it does 2021-11-29 14:09:57 -08:00
ebuehrle
284d4af637 Train discriminator 2021-11-10 11:54:41 +01:00
Arec
6c3a7b903e adding test structure 2021-11-09 09:48:45 -08:00
Arec
a07050a748 fixing rendering system and main script to align with new repo changes 2021-11-09 07:15:07 -08:00
Arec
5799d095d9 adding tools to render directly from a policy, updating data generator, adding scratch files 2021-11-09 06:28:42 -08:00
ebuehrle
4c8fb77a91 Larger batches 2021-11-06 18:49:00 +01:00
ebuehrle
bc774c54ca Refactor LL buffer 2021-11-06 16:43:45 +01:00
ebuehrle
b634a34461 RMSprop + weight decay, no discount, action noise 2021-11-05 15:56:33 +01:00
ebuehrle
4a69322ed0 Move eps to constructor 2021-11-05 10:32:07 +01:00
ebuehrle
4ee960b104 Fix rendering 2021-11-05 08:35:14 +01:00
ebuehrle
071c731921 More expert data 2021-11-04 19:54:40 +01:00
ebuehrle
081fb4e6ab Sample with replacement 2021-11-04 19:54:14 +01:00
ebuehrle
f794a96112 Sample expert data from same distribution 2021-11-04 18:52:08 +01:00
ebuehrle
9a95134530 Remove rasterized speed 2021-11-04 17:21:10 +01:00
ebuehrle
0990eb808a Larger batches 2021-11-04 11:01:06 +01:00
ebuehrle
361c1ea9d3 Add speed, then accumulate, skip 5 frames 2021-11-03 17:49:59 +01:00
ebuehrle
2718f52941 Improve custom env support 2021-11-03 17:48:27 +01:00
ebuehrle
ba850eadbb Move rasterized speed env to scratch 2021-11-03 08:48:19 +01:00
ebuehrle
06fb1afae4 Random skip, longer horizon 2021-11-02 16:48:31 +01:00
ebuehrle
2aaaad36f0 Fix rendering
- support predict()
- move discount to OptionsEnv
- fix RenderOptions
2021-11-02 16:15:34 +01:00
ebuehrle
6416fceb60 Fix horizon 2021-11-02 12:57:40 +01:00
ebuehrle
a1ae103ab4 Merge branch 'options-env' into dev 2021-11-02 10:18:33 +01:00
ebuehrle
66c10f5280 Make options env compatible with PPO 2021-11-02 09:33:16 +01:00
ebuehrle
e37447caff Increase discriminator batch size and update steps 2021-10-29 16:33:06 +02:00
ebuehrle
2e8c7f1ace Use rasterized speed 2021-10-29 16:09:03 +02:00
ebuehrle
fc2cd936a8 Copy options to scratch 2021-10-29 14:56:33 +02:00
ebuehrle
8dd42abbf3 use discriminator preprocessing 2021-10-29 14:31:10 +02:00
ebuehrle
92981ba284 Change batch size and discriminator updates
Training not successful
2021-10-29 11:54:32 +02:00
Johannes Fischer
fb7e841dc3 Merge branch 'main' of github.com:sisl/InteractionImitation 2021-10-29 11:35:08 +02:00
ebuehrle
4317cee272 Check emergency braking in available actions 2021-10-29 11:31:38 +02:00
ebuehrle
cedb95dd57 Vectorize action propagation 2021-10-29 11:17:16 +02:00
ebuehrle
e57da1338a Check emergency braking in available actions 2021-10-29 11:10:42 +02:00
ebuehrle
999cb80e13 Merge branch 'vectorize-propagation2' 2021-10-29 11:07:14 +02:00
ebuehrle
5bdf85562b Merge branch 'main' into dev 2021-10-29 10:54:21 +02:00
Johannes Fischer
673b565e11 Update scratch 2021-10-28 18:31:52 +02:00
Johannes Fischer
1a1f6d8836 Merge branch 'main' of github.com:sisl/InteractionImitation 2021-10-28 18:17:47 +02:00
Johannes Fischer
e36aaef9f2 Move and add scratch scripts 2021-10-28 18:16:17 +02:00
Johannes Fischer
0077c24074 precompute expert features 2021-10-28 18:16:00 +02:00
ebuehrle
b1740764e3 Parameterize number of discriminator updates per epoch 2021-10-28 17:58:42 +02:00
ebuehrle
8d7409c914 Check emergency braking in available actions 2021-10-28 17:54:58 +02:00
ebuehrle
f9e058a7d9 Vectorize available actions computation 2021-10-28 15:47:39 +02:00
Johannes Fischer
070b8fc785 Cleanup 2021-10-28 13:49:14 +02:00
Johannes Fischer
c5b043c49f Cleanup 2021-10-28 13:47:54 +02:00
Johannes Fischer
8703b11dee import evaluation 2021-10-28 13:31:30 +02:00
Johannes Fischer
1bab1aaab7 Cleanup evaluation 2021-10-28 13:31:08 +02:00
Johannes Fischer
7ffcc0b4b8 Extract evaluation code to separate file 2021-10-28 13:29:00 +02:00
Johannes Fischer
2218d14409 Move metrics 2021-10-28 13:26:17 +02:00
Johannes Fischer
f217daf251 update evaluation 2021-10-28 13:10:44 +02:00
Johannes Fischer
09afee4e1d Add first metrics 2021-10-28 09:55:20 +02:00
Johannes Fischer
214c6daeaa Merge branch 'main' of github.com:sisl/InteractionImitation 2021-10-28 09:45:27 +02:00
Johannes Fischer
d89c77409c Add some scratch 2021-10-28 09:43:55 +02:00
Johannes Fischer
3857716cec Rename predict to forward
This is done to be consistent with stable baselines interface. predict is then automatically defined. This is necessary to use stable baselines' evaluate_policy method
2021-10-28 09:42:27 +02:00
Johannes Fischer
71f69c43ed Fix typo in dataset folder name 2021-10-28 09:40:52 +02:00
Johannes Fischer
351b22fe01 Optionally include infos in expert data 2021-10-28 09:40:20 +02:00
ebuehrle
039f8a7643 Adapt expert for RandomLocations environment 2021-10-27 13:56:20 +02:00
ebuehrle
97b98cb52e Add experiment for random locations 2021-10-27 13:55:40 +02:00
ebuehrle
bcddf422f0 Move files to src 2021-10-26 17:41:05 +02:00
ebuehrle
24b91d4eec Add route, increase resolution 2021-10-26 13:18:09 +02:00
ebuehrle
9a1038d832 Add experiment for options gail on random agents 2021-10-26 13:13:20 +02:00
ebuehrle
82407d5222 Refactor options GAIL training script 2021-10-26 12:37:10 +02:00
ebuehrle
1f506baa48 Rename combined tracks experiment 2021-10-26 11:31:24 +02:00
Johannes Fischer
8ce4c0c951 Merge branch 'main' of github.com:sisl/InteractionImitation 2021-10-22 09:36:57 +02:00
Arec
03478b7ed9 adding comments to gail_options_image, combining environments for options gail, and fixing bug where last state is yielded in hl buffer 2021-10-21 18:05:03 +02:00
Arec
ba79de58b8 moving feasibility checkers into src.util.collisions, and doing expert processing using the tools in src.data.expert 2021-10-21 07:01:12 -07:00
Arec
06785236d4 fixing expert data combiner and adding feasibility checking with all options to util.collisions 2021-10-21 06:59:21 -07:00
Arec
2d8928f2ae updating data processing scripts to output to the correct location 2021-10-21 06:29:43 -07:00
Arec
05b31092f4 moving options policy to policies, commenting options image, and making the calls to train more flexible 2021-10-21 05:59:28 -07:00
Arec
45a99978e4 adding discriminators to main folder, utilities to render a video from a saved model 2021-10-21 05:33:05 -07:00
Arec
da1fb11269 adding functions to process expert data across locations and tracks in intersimple environment 2021-10-21 05:21:06 -07:00
Arec
dcf8212028 adding comments to gail_options_image, combining environments for options gail, and fixing bug where last state is yielded in hl buffer 2021-10-20 12:28:12 -07:00
Johannes Fischer
bef6d6db55 Merge branch 'main' of github.com:sisl/InteractionImitation 2021-10-20 13:03:21 +02:00
Johannes Fischer
7b900d6260 Add exact two-stage collision checking method 2021-10-20 12:02:25 +02:00
Johannes Fischer
73a160fa7a Fix /ray/ gitignore 2021-10-20 11:42:14 +02:00
Arec
b61e4a5002 adding multi-circle collision checker 2021-10-19 07:21:10 -07:00
ebuehrle
eae8c7f3f4 Fix mask computation 2021-10-19 09:35:14 +02:00
ebuehrle
466e6b6ce7 No-mask options GAIL 2021-10-18 13:28:32 +02:00
Arec
62bfe797a4 adding function to load experts and combine them into single transition list 2021-10-15 02:47:52 -07:00
Arec
ffb16cfc31 updating function to process all expert data from track files, starting processing options policy from file 2021-10-15 02:39:49 -07:00
Arec
415d607418 making the expert demonstration processor go through all agents in order when producing a single (default) trajectory file, using a randomized agent environment in optionsgail, starting function to process and store all expert data 2021-10-13 11:20:40 -07:00
Arec
70e55327dc fixing flataction discriminator to convert to float beforehand, adding necessary forward calls in expert, adding Fire to video creator from model, and trying full run of options gail with new discrimination model 2021-10-11 08:47:18 -07:00
Arec
01752fac12 adding model to append actions to encoded image state for discriminator, files to test different environment experiments, and a script to render an environment from a saved model 2021-10-11 07:14:03 -07:00
Johannes Fischer
244b85a06e Add larger expert dataset creation command 2021-10-08 18:23:59 +02:00
Johannes Fischer
8a67d3536e Add ray directory to gitignore 2021-10-08 18:20:20 +02:00
Johannes Fischer
c59da3611c Use ray tune in gail 2021-10-08 18:19:08 +02:00
Johannes Fischer
6d2ab54b6e Add callback to gail image random to report metrics
Currently nothing is reported yet
2021-10-08 18:18:42 +02:00
Johannes Fischer
4b9a81080b Add missing * in **kwargs 2021-10-08 18:17:02 +02:00
ebuehrle
59681cb16f Merge pull request #3 from sisl/refactor-sampling
Refactor sampling
2021-09-15 09:08:13 +02:00
ebuehrle
4928458e08 Fix discriminator reward
Had wrong sign.
2021-09-15 07:15:43 +02:00
ebuehrle
40da84393c Update imitation version 2021-09-14 18:04:53 +02:00
ebuehrle
183657dc36 Fix buffer bug, add test
Buffer was not being cleared between plan rollouts
2021-09-14 17:55:02 +02:00
ebuehrle
d2932374d9 Refactor sampling 2021-09-14 13:42:25 +02:00
Johannes Fischer
763a7bb0d3 Merge branch 'main' of github.com:sisl/InteractionImitation 2021-09-14 11:01:24 +02:00
ebuehrle
deaef45943 Add test for discriminator 2021-09-14 07:19:58 +02:00
Johannes Fischer
2280597db6 Add GAIL with random agent data 2021-09-13 19:42:41 +02:00
ebuehrle
7eae74a7d8 Switch back to additive reward 2021-09-13 17:55:50 +02:00
johannes-fischer
b0b358544f Merge pull request #2 from sisl/fischer/fusion_sample_methods
Merge different methods to sample the policy and collect transitions
2021-09-13 16:51:16 +02:00
Johannes Fischer
9c7e6cef3a Rename action to option 2021-09-13 16:43:45 +02:00
Johannes Fischer
9b8ceed9c9 Render only one episode 2021-09-13 16:31:24 +02:00
Johannes Fischer
826c0fa219 Merge different methods to sample the policy and collect transitions 2021-09-13 15:50:49 +02:00
ebuehrle
f1ece358d7 Speed up collision check, assume 0 is fallback option
Due to the conservative approximation of the collision check,
no option might be feasible, thus the necessity of a guaranteed fallback.
2021-09-13 09:35:49 +02:00
ebuehrle
87ff3dbb93 Add cuda support, normalize actions 2021-09-11 21:32:30 +02:00
ebuehrle
e7b0aea427 run options gail 2021-09-11 21:32:25 +02:00
Johannes Fischer
8ad7457159 Merge branch 'main' of github.com:sisl/InteractionImitation 2021-09-10 11:38:31 +02:00
Johannes Fischer
544ea4d15a Allow variable horizon trajectories 2021-09-10 11:37:34 +02:00
Johannes Fischer
9a107b165a Allow variable horizon trajectories 2021-09-10 11:34:36 +02:00
Johannes Fischer
b2b2abafa2 Fix typo 2021-09-10 11:34:13 +02:00
ebuehrle
5ff4b42c0e Fix imports 2021-09-08 20:45:45 +02:00
ebuehrle
3a6139286d Update .gitignore 2021-09-08 20:31:45 +02:00
ebuehrle
50916aec05 Vanilla GAIL on rasterized observation 2021-09-08 20:30:11 +02:00
ebuehrle
802d4a4301 Try lower image resolution 2021-09-08 20:26:54 +02:00
ebuehrle
f94ec9a4dc Add test for discriminator 2021-09-08 20:23:39 +02:00
Arec
de5877aaad filling in available_actions, generate_plan, and feasible helpers 2021-09-08 05:14:15 -07:00
ebuehrle
1fd0a71646 Draft Options GAIL 2021-09-08 11:21:25 +02:00
ebuehrle
d89e491b92 Remove debug print statement 2021-09-07 19:20:28 +02:00
ebuehrle
e9f09cacb7 Add option to render expert rollout 2021-09-07 19:19:53 +02:00
ebuehrle
88e0b99d7e Add script for data generation 2021-09-07 19:18:59 +02:00
ebuehrle
a70907c0fd Copy over experiments 2021-09-01 16:07:15 +02:00
Johannes Fischer
317d329765 Add shell script for value dice training 2021-08-06 18:53:32 +02:00
Johannes Fischer
88b4466e57 MInor change in value dice loss, activate print statements, only do EITHER value OR policy update for each batch 2021-08-06 18:52:17 +02:00
Johannes Fischer
025c71767f Change final value network activation to identity 2021-08-06 18:48:53 +02:00
Johannes Fischer
66bfba3986 Minor formatting 2021-08-05 18:37:54 +02:00
Johannes Fischer
6afb112277 Bugfix in value dice
FIRST backward() has to be called on both, policy and value, before step() is called for either of them
2021-08-05 18:35:14 +02:00
Johannes Fischer
bf4c19a4d0 Add value dice ray config 2021-08-05 18:33:34 +02:00
Johannes Fischer
8bce5d15f6 Restore train_epochs to 200 instead of 8 2021-08-05 18:32:46 +02:00
Johannes Fischer
40c55478f3 Bugfixes in valuedice 2021-08-04 20:53:03 +02:00
Johannes Fischer
2224e2cd14 Merge branch 'main' of github.com:sisl/InteractionImitation 2021-08-04 19:44:55 +02:00
Johannes Fischer
5c40de66fa Implement ValueDICE and some restructuring 2021-08-04 19:34:49 +02:00
Arec
f9729b0a9d making expert data save s, a, sp. making dataloader also load batches thisway. renaming state to ego_state. converting path_x and path_y to single path variable. making number of samples for ray an argument. adjusting metrics, policy, and other functions to be able to handle this 2021-08-04 09:45:36 -07:00
Etienne Buehrle
7ae01f73a2 AdVIL tests 2021-08-04 16:41:18 +02:00
Johannes Fischer
cba42c6e4d Set default divergence to histogram based 2021-08-03 17:18:30 +02:00
Johannes Fischer
5919a4e439 Use JS divergence in metrics 2021-08-03 17:04:47 +02:00
Johannes Fischer
1ee46214a7 Implement jenson shannon divergence 2021-08-03 17:03:37 +02:00
Johannes Fischer
1916a8fe69 Implement metrics and write to tensorboard summary at test time 2021-08-03 15:24:29 +02:00
Arec
98294e0c95 Merge branch 'main' of https://github.com/sisl/InteractionImitation into main 2021-08-03 03:28:23 -07:00
Arec
943e8cda26 adding output directory to parse arguments 2021-08-03 03:28:11 -07:00
Arec
6e524cf4b5 adding options for regularization and relative state masking via interaction graphs during data processing and experiment running. found 0.002 regularization on actions gives up to 3m of deviation with no collisions. added shell script to run ray experiments overnight 2021-08-02 14:38:06 -07:00
Johannes Fischer
b869597717 extend comment on divergence 2021-08-02 19:15:02 +02:00
Johannes Fischer
f468b3b7a4 Implement histogram based kl divergence computation 2021-08-02 19:14:40 +02:00
Johannes Fischer
9dd655bc75 test out kd divergence estimate based on CV-KDE (very slow) 2021-08-02 17:38:52 +02:00
Johannes Fischer
6177b1f7e1 Add kl_cat 2021-08-02 11:12:24 +02:00
Johannes Fischer
4ea4d42df7 Merge branch 'main' of github.com:sisl/InteractionImitation 2021-08-02 11:08:35 +02:00
Johannes Fischer
281f7773c4 Implement kl divergence methods and tests 2021-08-02 11:04:03 +02:00
Johannes Fischer
99f7df2e7c Add comment 2021-07-30 18:19:29 +02:00
Johannes Fischer
367f72ec46 Imrove print output 2021-07-30 18:19:15 +02:00
Arec
fb91ee1a62 Merge branch 'main' of https://github.com/sisl/InteractionImitation into main 2021-07-30 05:17:43 -07:00
Arec
5fcd3f49da adding hyperopt tuning 2021-07-30 05:17:38 -07:00
Johannes Fischer
bd5e854720 Add collision and avg velocity metrics 2021-07-30 13:35:42 +02:00
Arec
e30d0ab1ba removing outliers from expert tracks 2021-07-29 08:20:40 -07:00
Arec
3b4ef6ffb5 adding tool for visualizing acceleration distributions, and making nframes an arg 2021-07-29 07:35:21 -07:00
Johannes Fischer
afc3719ab9 Fix bug with wrong argument order 2021-07-29 15:30:55 +02:00
Johannes Fischer
3b623a1467 Add testing script for raytune experiments 2021-07-29 15:30:41 +02:00
Johannes Fischer
35634fd2eb Separate experiment from main.py 2021-07-29 14:40:19 +02:00
Arec
e47d69dbc1 changing relative state dim to 6 2021-07-29 02:54:41 -07:00
Arec
fdbdc7f9f0 making data processing happen on front end, not on data loader. saving a ton of time 2021-07-29 02:53:20 -07:00
Arec
09f77e0587 changing how tune reporting works so the scheduler doesnt break if itcant find cv loss. also fixed bug in config structure that was rendering impossible policies 2021-07-28 09:55:11 -07:00
Arec
5a7090a21c Merge branch 'main' of https://github.com/sisl/InteractionImitation into main 2021-07-27 14:32:52 -07:00
Arec
87aa19b86b getting hyperparameter tunning with ray tune working. updating default network with optimization and general parameters. 2021-07-27 14:30:28 -07:00
Johannes Fischer
2bd638c247 Test for batch data in test_deepsets_policy 2021-07-27 12:37:40 +02:00
Arec
ca80fa19eb Merge branch 'main' of https://github.com/sisl/InteractionImitation into main 2021-07-26 07:52:19 -07:00
Arec
d9436daaba changing default network, making deepsets network choose output dimension appropriately, making bc config to be called by ray 2021-07-26 07:52:11 -07:00
Johannes Fischer
5e89a83c88 Fix tests 2021-07-26 16:35:45 +02:00
Arec
69359b5af3 periodically savingin out model and adding functionality to make identity Phi networks (for 0-dim NNs) 2021-07-26 05:51:08 -07:00
Arec
7b2ca6edc7 adding tensorboard writer for training loss and cv loss 2021-07-26 02:38:50 -07:00
Arec
969812c5cc Merge branch 'main' of https://github.com/sisl/InteractionImitation into main 2021-07-23 04:44:57 -07:00
Arec
5b09374c77 getting training and testing loop working, adding tqdm to simulator, and reduced number of frames, updating readme 2021-07-23 04:44:50 -07:00
Johannes Fischer
8a4094037a update forward pass test 2021-07-23 11:16:08 +02:00
Arec
acd2b730a6 adding transforms to test case 2021-07-23 01:38:20 -07:00
Arec
5c15ec2db1 Merge branch 'main' of https://github.com/sisl/InteractionImitation into main 2021-07-23 01:28:07 -07:00
Arec
9c7fc47abe updating test batch 2021-07-23 01:27:57 -07:00
Johannes Fischer
5d3b3fa1bc Merge branch 'main' of github.com:sisl/InteractionImitation 2021-07-23 09:30:26 +02:00
Johannes Fischer
9b0aeb182f Add .vscode to gitignore 2021-07-23 09:30:23 +02:00
Arec
563a2cfbd4 making a differentiable transform for use for pytorch, making sure the fitting function treats nans properly while fitting. next issue: forward pass is returning nans 2021-07-22 12:37:36 -07:00
Arec
08eb898812 adding dtypes and fixing matrix indexing 2021-07-22 12:06:42 -07:00
Johannes Fischer
1c22bd6111 bugfix in deepsets 2021-07-22 18:44:12 +02:00
Arec
91d052445e making test case for typing bug and fixing some small typing errors in bc 2021-07-22 08:23:46 -07:00
Johannes Fischer
827a8e7172 bugfix in Phi module
nn.ModuleList has to be used in order to register layer parameters as module parameters (similar to add_module)
2021-07-22 14:33:05 +02:00
Arec
1ca9914bf9 fixing bugs in transform, expert demo processing, main train function, and behavior cloning class. need to get bc class parameters to return nonempty list 2021-07-21 09:44:20 -07:00
Arec
5758af5dd8 Merge branch 'main' of https://github.com/sisl/InteractionImitation into main 2021-07-21 08:22:15 -07:00
Arec
18b8e0c58f updating main testing function to use configs and seeds, finishing first pass at behavior cloning policy and training loop. not yet tested 2021-07-21 08:22:08 -07:00
Arec
4350cf8cd5 defining transform class to do tensor size manipulation before and after transform 2021-07-21 08:20:55 -07:00
Arec
3422e9c9ef exporting policy class and letting default final activation do nothing 2021-07-21 08:20:15 -07:00
Johannes Fischer
c939a8e131 Remove todo 2021-07-20 18:45:49 +02:00
Johannes Fischer
ca0f520c89 Merge branch 'main' of github.com:sisl/InteractionImitation 2021-07-20 18:44:11 +02:00
Johannes Fischer
61f06c95c2 Improve deepsets module
module can now deal with nan values for nonexisting relative states
in case all relative states are nan, the latent representation is zeroed, which is consitent with an empty sum
2021-07-20 18:44:07 +02:00
Johannes Fischer
ffdff12ccb Update deepsets to deal with nans (first version) 2021-07-20 18:23:51 +02:00
Arec
6794b4cad8 making saving and loading functions class requirements, working on behavior cloning policy class and training function 2021-07-20 08:29:00 -07:00
Arec
1a74fa5237 making general-purpose metric function 2021-07-20 07:05:09 -07:00
Johannes Fischer
226a427436 Adapt policy input format 2021-07-20 15:45:15 +02:00
Johannes Fischer
7109afb21f Merge branch 'main' of github.com:sisl/InteractionImitation 2021-07-20 15:25:10 +02:00
Johannes Fischer
8534e8a437 Update scratch space 2021-07-20 15:25:07 +02:00
Johannes Fischer
ba10a1f53b Implement transforms for normalization 2021-07-20 15:24:34 +02:00
Arec
a15e8c29ff moving transforms out of dataset class, will be exclusively in policy classes 2021-07-20 06:16:54 -07:00
Arec
2fb5d5e5b1 developing main experiment loop, functions required to implement in bc and other imitation methods 2021-07-20 05:58:24 -07:00
Arec
c0755f5bb5 Merge branch 'main' of https://github.com/sisl/InteractionImitation into main 2021-07-20 05:46:47 -07:00
Arec
2e29f42d75 add flag to process all tracks of a particular location 2021-07-20 05:46:43 -07:00
Johannes Fischer
ee7b6b607f Fix deprecation warning in sigmoid 2021-07-20 12:52:02 +02:00
Johannes Fischer
a9c6857b5b torchvision normalization example 2021-07-20 12:48:42 +02:00
419 changed files with 21794 additions and 331 deletions

10
.gitignore vendored
View File

@@ -1,3 +1,10 @@
*.png
*.pkl
*.pt
*.zip
**/ray/*
**/runs/*
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
@@ -119,6 +126,7 @@ venv.bak/
# VS Code project settings
.project
.vscode
# mkdocs documentation
/site
@@ -140,6 +148,8 @@ expert_data/
# Results
experiments/results/
output/
# Dependencies
InteractionSimulator/
imitation/

View File

@@ -24,8 +24,26 @@ Once the repository has been set up, you can process and save expert track demon
```
python src/expert_data.py --loc [LOCNUM] --track [TRACKNUM]
```
You can (and should) process all tracks at once at location 0 with:
```
python src/expert_data.py --all-tracks
```
You can then load the experts actions and observations using
You can then train a default behavior cloning policy with the following. Be sure to check help for main.py for running options.
```
python src/main.py --train
```
You can run tensorboard by running the following and opening `localhost:6006` (or alternatively port-forwarding 6006 from the remote server)
```
tensorboard --logdir output/
```
You can then test the learned policy with the following, and see the animation file in `output/`:
```
python src/main.py --test
```
You can load the experts actions manually
```
from src import expert_data
observations, actions = expert_data.load_expert_data(loc = [LOCNUM], track = [TRACKNUM])

212
bc-experiment.py Normal file
View File

@@ -0,0 +1,212 @@
# %%
import os
from tqdm import tqdm
from src.core.sampling import rollout
from src.core.gail import gail_ppo, Buffer
from src.core.value import SetValue
from src.core.policy import SetPolicy
from src.core.discriminator import DeepsetDiscriminator
import torch
from intersim.envs import IntersimpleLidarFlatRandom
from intersim.envs.intersimple import speed_reward
import functools
from src.util.wrappers import CollisionPenaltyWrapper, TransformObservation, Setobs
import numpy as np
from torch.utils.tensorboard import SummaryWriter
from ray import tune
from datetime import datetime
import json
DIR = os.path.dirname(os.path.abspath(__file__))
activations = [torch.nn.Tanh, torch.nn.LeakyReLU]
obs_min = np.array([
[-1000, -1000, 0, -np.pi, -1e-1, 0.],
[0, -np.pi, -20, -20, -np.pi, -1e-1],
[0, -np.pi, -20, -20, -np.pi, -1e-1],
[0, -np.pi, -20, -20, -np.pi, -1e-1],
[0, -np.pi, -20, -20, -np.pi, -1e-1],
[0, -np.pi, -20, -20, -np.pi, -1e-1],
]).reshape(-1)
obs_max = np.array([
[1000, 1000, 20, np.pi, 1e-1, 0.],
[50, np.pi, 20, 20, np.pi, 1e-1],
[50, np.pi, 20, 20, np.pi, 1e-1],
[50, np.pi, 20, 20, np.pi, 1e-1],
[50, np.pi, 20, 20, np.pi, 1e-1],
[50, np.pi, 20, 20, np.pi, 1e-1],
]).reshape(-1)
def training_function(config):
np.random.seed(config['seed'])
torch.manual_seed(config['seed'])
# choose validation environment
if config['experiment'] == 'A':
envs = [Setobs(TransformObservation(CollisionPenaltyWrapper(
IntersimpleLidarFlatRandom(
n_rays=5,
reward=functools.partial(
speed_reward,
collision_penalty=0
),
check_collisions=True,
stop_on_collision=config['trainenv']['stop_on_collision'],
), collision_distance=6, collision_penalty=100),
lambda obs: (obs - obs_min) / (obs_max - obs_min + 1e-10)
)) for _ in range(60)]
elif config['experiment'] == 'B':
envs = sum([[Setobs(TransformObservation(CollisionPenaltyWrapper(
IntersimpleLidarFlatRandom(
n_rays=5,
reward=functools.partial(
speed_reward,
collision_penalty=0
),
check_collisions=True,
stop_on_collision=config['trainenv']['stop_on_collision'],
), collision_distance=6, collision_penalty=100),
lambda obs: (obs - obs_min) / (obs_max - obs_min + 1e-10)
)) for _ in range(15)] for track in range(4)],[])
else:
raise NotImplementedError
env_fn = lambda i: envs[i]
# load expert data
if config['experiment'] == 'A':
expert_data = torch.load(os.path.join(DIR, 'intersimple-expert-data-setobs2-loc0-track0.pt'))
elif config['experiment'] == 'B':
expert_data = [
torch.load(os.path.join(DIR, 'intersimple-expert-data-setobs2-loc0-track0.pt')),
torch.load(os.path.join(DIR, 'intersimple-expert-data-setobs2-loc0-track1.pt')),
torch.load(os.path.join(DIR, 'intersimple-expert-data-setobs2-loc0-track2.pt')),
torch.load(os.path.join(DIR, 'intersimple-expert-data-setobs2-loc0-track3.pt')),
]
d0 = [d[0] for d in expert_data]
d1 = [d[1] for d in expert_data]
d2 = [d[2] for d in expert_data]
d3 = [d[3] for d in expert_data]
expert_data = (torch.cat(d0), torch.cat(d1), torch.cat(d2), torch.cat(d3))
expert_data = Buffer(*expert_data)
# configure and train policy
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
policy = SetPolicy(expert_data.actions.shape[-1],
n_hidden_layers=config['policy']['n_hidden_layers'],
hidden_layer_size=config['policy']['hidden_layer_size'],
activation=activations[config['policy']['activation']] ) # config net architecture
policy = policy.to(device)
pi_opt = torch.optim.Adam(policy.parameters(), lr=config['policy']['learning_rate'])
pi_lr_scheduler = torch.optim.lr_scheduler.ExponentialLR(pi_opt, gamma=config['policy']['learning_rate_decay'])
expert_states = expert_data.states[~expert_data.dones].to(device)
expert_actions = expert_data.actions[~expert_data.dones].to(device)
for epoch in range(config['train_epochs']):
pi_opt.zero_grad()
loss = -policy.log_prob(policy(expert_states), expert_actions).mean()
loss.backward()
pi_opt.step()
pi_lr_scheduler.step()
if epoch % 25 == 0:
gen_states, gen_actions, gen_rewards, gen_dones, gen_collisions = rollout(env_fn, policy.cpu(), n_episodes=60, max_steps_per_episode=200)
gen_mean_episode_length = (~gen_dones).sum() / gen_states.shape[0]
gen_mean_reward_per_episode = gen_rewards[~gen_dones].sum() / gen_states.shape[0]
gen_collision_rate = (1. * gen_collisions.any(-1)).mean()
tune.report(
gen_mean_reward_per_episode=gen_mean_reward_per_episode.item(),
mean_episode_length=gen_mean_episode_length.item(),
gen_collision_rate=gen_collision_rate.item(),
loss=loss.item(),
)
# save model checkpoints
ep = epoch + 1
if (ep % 50 == 0):
torch.save(policy.state_dict(), f'policy_epoch{ep}.pt')
# save model
torch.save(policy.state_dict(), 'policy_final.pt')
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--train', choices=['A', 'B'])
parser.add_argument('--epochs', type=int, default=1000)
parser.add_argument('--test', type=str, help='path to config file to run final training on')
parser.add_argument('--test_seeds', type=int, default=5)
parser.add_argument('--test_cpus', type=int, help='number of cpus available to split test seed training over')
args = parser.parse_args()
assert (args.train is None) ^ (args.test is None), 'Must either train on an experiment or test with a config file'
# if no test config specified, train
if args.test is None:
print('Running Tuning for Experiment %s'%(args.train))
analysis = tune.run(
training_function,
config={
'experiment': args.train,
'trainenv': {
'stop_on_collision': False,
},
'policy': {
'learning_rate': 3e-4,
'learning_rate_decay': tune.grid_search([0.001, 1.0]),
'hidden_layer_size': tune.grid_search([10, 20, 40, 80]),
'n_hidden_layers': tune.grid_search([2, 3, 4]),
'activation':0,
},
'train_epochs': args.epochs,
'seed': 0,
}
# TODO resources_per_trial={'gpu': 1}
)
best_config = analysis.get_best_config(metric='gen_collision_rate', mode='min')
print('Best config: ', best_config)
# safe best_config
if not os.path.isdir(os.path.join(DIR, 'best_configs')):
os.mkdir(os.path.join(DIR, 'best_configs'))
# save gail
with open(os.path.join(DIR, 'best_configs',f'bc_exp{args.train}.json'), 'w', encoding='utf-8') as f:
json.dump(best_config, f, ensure_ascii=False, indent=4)
# if config file specified, rerun it with appropriate number of seeds
else:
with open(args.test, 'rb') as f:
config = json.load(f)
print(f'Retraining {args.test} with {args.test_seeds} seeds on experiment {config["experiment"]}')
# rerun with appropriate number of seeds
rpt = {'cpu': int(args.test_cpus/args.test_seeds)} if (args.test_cpus is not None) else None
config['seed'] = tune.grid_search(list(range(1,args.test_seeds+1)))
analysis = tune.run(training_function, config=config, resources_per_trial=rpt)
# move final policies to appropriate directory
split_ = os.path.basename(args.test).split('_')
model = split_[0]
exper = split_[-1].split('.')[0]
savepath = os.path.join('test_policies',model,exper)
if not os.path.isdir(savepath):
os.makedirs(savepath)
import shutil
for i in range(args.test_seeds):
s = analysis._checkpoints[i]['config']['seed']
check_dir = analysis._checkpoints[i]['logdir']
shutil.copyfile(os.path.join(check_dir,'policy_final.pt'),
os.path.join(savepath, f'policy_seed{s}.pt'))

15
best_configs/bc_expA.json Normal file
View File

@@ -0,0 +1,15 @@
{
"experiment": "A",
"trainenv": {
"stop_on_collision": false
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"hidden_layer_size": 40,
"n_hidden_layers": 2,
"activation": 0
},
"train_epochs": 300,
"seed": 0
}

15
best_configs/bc_expB.json Normal file
View File

@@ -0,0 +1,15 @@
{
"experiment": "B",
"trainenv": {
"stop_on_collision": false
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"hidden_layer_size": 40,
"n_hidden_layers": 2,
"activation": 0
},
"train_epochs": 300,
"seed": 0
}

View File

@@ -0,0 +1,31 @@
{
"experiment": "A",
"trainenv": {
"stop_on_collision": false
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"delta": 0.01,
"iterations_per_epoch": 100,
"hidden_layer_size": 40,
"n_hidden_layers": 2,
"activation": 0
},
"value": {
"learning_rate": 0.0001,
"weight_decay": 0.001,
"iterations_per_epoch": 1000
},
"discriminator": {
"learning_rate": 0.001,
"weight_decay": 0.0001,
"iterations_per_epoch": 100,
"n_hidden_layers_element": 4,
"n_hidden_layers_global": 1,
"hidden_layer_size": 10,
"activation": 0
},
"train_epochs": 100,
"seed": 0
}

View File

@@ -0,0 +1,31 @@
{
"experiment": "B",
"trainenv": {
"stop_on_collision": false
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"delta": 0.01,
"iterations_per_epoch": 100,
"hidden_layer_size": 40,
"n_hidden_layers": 2,
"activation": 0
},
"value": {
"learning_rate": 0.0001,
"weight_decay": 0.001,
"iterations_per_epoch": 1000
},
"discriminator": {
"learning_rate": 0.001,
"weight_decay": 0.0001,
"iterations_per_epoch": 100,
"n_hidden_layers_element": 4,
"n_hidden_layers_global": 1,
"hidden_layer_size": 10,
"activation": 0
},
"train_epochs": 100,
"seed": 0
}

View File

@@ -0,0 +1,31 @@
{
"experiment": "A",
"trainenv": {
"stop_on_collision": false
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"clip_ratio": 0.2,
"iterations_per_epoch": 100,
"hidden_layer_size": 40,
"n_hidden_layers": 2,
"activation": 0
},
"value": {
"learning_rate": 0.0001,
"weight_decay": 0.001,
"iterations_per_epoch": 1000
},
"discriminator": {
"learning_rate": 0.001,
"weight_decay": 0.0001,
"iterations_per_epoch": 100,
"n_hidden_layers_element": 4,
"n_hidden_layers_global": 1,
"hidden_layer_size": 10,
"activation": 0
},
"train_epochs": 100,
"seed": 0
}

View File

@@ -0,0 +1,31 @@
{
"experiment": "B",
"trainenv": {
"stop_on_collision": false
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"clip_ratio": 0.2,
"iterations_per_epoch": 100,
"hidden_layer_size": 40,
"n_hidden_layers": 2,
"activation": 0
},
"value": {
"learning_rate": 0.0001,
"weight_decay": 0.001,
"iterations_per_epoch": 1000
},
"discriminator": {
"learning_rate": 0.001,
"weight_decay": 0.0001,
"iterations_per_epoch": 100,
"n_hidden_layers_element": 4,
"n_hidden_layers_global": 1,
"hidden_layer_size": 10,
"activation": 0
},
"train_epochs": 100,
"seed": 0
}

View File

@@ -0,0 +1,33 @@
{
"experiment": "A",
"trainenv": {
"stop_on_collision": false,
"safe_actions_collision_method": null,
"abort_unsafe_collision_method": null
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"clip_ratio": 0.2,
"iterations_per_epoch": 100,
"hidden_layer_size": 10,
"n_hidden_layers": 3,
"activation": 0,
"option": 0
},
"value": {
"learning_rate": 0.001,
"iterations_per_epoch": 1000
},
"discriminator": {
"learning_rate": 0.001,
"weight_decay": 0.0001,
"iterations_per_epoch": 100,
"n_hidden_layers_element": 3,
"n_hidden_layers_global": 2,
"hidden_layer_size": 10,
"activation": 0
},
"train_epochs": 100,
"seed": 0
}

View File

@@ -0,0 +1,33 @@
{
"experiment": "B",
"trainenv": {
"stop_on_collision": false,
"safe_actions_collision_method": null,
"abort_unsafe_collision_method": null
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"clip_ratio": 0.2,
"iterations_per_epoch": 100,
"hidden_layer_size": 10,
"n_hidden_layers": 3,
"activation": 0,
"option": 0
},
"value": {
"learning_rate": 0.001,
"iterations_per_epoch": 1000
},
"discriminator": {
"learning_rate": 0.001,
"weight_decay": 0.0001,
"iterations_per_epoch": 100,
"n_hidden_layers_element": 3,
"n_hidden_layers_global": 2,
"hidden_layer_size": 10,
"activation": 0
},
"train_epochs": 100,
"seed": 0
}

View File

@@ -0,0 +1,33 @@
{
"experiment": "A",
"trainenv": {
"stop_on_collision": false,
"safe_actions_collision_method": null,
"abort_unsafe_collision_method": null
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"clip_ratio": 0.2,
"iterations_per_epoch": 100,
"hidden_layer_size": 40,
"n_hidden_layers": 3,
"activation": 0,
"option": 0
},
"value": {
"learning_rate": 0.001,
"iterations_per_epoch": 1000
},
"discriminator": {
"learning_rate": 0.001,
"weight_decay": 0.0001,
"iterations_per_epoch": 100,
"n_hidden_layers_element": 3,
"n_hidden_layers_global": 2,
"hidden_layer_size": 10,
"activation": 0
},
"train_epochs": 100,
"seed": 0
}

View File

@@ -0,0 +1,33 @@
{
"experiment": "B",
"trainenv": {
"stop_on_collision": false,
"safe_actions_collision_method": null,
"abort_unsafe_collision_method": null
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"clip_ratio": 0.2,
"iterations_per_epoch": 100,
"hidden_layer_size": 40,
"n_hidden_layers": 3,
"activation": 0,
"option": 0
},
"value": {
"learning_rate": 0.001,
"iterations_per_epoch": 1000
},
"discriminator": {
"learning_rate": 0.001,
"weight_decay": 0.0001,
"iterations_per_epoch": 100,
"n_hidden_layers_element": 3,
"n_hidden_layers_global": 2,
"hidden_layer_size": 10,
"activation": 0
},
"train_epochs": 100,
"seed": 0
}

View File

@@ -0,0 +1,33 @@
{
"experiment": "A",
"trainenv": {
"stop_on_collision": false,
"safe_actions_collision_method": null,
"abort_unsafe_collision_method": null
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"clip_ratio": 0.2,
"iterations_per_epoch": 100,
"hidden_layer_size": 20,
"n_hidden_layers": 4,
"activation": 0,
"option": 0
},
"value": {
"learning_rate": 0.001,
"iterations_per_epoch": 1000
},
"discriminator": {
"learning_rate": 0.001,
"weight_decay": 0.0001,
"iterations_per_epoch": 100,
"n_hidden_layers_element": 3,
"n_hidden_layers_global": 2,
"hidden_layer_size": 10,
"activation": 0
},
"train_epochs": 100,
"seed": 0
}

View File

@@ -0,0 +1,33 @@
{
"experiment": "B",
"trainenv": {
"stop_on_collision": false,
"safe_actions_collision_method": null,
"abort_unsafe_collision_method": null
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"clip_ratio": 0.2,
"iterations_per_epoch": 100,
"hidden_layer_size": 20,
"n_hidden_layers": 4,
"activation": 0,
"option": 0
},
"value": {
"learning_rate": 0.001,
"iterations_per_epoch": 1000
},
"discriminator": {
"learning_rate": 0.001,
"weight_decay": 0.0001,
"iterations_per_epoch": 100,
"n_hidden_layers_element": 3,
"n_hidden_layers_global": 2,
"hidden_layer_size": 10,
"activation": 0
},
"train_epochs": 100,
"seed": 0
}

View File

@@ -0,0 +1,33 @@
{
"experiment": "A",
"trainenv": {
"stop_on_collision": false,
"safe_actions_collision_method": null,
"abort_unsafe_collision_method": null
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"clip_ratio": 0.2,
"iterations_per_epoch": 100,
"hidden_layer_size": 40,
"n_hidden_layers": 2,
"activation": 0,
"option": 0
},
"value": {
"learning_rate": 0.001,
"iterations_per_epoch": 1000
},
"discriminator": {
"learning_rate": 0.001,
"weight_decay": 0.0001,
"iterations_per_epoch": 100,
"n_hidden_layers_element": 4,
"n_hidden_layers_global": 1,
"hidden_layer_size": 10,
"activation": 0
},
"train_epochs": 90,
"seed": 0
}

View File

@@ -0,0 +1,33 @@
{
"experiment": "B",
"trainenv": {
"stop_on_collision": false,
"safe_actions_collision_method": null,
"abort_unsafe_collision_method": null
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"clip_ratio": 0.2,
"iterations_per_epoch": 100,
"hidden_layer_size": 20,
"n_hidden_layers": 2,
"activation": 0,
"option": 0
},
"value": {
"learning_rate": 0.001,
"iterations_per_epoch": 1000
},
"discriminator": {
"learning_rate": 0.001,
"weight_decay": 0.0001,
"iterations_per_epoch": 100,
"n_hidden_layers_element": 4,
"n_hidden_layers_global": 2,
"hidden_layer_size": 10,
"activation": 0
},
"train_epochs": 85,
"seed": 0
}

View File

@@ -0,0 +1,33 @@
{
"experiment": "A",
"trainenv": {
"stop_on_collision": false,
"safe_actions_collision_method": "circle",
"abort_unsafe_collision_method": "circle"
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"clip_ratio": 0.2,
"iterations_per_epoch": 100,
"hidden_layer_size": 10,
"n_hidden_layers": 3,
"activation": 0,
"option": 0
},
"value": {
"learning_rate": 0.001,
"iterations_per_epoch": 1000
},
"discriminator": {
"learning_rate": 0.001,
"weight_decay": 0.0001,
"iterations_per_epoch": 100,
"n_hidden_layers_element": 3,
"n_hidden_layers_global": 2,
"hidden_layer_size": 10,
"activation": 0
},
"train_epochs": 100,
"seed": 0
}

View File

@@ -0,0 +1,33 @@
{
"experiment": "B",
"trainenv": {
"stop_on_collision": false,
"safe_actions_collision_method": "circle",
"abort_unsafe_collision_method": "circle"
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"clip_ratio": 0.2,
"iterations_per_epoch": 100,
"hidden_layer_size": 10,
"n_hidden_layers": 3,
"activation": 0,
"option": 0
},
"value": {
"learning_rate": 0.001,
"iterations_per_epoch": 1000
},
"discriminator": {
"learning_rate": 0.001,
"weight_decay": 0.0001,
"iterations_per_epoch": 100,
"n_hidden_layers_element": 3,
"n_hidden_layers_global": 2,
"hidden_layer_size": 10,
"activation": 0
},
"train_epochs": 100,
"seed": 0
}

View File

@@ -0,0 +1,33 @@
{
"experiment": "A",
"trainenv": {
"stop_on_collision": false,
"safe_actions_collision_method": "circle",
"abort_unsafe_collision_method": "circle"
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"clip_ratio": 0.2,
"iterations_per_epoch": 100,
"hidden_layer_size": 40,
"n_hidden_layers": 3,
"activation": 0,
"option": 0
},
"value": {
"learning_rate": 0.001,
"iterations_per_epoch": 1000
},
"discriminator": {
"learning_rate": 0.001,
"weight_decay": 0.0001,
"iterations_per_epoch": 100,
"n_hidden_layers_element": 3,
"n_hidden_layers_global": 2,
"hidden_layer_size": 10,
"activation": 0
},
"train_epochs": 100,
"seed": 0
}

View File

@@ -0,0 +1,33 @@
{
"experiment": "B",
"trainenv": {
"stop_on_collision": false,
"safe_actions_collision_method": "circle",
"abort_unsafe_collision_method": "circle"
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"clip_ratio": 0.2,
"iterations_per_epoch": 100,
"hidden_layer_size": 40,
"n_hidden_layers": 3,
"activation": 0,
"option": 0
},
"value": {
"learning_rate": 0.001,
"iterations_per_epoch": 1000
},
"discriminator": {
"learning_rate": 0.001,
"weight_decay": 0.0001,
"iterations_per_epoch": 100,
"n_hidden_layers_element": 3,
"n_hidden_layers_global": 2,
"hidden_layer_size": 10,
"activation": 0
},
"train_epochs": 100,
"seed": 0
}

View File

@@ -0,0 +1,33 @@
{
"experiment": "A",
"trainenv": {
"stop_on_collision": false,
"safe_actions_collision_method": "circle",
"abort_unsafe_collision_method": "circle"
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"clip_ratio": 0.2,
"iterations_per_epoch": 500,
"hidden_layer_size": 40,
"n_hidden_layers": 3,
"activation": 0,
"option": 0
},
"value": {
"learning_rate": 0.001,
"iterations_per_epoch": 1000
},
"discriminator": {
"learning_rate": 0.001,
"weight_decay": 0.0001,
"iterations_per_epoch": 100,
"n_hidden_layers_element": 3,
"n_hidden_layers_global": 2,
"hidden_layer_size": 10,
"activation": 0
},
"train_epochs": 150,
"seed": 0
}

View File

@@ -0,0 +1,33 @@
{
"experiment": "A",
"trainenv": {
"stop_on_collision": false,
"safe_actions_collision_method": "circle",
"abort_unsafe_collision_method": "circle"
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"clip_ratio": 0.2,
"iterations_per_epoch": 100,
"hidden_layer_size": 20,
"n_hidden_layers": 4,
"activation": 0,
"option": 0
},
"value": {
"learning_rate": 0.001,
"iterations_per_epoch": 1000
},
"discriminator": {
"learning_rate": 0.001,
"weight_decay": 0.0001,
"iterations_per_epoch": 100,
"n_hidden_layers_element": 3,
"n_hidden_layers_global": 2,
"hidden_layer_size": 10,
"activation": 0
},
"train_epochs": 100,
"seed": 0
}

View File

@@ -0,0 +1,33 @@
{
"experiment": "B",
"trainenv": {
"stop_on_collision": false,
"safe_actions_collision_method": "circle",
"abort_unsafe_collision_method": "circle"
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"clip_ratio": 0.2,
"iterations_per_epoch": 100,
"hidden_layer_size": 20,
"n_hidden_layers": 4,
"activation": 0,
"option": 0
},
"value": {
"learning_rate": 0.001,
"iterations_per_epoch": 1000
},
"discriminator": {
"learning_rate": 0.001,
"weight_decay": 0.0001,
"iterations_per_epoch": 100,
"n_hidden_layers_element": 3,
"n_hidden_layers_global": 2,
"hidden_layer_size": 10,
"activation": 0
},
"train_epochs": 100,
"seed": 0
}

View File

@@ -0,0 +1,33 @@
{
"experiment": "A",
"trainenv": {
"stop_on_collision": false,
"safe_actions_collision_method": "circle",
"abort_unsafe_collision_method": "circle"
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"clip_ratio": 0.2,
"iterations_per_epoch": 100,
"hidden_layer_size": 40,
"n_hidden_layers": 2,
"activation": 0,
"option": 0
},
"value": {
"learning_rate": 0.001,
"iterations_per_epoch": 1000
},
"discriminator": {
"learning_rate": 0.001,
"weight_decay": 0.0001,
"iterations_per_epoch": 100,
"n_hidden_layers_element": 4,
"n_hidden_layers_global": 1,
"hidden_layer_size": 10,
"activation": 0
},
"train_epochs": 90,
"seed": 0
}

View File

@@ -0,0 +1,33 @@
{
"experiment": "B",
"trainenv": {
"stop_on_collision": false,
"safe_actions_collision_method": "circle",
"abort_unsafe_collision_method": "circle"
},
"policy": {
"learning_rate": 0.0003,
"learning_rate_decay": 1.0,
"clip_ratio": 0.2,
"iterations_per_epoch": 100,
"hidden_layer_size": 20,
"n_hidden_layers": 2,
"activation": 0,
"option": 0
},
"value": {
"learning_rate": 0.001,
"iterations_per_epoch": 1000
},
"discriminator": {
"learning_rate": 0.001,
"weight_decay": 0.0001,
"iterations_per_epoch": 100,
"n_hidden_layers_element": 4,
"n_hidden_layers_global": 2,
"hidden_layer_size": 10,
"activation": 0
},
"train_epochs": 85,
"seed": 0
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,34 +1,42 @@
{
ego_state: {
ego_encoder: {
input_dim: 5, // number of state vars
hidden_n: 1,
hidden_n: 0,
hidden_dim: 5,
output_dim: 5
},
deepsets: {
input_dim: 5, // number of relative state vars for others
input_dim: 6, // number of relative state vars for others
phi: {
hidden_n: 1,
hidden_n: 2,
hidden_dim: 20,
},
latent_dim: 20,
rho: {
hidden_n: 1,
hidden_n: 2,
hidden_dim: 10,
},
output_dim: 10
},
path_encoder: {
input_dim: 40, // 2 * path length for (x,y) coordinates
hidden_n: 2,
hidden_n: 0,
hidden_dim: 20,
output_dim: 10,
},
head: {
input_dim: 0, // computed in policy constructor
hidden_n: 1,
hidden_n: 3,
hidden_dim: 50,
output_dim: 1, // number of outputs e.g. number of actions, or just one
final_activation: 'sigmoid',
}
},
optim: {
optimizer: 'adam',
lr: 1e-3,
weight_decay: 0.1,
},
train_epochs: 200,
train_batch_size: 32,
loss: 'huber',
}

85
config/value_dice.json5 Normal file
View File

@@ -0,0 +1,85 @@
{
policy_net: {
ego_encoder: {
input_dim: 5, // number of state vars
hidden_n: 0,
hidden_dim: 5,
output_dim: 5
},
deepsets: {
input_dim: 6, // number of relative state vars for others
phi: {
hidden_n: 2,
hidden_dim: 20,
},
latent_dim: 20,
rho: {
hidden_n: 2,
hidden_dim: 10,
},
output_dim: 10
},
path_encoder: {
input_dim: 40, // 2 * path length for (x,y) coordinates
hidden_n: 0,
hidden_dim: 20,
output_dim: 10,
},
head: {
input_dim: 0, // computed in policy constructor
hidden_n: 3,
hidden_dim: 50,
output_dim: 1, // number of outputs e.g. number of actions, or just one
final_activation: 'sigmoid',
},
},
value_net: {
ego_encoder: {
input_dim: 5, // number of state vars
hidden_n: 0,
hidden_dim: 5,
output_dim: 5
},
deepsets: {
input_dim: 6, // number of relative state vars for others
phi: {
hidden_n: 2,
hidden_dim: 20,
},
latent_dim: 20,
rho: {
hidden_n: 2,
hidden_dim: 10,
},
output_dim: 10
},
path_encoder: {
input_dim: 40, // 2 * path length for (x,y) coordinates
hidden_n: 0,
hidden_dim: 20,
output_dim: 10,
},
action_dim: 1, // number of actions
head: {
input_dim: 0, // computed in policy constructor
hidden_n: 3,
hidden_dim: 50,
output_dim: 1, // number of outputs e.g. number of actions, or just one
final_activation: 'id',
},
},
policy_optim: {
optimizer: 'adam',
lr: 1e-3,
weight_decay: 0.1,
},
value_optim: {
optimizer: 'adam',
lr: 1e-3,
weight_decay: 0.1,
},
train_epochs: 200,
train_batch_size: 32,
discount: 0.95,
clip_grad_norm: 1.,
}

100
eval_experiments.py Normal file
View File

@@ -0,0 +1,100 @@
import os
from src.eval_main import eval_main
from src.evaluation.utils import load_and_average
import torch
import json
activations = [torch.nn.Tanh, torch.nn.LeakyReLU]
def main(method:str='expert', folder:str=None, locations=[(0,0)], skip_running=False):
exclude_keys_from_policy_kwargs = {'learning_rate', 'learning_rate_decay', 'clip_ratio', 'iterations_per_epoch', 'option'}
policy_kwargs = {}
if method in ['expert', 'idm']:
env, env_kwargs ='NRasterizedRouteIncrementingAgent', {}
elif method in ['bc','gail']:
env='NormalizedContinuousEvalEnv'
env_kwargs={'stop_on_collision':True, 'max_episode_steps':1000}
elif method in ['hail']:
env = 'NormalizedSafeOptionsEvalEnv'
env_kwargs={'stop_on_collision':True, 'max_episode_steps':1000, 'safe_actions_collision_method': None, 'abort_unsafe_collision_method': None}
elif method in ['shail']:
env = 'NormalizedSafeOptionsEvalEnv'
env_kwargs={'stop_on_collision':True, 'max_episode_steps':1000}
else:
raise NotImplementedError
files = ['']
if folder is not None:
files = [os.path.join(folder, f) for f in os.listdir(folder) if os.path.isfile(os.path.join(folder, f))]
files = [f for f in files if f.endswith('.pt')]
with open(os.path.join(folder, 'config.json'), 'rb') as f:
config = json.load(f)
print('%i policy files found in %s folder' %(len(files), folder))
print('found policy config', config['policy'])
policy_config = {k: v for k, v in config['policy'].items() if k not in exclude_keys_from_policy_kwargs}
policy_config['activation'] = activations[policy_config['activation']]
print('final policy config', policy_config)
policy_kwargs.update(policy_config)
print('final policy kwargs', policy_kwargs)
if not skip_running:
for policy_file in files:
# run metrics on that file
outbase = eval_main(locations=locations,
method=method,
policy_file=policy_file,
policy_kwargs=policy_kwargs,
env=env,
env_kwargs=env_kwargs)
outfolder = os.path.dirname(outbase)
else:
locstr = 'loc_'+'_'.join([f'r{ro}t{tr}' for (ro,tr) in locations])
if folder is None:
outfolder = os.path.join('out',method,locstr)
else:
path_items = folder.split('/')
outfolder = os.path.join('out', '/'.join(path_items[1:]), locstr)
# load metrics from save_path
average_metrics = load_and_average(outfolder)
if method in ['expert', 'idm']:
latex_print(average_metrics, light=True)
else:
latex_print(average_metrics)
def latex_print(am, light=False):
"""
print latex line
am (Dict[str,tuple]): dict mapping metric_name to (mean, std)
"""
print('success rate, distance travelled, RWSE_10, |DeltaV|, AccelJSD')
if light:
if 'rwse_10s' in am.keys():
print("%2.1f& %2.1f & %1.2f & %2.1f& "
"%0.3f \\\\" %( 100*am['success rate'][0], am['mean travel distance'][0], am['rwse_10s'][0],
am['average absolute average velocity'][0],am['acceleration distribution divergence'][0] ))
return
print("%2.1f& %2.1f & $---$ & $---$ & "
"$---$ \\\\" %( 100*am['success rate'][0], am['mean travel distance'][0]))
return
print("%2.1f \\scriptstyle\\pm %2.1f & %2.1f \\scriptstyle\\pm %2.1f & "
"%1.2f \\scriptstyle\\pm %1.2f & %2.1f \\scriptstyle\\pm %1.1f & "
"%0.3f \\scriptstyle\\pm %0.3f \\\\" %( 100*am['success rate'][0], 100*am['success rate'][1],
am['mean travel distance'][0] , am['mean travel distance'][1] ,
am['rwse_10s'][0] , am['rwse_10s'][1] ,
am['average absolute average velocity'][0] , am['average absolute average velocity'][1] ,
am['acceleration distribution divergence'][0] , am['acceleration distribution divergence'][1] ))
if __name__=='__main__':
import fire
fire.Fire(main)

19
evaluate_models.sh Executable file
View File

@@ -0,0 +1,19 @@
# can add --skip_running if you've run the runs before on the saved policies
python -m eval_experiments
python -m eval_experiments --locations='[(0,4)]'
python -m eval_experiments --method idm
python -m eval_experiments --method idm --locations='[(0,4)]'
python -m eval_experiments --method bc --folder='test_policies/bc/expA'
python -m eval_experiments --method bc --folder='test_policies/bc/expB' --locations='[(0,4)]'
python -m eval_experiments --method gail --folder='test_policies/gail/expA'
python -m eval_experiments --method gail --folder='test_policies/gail/expB' --locations='[(0,4)]'
python -m eval_experiments --method hail --folder='test_policies/hail/expA'
python -m eval_experiments --method hail --folder='test_policies/hail/expB' --locations='[(0,4)]'
python -m eval_experiments --method shail --folder='test_policies/shail/expA'
python -m eval_experiments --method shail --folder='test_policies/shail/expB' --locations='[(0,4)]'
python -m eval_experiments --method hail --folder='test_policies/hail-etienne/expA'
python -m eval_experiments --method hail --folder='test_policies/hail-etienne/expB' --locations='[(0,4)]'
python -m eval_experiments --method shail --folder='test_policies/shail-etienne/expA'
python -m eval_experiments --method shail --folder='test_policies/shail-etienne/expB' --locations='[(0,4)]'

View File

@@ -0,0 +1,203 @@
import json5
from functools import partial
import os
opj = os.path.join
# set up ray tune
import ray
from ray import tune
from ray.tune import Analysis, ExperimentAnalysis
from ray.tune.schedulers import ASHAScheduler
from hyperopt import hp
from ray.tune.suggest.hyperopt import HyperOptSearch
# get graphs
import intersim
from intersim.graphs import ConeVisibilityGraph
from src.main import basestr, main
def parse_args():
"""
Parse arguments to main
Returns:
kwargs: dictionary of arguments:
train (bool): whether to run train loop
test (bool): whether to run test loop
method (str): the method to try for imitation
loc (int): the location index of the roundabout
config (str): config path
seed (int): RNG seed
"""
import argparse
parser = argparse.ArgumentParser(description='Save Expert Trajectories')
parser.add_argument('--loc', default=0, type=int,
help='location (default 0)')
parser.add_argument("--train", help="train model",
action="store_true")
parser.add_argument("--ray", help="use ray tune to run multiple experiments",
action="store_true")
parser.add_argument("--test", help="test model",
action="store_true")
parser.add_argument("--method", help="modeling method",
choices=['bc', 'gail', 'advil', 'vd'], default='bc')
parser.add_argument("--config", help="config file path",
default=None, type=str)
parser.add_argument('--seed', default=0, type=int,
help='seed')
parser.add_argument('--nframes', default=500, type=int,
help='frames for test animation')
parser.add_argument('--nsamples', default=200, type=int,
help='number of ray samples')
parser.add_argument('--graph', action='store_true',
help='whether to mask the relative states based on a ConeVisibilityGraph')
parser.add_argument('-d', default='./expert_data', type=str,
help='data directory')
parser.add_argument('-o', default=None, type=str,
help='output directory')
args = parser.parse_args()
kwargs = {
'train':args.train,
'test':args.test,
'method':args.method,
'loc':args.loc,
'config_path':args.config,
'seed':args.seed,
'ray':args.ray,
'nframes':args.nframes,
'nsamples':args.nsamples,
'datadir':os.path.abspath(args.d),
'graph':None,
'outdir': opj('output',args.method,'loc%02i'%(args.loc)),
'train_tracks':[0,1,2],
'cv_tracks':[3],
'test_tracks':[4],
}
if args.o:
kwargs['outdir'] = args.o
if args.graph:
kwargs['graph'] = ConeVisibilityGraph(r=20, half_angle=120)
return kwargs
def get_full_config(ray_config:dict, method:str)->dict:
"""
Get full model configuration from ray config and method string
Args:
ray_config (dict): ray config
method (str): method to get full configuration for
"""
if method == 'bc':
from src.bc import bc_config
config = bc_config(ray_config)
elif method == 'vd':
from src.value_dice import vd_config
config = vd_config(ray_config)
else:
raise NotImplementedError
return config
def get_ray_config(method:str)->dict:
"""
Get configuration for ray based on method.
Args:
method (str): method to get configuration for
Returns:
ray_config (dict): configuration for ray
"""
if method == 'bc':
ray_config = {
"lr": tune.loguniform(1e-5, 1e-3),
"weight_decay": tune.choice([0, 0.1]),
"loss": tune.choice(['huber', 'mse']),
"train_batch_size": tune.choice([16,32,64]),
"deepsets_phi_hidden_n": tune.randint(1,5),
"deepsets_phi_hidden_dim": tune.lograndint(8,65),
"deepsets_latent_dim": tune.lograndint(8,129),
"deepsets_rho_hidden_n": tune.randint(0,3),
"deepsets_rho_hidden_dim": tune.lograndint(8,129),
"deepsets_output_dim": tune.lograndint(4,129),
"head_hidden_n": tune.randint(1,6),
"head_hidden_dim": tune.lograndint(16,257),
"head_final_activation": tune.choice(['sigmoid', None]),
}
elif method == 'vd':
ray_config = {
"policy_lr": tune.loguniform(1e-5, 1e-3),
"value_lr": tune.loguniform(1e-5, 1e-3),
"policy_weight_decay": tune.choice([0, 0.1]),
"value_weight_decay": tune.choice([0, 0.1]),
"train_batch_size": tune.choice([16,32,64]),
"deepsets_phi_hidden_n": tune.randint(1,5),
"deepsets_phi_hidden_dim": tune.lograndint(8,65),
"deepsets_latent_dim": tune.lograndint(8,129),
"deepsets_rho_hidden_n": tune.randint(0,3),
"deepsets_rho_hidden_dim": tune.lograndint(8,129),
"deepsets_output_dim": tune.lograndint(4,129),
"head_hidden_n": tune.randint(1,6),
"head_hidden_dim": tune.lograndint(16,257),
"head_final_activation": tune.choice(['sigmoid', None]),
"clip_grad_norm": tune.choice([.5, 1., 5., 10.]),
"discount": tune.choice([.95, .99])
}
else:
raise NotImplementedError
return ray_config
if __name__ == '__main__':
kwargs = parse_args()
# make prefix of output files
if kwargs['config_path']:
# load config
with open(kwargs['config_path'], 'r') as cfg:
config = json5.load(cfg)
if not os.path.isdir(kwargs['outdir']):
os.makedirs(kwargs['outdir'])
filestr = opj(kwargs['outdir'], basestr(**kwargs))
if kwargs['ray']:
filestr = kwargs['config_path'].replace('_config.json','')
main(config, filestr=filestr, **kwargs)
elif kwargs['ray'] and kwargs['train']:
ray.shutdown()
ray.init(log_to_driver=False)
def ray_train(config, datadir=None):
full_config = get_full_config(config, kwargs['method'])
main(full_config, filestr='exp', **kwargs)
ray_config = get_ray_config(kwargs['method'])
search = HyperOptSearch(ray_config, max_concurrent=8, metric='cv_loss',mode="min",)
custom_scheduler = ASHAScheduler(metric='cv_loss', mode="min", grace_period=15)
analysis = tune.run(
ray_train,
#config=ray_config,
search_alg=search,
scheduler=custom_scheduler,
local_dir=kwargs['outdir'],
#resources_per_trial={"cpu": 2},
time_budget_s=120*60,
num_samples=kwargs['nsamples'],
)
elif kwargs['ray'] and kwargs['test']:
analysis = Analysis(kwargs['outdir'], default_metric="cv_loss", default_mode="min")
config = analysis.get_best_config()
filepath = analysis.get_best_logdir()
filestr = opj(filepath, 'exp')
config_path = filestr+'_config.json'
with open(config_path, 'r') as cfg:
config = json5.load(cfg)
print("Best ray experiment:", filepath)
main(config, filestr=filestr, **kwargs)
else:
raise Exception('No valid config found')

9
experiments/experiments.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/sh
python experiments/experiment.py --ray --train -d ./expert_data/base
python experiments/experiment.py --ray --test -d ./expert_data/base --nframes 1000
python experiments/experiment.py --ray --train -d ./expert_data/reg
python experiments/experiment.py --ray --test -d ./expert_data/reg --nframes 1000
python experiments/experiment.py --ray --train -d ./expert_data/reg_graph --graph
python experiments/experiment.py --ray --test -d ./expert_data/reg_graph --graph --nframes 1000

5
experiments/train_vd.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/sh
# python experiments/experiment.py --method vd --train --ray -d expert_data/reg -o output/vd/loc00/reg --nsamples 400
# python experiments/experiment.py --test --ray --method vd -d expert_data/normal -o output/vd/loc00/normal --nframes 1000
python experiments/experiment.py --train --method vd --config config/value_dice.json5

238
gail-experiment.py Normal file
View File

@@ -0,0 +1,238 @@
# %%
import os
import gym
from src.core.gail import gail_ppo, Buffer
from src.core.value import SetValue
from src.core.policy import SetPolicy
from src.core.discriminator import DeepsetDiscriminator
import torch
from intersim.envs import IntersimpleLidarFlatRandom
from intersim.envs.intersimple import speed_reward
import functools
from src.util.wrappers import CollisionPenaltyWrapper, TransformObservation, Setobs
import numpy as np
from torch.utils.tensorboard import SummaryWriter
from ray import tune
from datetime import datetime
import json
DIR = os.path.dirname(os.path.abspath(__file__))
activations = [torch.nn.Tanh, torch.nn.LeakyReLU]
obs_min = np.array([
[-1000, -1000, 0, -np.pi, -1e-1, 0.],
[0, -np.pi, -20, -20, -np.pi, -1e-1],
[0, -np.pi, -20, -20, -np.pi, -1e-1],
[0, -np.pi, -20, -20, -np.pi, -1e-1],
[0, -np.pi, -20, -20, -np.pi, -1e-1],
[0, -np.pi, -20, -20, -np.pi, -1e-1],
]).reshape(-1)
obs_max = np.array([
[1000, 1000, 20, np.pi, 1e-1, 0.],
[50, np.pi, 20, 20, np.pi, 1e-1],
[50, np.pi, 20, 20, np.pi, 1e-1],
[50, np.pi, 20, 20, np.pi, 1e-1],
[50, np.pi, 20, 20, np.pi, 1e-1],
[50, np.pi, 20, 20, np.pi, 1e-1],
]).reshape(-1)
def training_function(config):
np.random.seed(config['seed'])
torch.manual_seed(config['seed'])
if config['experiment'] == 'A':
envs = [Setobs(TransformObservation(CollisionPenaltyWrapper(
IntersimpleLidarFlatRandom(
n_rays=5,
reward=functools.partial(
speed_reward,
collision_penalty=0
),
check_collisions=True,
stop_on_collision=config['trainenv']['stop_on_collision'],
), collision_distance=6, collision_penalty=100),
lambda obs: (obs - obs_min) / (obs_max - obs_min + 1e-10)
)) for _ in range(60)]
elif config['experiment'] == 'B':
envs = sum([[Setobs(TransformObservation(CollisionPenaltyWrapper(
IntersimpleLidarFlatRandom(
n_rays=5,
reward=functools.partial(
speed_reward,
collision_penalty=0
),
check_collisions=True,
stop_on_collision=config['trainenv']['stop_on_collision'],
track=track,
), collision_distance=6, collision_penalty=100),
lambda obs: (obs - obs_min) / (obs_max - obs_min + 1e-10)
)) for _ in range(15)] for track in range(4)],[])
else:
raise NotImplementedError
env_fn = lambda i: envs[i]
policy = SetPolicy(env_fn(0).action_space.shape[0],
n_hidden_layers=config['policy']['n_hidden_layers'],
hidden_layer_size=config['policy']['hidden_layer_size'],
activation=activations[config['policy']['activation']] ) # config net architecture
pi_opt = torch.optim.Adam(policy.parameters(), lr=config['policy']['learning_rate'])
pi_lr_scheduler = torch.optim.lr_scheduler.ExponentialLR(pi_opt, gamma=config['policy']['learning_rate_decay'])
value = SetValue() # config net architecture
v_opt = torch.optim.Adam(value.parameters(), lr=config['value']['learning_rate'], weight_decay=config['value']['weight_decay'])
discriminator = DeepsetDiscriminator(
n_hidden_layers_element=config['discriminator']['n_hidden_layers_element'],
n_hidden_layers_global=config['discriminator']['n_hidden_layers_global'],
hidden_layer_size=config['discriminator']['hidden_layer_size'],
activation=activations[config['discriminator']['activation']],
)
disc_opt = torch.optim.Adam(discriminator.parameters(), lr=config['discriminator']['learning_rate'], weight_decay=config['discriminator']['weight_decay'])
if config['experiment'] == 'A':
expert_data = torch.load(os.path.join(DIR, 'intersimple-expert-data-setobs2-loc0-track0.pt'))
elif config['experiment'] == 'B':
expert_data = [
torch.load(os.path.join(DIR, 'intersimple-expert-data-setobs2-loc0-track0.pt')),
torch.load(os.path.join(DIR, 'intersimple-expert-data-setobs2-loc0-track1.pt')),
torch.load(os.path.join(DIR, 'intersimple-expert-data-setobs2-loc0-track2.pt')),
torch.load(os.path.join(DIR, 'intersimple-expert-data-setobs2-loc0-track3.pt')),
]
d0 = [d[0] for d in expert_data]
d1 = [d[1] for d in expert_data]
d2 = [d[2] for d in expert_data]
d3 = [d[3] for d in expert_data]
expert_data = (torch.cat(d0), torch.cat(d1), torch.cat(d2), torch.cat(d3))
expert_data = Buffer(*expert_data)
def callback(info):
tune.report(gen_mean_reward_per_episode=info['gen/mean_reward_per_episode'],
disc_mean_reward_per_episode=info['disc/mean_reward_per_episode'],
mean_episode_length=info['gen/mean_episode_length'],
gen_collision_rate=info['gen/collision_rate'])
# save model checkpoints
ep = info['epoch'] + 1
if (ep % 25 == 0):
torch.save(info['policy'].state_dict(), f'policy_epoch{ep}.pt')
value, policy = gail_ppo(
env_fn=env_fn,
expert_data=expert_data,
discriminator=discriminator,
disc_opt=disc_opt,
disc_iters=config['discriminator']['iterations_per_epoch'],
policy=policy,
value=value,
v_opt=v_opt,
v_iters=config['value']['iterations_per_epoch'],
epochs=config['train_epochs'],
rollout_episodes=60,
rollout_steps=200,
gamma=0.99,
gae_lambda=0.9,
clip_ratio=config['policy']['clip_ratio'],
pi_opt=pi_opt,
pi_iters=config['policy']['iterations_per_epoch'],
logger=SummaryWriter(comment='gail-ppo-options-setobs2'),
callback=callback,
lr_schedulers=[pi_lr_scheduler],
)
# save model
torch.save(policy.state_dict(), 'policy_final.pt')
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--train', choices=['A', 'B'])
parser.add_argument('--epochs', type=int, default=200)
parser.add_argument('--test', type=str, help='path to config file to run final training on')
parser.add_argument('--test_seeds', type=int, default=5)
parser.add_argument('--test_cpus', type=int, help='number of cpus available to split test seed training over')
args = parser.parse_args()
assert (args.train is None) ^ (args.test is None), 'Must either train on an experiment or test with a config file'
# if no test config specified, train
if args.test is None:
print('Running Tuning for Experiment %s'%(args.train))
analysis = tune.run(
training_function,
config={
'experiment': args.train,
'trainenv': {
'stop_on_collision': False,
},
'policy': {
'learning_rate': 3e-4,
'learning_rate_decay': 1.0,
'clip_ratio': 0.2,
'iterations_per_epoch': 100,
'hidden_layer_size': tune.grid_search([20, 40]),
'n_hidden_layers': tune.grid_search([2, 3]),
'activation':0,
},
'value': {
'learning_rate': 1e-4,
'weight_decay': 1e-3,
'iterations_per_epoch': 1000,
},
'discriminator': {
'learning_rate': 1e-3,
'weight_decay': 1e-4,
'iterations_per_epoch': 100,
'n_hidden_layers_element': tune.grid_search([3,4]),
'n_hidden_layers_global': tune.grid_search([1,2]),
'hidden_layer_size': 10,
'activation': 0,
},
'train_epochs': args.epochs,
'seed': 0,
}
)
best_config = analysis.get_best_config(metric='gen_collision_rate', mode='min')
print('Best config: ', best_config)
# safe best_config
if not os.path.isdir(os.path.join(DIR, 'best_configs')):
os.mkdir(os.path.join(DIR, 'best_configs'))
# save gail
with open(os.path.join(DIR, 'best_configs',f'gail_exp{args.train}.json'), 'w', encoding='utf-8') as f:
json.dump(best_config, f, ensure_ascii=False, indent=4)
# if config file specified, rerun it with appropriate number of seeds
else:
with open(args.test, 'rb') as f:
config = json.load(f)
print(f'Retraining {args.test} with {args.test_seeds} seeds on experiment {config["experiment"]}')
# rerun with appropriate number of seeds
rpt = {'cpu': int(args.test_cpus/args.test_seeds)} if (args.test_cpus is not None) else None
config['seed'] = tune.grid_search(list(range(1,args.test_seeds+1)))
analysis = tune.run(training_function, config=config, resources_per_trial=rpt)
# move final policies to appropriate directory
split_ = os.path.basename(args.test).split('_')
model = split_[0]
exper = split_[-1].split('.')[0]
savepath = os.path.join('test_policies',model,exper)
if not os.path.isdir(savepath):
os.makedirs(savepath)
import shutil
for i in range(args.test_seeds):
s = analysis._checkpoints[i]['config']['seed']
check_dir = analysis._checkpoints[i]['logdir']
shutil.copyfile(os.path.join(check_dir,'policy_final.pt'),
os.path.join(savepath, f'policy_seed{s}.pt'))

10
generate_demos.sh Executable file
View File

@@ -0,0 +1,10 @@
#DEFAULT PARAMETERS:
# locs:list=None, (default to all locations)
# tracks:list=None, (default to all tracks)
# env_class:str='NRasterizedIncrementingAgent',
# env_args:dict={width:36,height:36,m_per_px:2},
# expert_class:str='NRasterizedRouteIncrementingAgent',
# expert_args:dict={mu:0.001}):
# python -m src.data.expert --locs='[DR_USA_Roundabout_FT]' --tracks='[0]'
python -m src.data.expert --locs='[DR_USA_Roundabout_FT]' --tracks='[0]'

View File

@@ -1 +0,0 @@
from interimit.expert_data import generate_expert_data, load_expert_data

View File

@@ -1,103 +0,0 @@
import torch
from torch.utils.data import Dataset, DataLoader
import numpy as np
#from torchvision import transforms, utils
from interimit.expert_data import load_expert_data
import os
opj = os.path.join
class InteractionDatasetMultiAgent(Dataset):
"""
Class to handle getting full multi-agent observations and actions
"""
pass
class InteractionDatasetSingleAgent(Dataset):
"""Class to load states and actions for individual agents."""
def __init__(self, output_dir='expert_data', loc:int = 0, tracks:list = [0], transforms={}):
"""
Args:
output_dir (string): Directory with all the images.
loc (int): location index
tracks (list[int]): track indices
transforms (dict): dictionary of transforms to apply to different variables
"""
self.output_dir = output_dir
self.loc = loc
self.tracks = tracks
self.transforms = transforms
#self.action_transform = transforms.get('action', None)
#self.state_transform = transforms.get('state', None)
#self.relative_state_transform = transforms.get('relative_state', None)
#self.paths_x_transform = transforms.get('paths_x', None)
#self.paths_y_transform = transform.get('paths_y',None)
self._load_dataset()
def _load_dataset(self):
"""
Load the full datasets ahead of time
"""
self.raw_data = {'state':[], 'relative_state':[], 'action':[], 'path_x':[], 'path_y':[]}
max_nv = 0
for track in self.tracks:
try:
observations, actions = load_expert_data(path=self.output_dir, loc=self.loc, track=track)
print('Loaded location {} track {}'.format(self.loc,track))
except:
print('Failed to load location {} track {}'.format(self.loc,track))
continue
T = len(actions)
for t in range(T):
nni = ~torch.isnan(observations[t]['state'][:,0])
max_nv = max(max_nv,nni.count_nonzero())
self.raw_data['state'].append(observations[t]['state'][nni])
self.raw_data['relative_state'].append(observations[t]['relative_state'][nni.nonzero(),nni.nonzero()])
self.raw_data['action'].append(actions[t][nni])
self.raw_data['path_x'].append(observations[t]['paths'][0][nni])
self.raw_data['path_y'].append(observations[t]['paths'][1][nni])
# cat lists
self.raw_data['state'] = torch.cat(self.raw_data['state'])
self.raw_data['action'] = torch.cat(self.raw_data['action'])
self.raw_data['path_x'] = torch.cat(self.raw_data['path_x'])
self.raw_data['path_y'] = torch.cat(self.raw_data['path_y'])
# pad second dimension of relative state
for i in range(len(self.raw_data['relative_state'])):
nv1, nv2, d = self.raw_data['relative_state'][i].shape
pad = torch.zeros(nv1, max_nv-nv2, d) * np.nan
self.raw_data['relative_state'][i] = torch.cat((self.raw_data['relative_state'][i], pad), dim=1)
self.raw_data['relative_state'] = torch.cat(self.raw_data['relative_state'])
# mandate equal length
assert len(self.raw_data['state']) == len(self.raw_data['relative_state']) \
== len(self.raw_data['action']) \
== len(self.raw_data['path_x']) \
== len(self.raw_data['path_y']), 'dataset lengths unequal'
def __len__(self):
return len(self.raw_data['state'])
def __getitem__(self, idx):
"""
Sample from the dataset
Args:
idx: index or indices of B samples
Returns:
sample (dict): sample dictionary with the following entries:
state (torch.tensor): (B, 5) raw state
relative_state (torch.tensor): (B, max_nv, d) relative state (padded with nans)
path_x (torch.tensor): (B, P) tensor of P future path x positions
path_y (torch.tensor): (B, P) tensor of P future path y positions
action (torch.tensor): (B, 1) actions taken from each state
"""
keys = ['state', 'relative_state', 'path_x', 'path_y', 'action']
sample = {key:self.raw_data[key][idx] for key in keys}
for key in keys:
if key in self.transforms.keys():
sample[key] = self.transforms[key](sample[key])
return sample

View File

@@ -1,95 +0,0 @@
import torch
import pickle
import gym
import numpy as np
import intersim
from intersim.utils import get_map_path, get_svt, SVT_to_stateactions
from intersim import collisions
import os
opj = os.path.join
def generate_expert_data(path: str='expert_data', loc: int = 0, track:int = 0, **kwargs):
"""
Function to save (joint) states and observations from simulated frame
Args:
path (str): directory to save data
loc (int): location index
track (int): track index
kwargs: arguments for environment instantiation
"""
if not os.path.isdir(path):
os.mkdir(path)
filestr = opj(path,intersim.LOCATIONS[loc]+'_track%03i'%(track))
svt, svt_path = get_svt(base='InteractionSimulator', loc=loc, track=track)
osm = get_map_path(base='InteractionSimulator', loc=loc)
print('SVT path: {}'.format(svt_path))
print('Map path: {}'.format(osm))
states, actions = SVT_to_stateactions(svt)
# animate from environment
env = gym.make('intersim:intersim-v0', svt=svt, map_path=osm, **kwargs,
min_acc=-np.inf, max_acc=np.inf)
env.reset()
done = False
obs, actions_taken, max_devs = [], [], []
i = 0
while not done and i < len(actions):
# check state deviation
env_state = env.projected_state
nni = ~torch.isnan(env_state[:,0])
norms = torch.norm(env_state[nni,:2]-states[i,nni,:2], dim=1)
max_devs.append(norms.max())
# propagate environment
ob, r, done, info = env.step(env.target_state(svt.simstate[i+1]))
obs.append(ob)
actions_taken.append(info['action_taken'])
i += 1
print("Maximum environment deviation from track: %f m" %(max(max_devs)))
# check for collisions
x = torch.stack([ob['state'] for ob in obs])
cols = collisions.check_collisions_trajectory(x, svt.lengths, svt.widths)
assert ~torch.any(cols), 'Error: Collisions found at indices {}'.format(cols.nonzero(as_tuple=True))
# shift actions
actions_taken.pop(0)
obs.pop(-1)
# save observations and actions
pickle.dump(obs,open(filestr+'_observations.pkl', 'wb'))
torch.save(torch.stack(actions_taken), filestr+'_actions.pt')
def load_expert_data(path='expert_data', loc: int = 0, track:int = 0):
"""
Load expert data from file.
Args:
path (str): directory to save data
loc (int): location index
track (int): track index
Returns:
obs (list[Observations]): list of observations
actions (list[torch.tensor]): list of corresponding actions taken in observations
"""
# load observations and actions
filestr = opj(path, intersim.LOCATIONS[loc]+'_track%03i'%(track))
obs = pickle.load(open(filestr+'_observations.pkl', 'rb'))
actions = torch.load(filestr+'_actions.pt')
actions = list(torch.unbind(actions))
return obs, actions
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser(description='Save Expert Trajectories')
parser.add_argument('--loc', default=0, type=int,
help='location (default 0)')
parser.add_argument('--track', default=0, type=int,
help='track number (default 0)')
args = parser.parse_args()
generate_expert_data(loc=args.loc,track=args.track)

View File

@@ -1,42 +0,0 @@
import torch
from torch import nn
from interimit.nets.deepsets import DeepSetsModule, Phi
class Policy:
pass
class DeepSetsPolicy(Policy, nn.Module):
def __init__(self, ego_config, dynamic_config, path_config, head_config):
"""
Args:
ego_config (dict): dictionary for configuring the ego network
dynamic_config (dict): dictionary for configuring the dynamic input (deepsets) network
path_config (dict): dictionary for configuring the path network
head_config (dict): dictionary for configuring the common head network
"""
super(DeepSetsPolicy, self).__init__()
self.ego_net = Phi.from_config(ego_config)
self.deepsets = DeepSetsModule.from_config(dynamic_config)
self.path_net = Phi.from_config(path_config)
cat_dim = self.ego_net.output_dim + self.deepsets.output_dim + self.path_net.output_dim
# head has number of concatenated features as input
head_config["input_dim"] = cat_dim
self.head = Phi.from_config(head_config)
def forward(self, ego_state, relative_states, path):
"""
Args:
ego_state (torch.tensor): (ns,) state of ego vehicle
relative_states (torch.tensor): (nv, ns) relative states of other vehicles (dynamic size)
path (torch.tensor): (path_length, 2) coordinates (x,y) of path
Returns:
x (torch.tensor): (head_output_dim,) output of common head network
"""
x_ego = self.ego_net(ego_state)
x_relative = self.deepsets(relative_states)
x_path = self.path_net(path.flatten())
x = torch.cat([x_ego, x_relative, x_path])
x = self.head(x)
return x

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More