Skip to main content

Contrastive RL

Project description

contrastive-rl (wip)

For following a new line of research that started in 2022 from Eysenbach et al.

install

$ pip install contrastive-rl-pytorch

usage

import torch
from contrastive_rl_pytorch import ContrastiveRLTrainer
from x_mlps_pytorch import MLP

encoder = MLP(16, 256, 128)

trainer = ContrastiveRLTrainer(encoder)

trajectories = torch.randn(256, 512, 16)

trainer(trajectories, 100)

# train for 100 steps and save

torch.save(encoder.state_dict(), './trained.pt')

citations

@misc{eysenbach2023contrastivelearninggoalconditionedreinforcement,
    title   = {Contrastive Learning as Goal-Conditioned Reinforcement Learning}, 
    author  = {Benjamin Eysenbach and Tianjun Zhang and Ruslan Salakhutdinov and Sergey Levine},
    year    = {2023},
    eprint  = {2206.07568},
    archivePrefix = {arXiv},
    primaryClass = {cs.LG},
    url     = {https://arxiv.org/abs/2206.07568}, 
}
@misc{ziarko2025contrastiverepresentationstemporalreasoning,
    title   = {Contrastive Representations for Temporal Reasoning}, 
    author  = {Alicja Ziarko and Michal Bortkiewicz and Michal Zawalski and Benjamin Eysenbach and Piotr Milos},
    year    = {2025},
    eprint  = {2508.13113},
    archivePrefix = {arXiv},
    primaryClass = {cs.LG},
    url     = {https://arxiv.org/abs/2508.13113}, 
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

contrastive_rl_pytorch-0.0.8.tar.gz (371.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

contrastive_rl_pytorch-0.0.8-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file contrastive_rl_pytorch-0.0.8.tar.gz.

File metadata

  • Download URL: contrastive_rl_pytorch-0.0.8.tar.gz
  • Upload date:
  • Size: 371.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for contrastive_rl_pytorch-0.0.8.tar.gz
Algorithm Hash digest
SHA256 9550073307900df9dc683f60bdbf60b8c24f9c3495d047a6969a03de1a7656cd
MD5 355b5d92c26507915c07138f10c02136
BLAKE2b-256 bf6e348791c0edb4aaef056dbe36cc65a9ae95adcbd7f575157ab2a43c4ed6a2

See more details on using hashes here.

File details

Details for the file contrastive_rl_pytorch-0.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for contrastive_rl_pytorch-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 1c47abc58c819f294b6c8ece5cdd3a1e8c01e66bdcf11f861e3b5ae29793e45c
MD5 0053d31e2ee81aa3e47eb6d733b1175c
BLAKE2b-256 6efec95ff6bfb0cc5c972e17dc6faf9be855518fdff17cc6413f49247c2d3a5b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page