maltemosbach / cognitive-robotics-lab-2021

Contains provided material and instructions for the cognitive robotics lab "State space models for Reinforcement Learning".
0 stars 1 forks source link

Implement different latent dynamics models #2

Open maltemosbach opened 3 years ago

maltemosbach commented 3 years ago

Different architectures can be used to implement the latent dynamics model for a model-based agent. Implement the following models in the subdirectories of models/dynamics_models. All dynamics models should inherit from the base class in latent_dynamics_model.py and implement the abstract methods. Implement the dynamics model:

For all models you should implement an encoder e_t = enc(o_t), a decoder p(o_t | s_t), prior and posterior transition dynamics p(s_t | s_t-1, a_t-1) and q(s_t | s_t-1, a_t-1, e_t). Ideally, encoder and decoder are shared between all architectures and only the transition dynamics are implemented separately. You must also implement a reward model that maps form state to reward as it is needed by the planner. Further, in the PlaNet agent, you should create the appropriate functions to calculate your model loss, such that the parameters can be optimized. The only files that should really be relevant for you are algos/planet.py and the dynamics models you should implement in subdirectories of models/dynamics_models. Helpful repositories to get started are:

References

Hafner, D., Lillicrap, T., Fischer, I., Villegas, R., Ha, D., Lee, H. Davidson, J.. (2019). Learning Latent Dynamics for Planning from Pixels. ICML

karacolada commented 2 years ago

Implemented classes VectorEncoder, VectorDecoder, ImageEncoder and ImageDecoder. Layer hyperparameters were taken from the original PlaNet Repo. A quick sanity test for ImageEncoder and ImageDecoder can be found in tests/encoder_decoder.py

maltemosbach commented 2 years ago

Top, hab den code noch nicht getestet, sieht aber gut aus. 2 Dinge, die du noch machen kannst:

  1. Für den Encoder (und Decoder genauso) schreibst du eine Funktion die als input neben der observation_size und embedding_size ein bool argument wie is_image_based oder visual oder so bekommt. Wenn das true is, gibst du deinen image encoder zurück und wenn nicht den vector encoder. Beim Decoder analog.
  2. Wenn du beispielsweise von der observation_size auf eine embedding_size gehen willst, gibt man häufig noch eine zusätzliche variable hidden_size an. Die Layer inputs und outputs wären dann zum Beispiel (observation_size, hidden_size) und (hidden_size, hidden_size) und (hidden_size, embedding_size).
karacolada commented 2 years ago
  1. erledigt, siehe Commit 653fab5
  2. erledigt, siehe Commit dce050c
karacolada commented 2 years ago
karacolada commented 2 years ago

Posterior von SSM stützt sich auf die Originalimplementierung: prior_mean und prior_stddev werden mit in das fully connected NN gegeben, nicht aber ein Zustand, der vom prior gesampled wird (das steht in meinen Notizen). Falls das nicht korrekt ist, ist es schnell geändert.

karacolada commented 2 years ago
karacolada commented 2 years ago

sketch sketch

karacolada commented 2 years ago
sketch