dreamer4 0.0.7__py3-none-any.whl → 0.1.16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dreamer4 might be problematic. Click here for more details.
- dreamer4/__init__.py +8 -2
- dreamer4/dreamer4.py +2808 -814
- dreamer4/mocks.py +97 -0
- dreamer4/trainers.py +525 -3
- {dreamer4-0.0.7.dist-info → dreamer4-0.1.16.dist-info}/METADATA +97 -11
- dreamer4-0.1.16.dist-info/RECORD +8 -0
- dreamer4-0.0.7.dist-info/RECORD +0 -7
- {dreamer4-0.0.7.dist-info → dreamer4-0.1.16.dist-info}/WHEEL +0 -0
- {dreamer4-0.0.7.dist-info → dreamer4-0.1.16.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dreamer4
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.1.16
|
|
4
4
|
Summary: Dreamer 4
|
|
5
5
|
Project-URL: Homepage, https://pypi.org/project/dreamer4/
|
|
6
6
|
Project-URL: Repository, https://github.com/lucidrains/dreamer4
|
|
@@ -35,12 +35,16 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
35
35
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
36
36
|
Requires-Python: >=3.9
|
|
37
37
|
Requires-Dist: accelerate
|
|
38
|
+
Requires-Dist: adam-atan2-pytorch>=0.2.2
|
|
38
39
|
Requires-Dist: assoc-scan
|
|
39
40
|
Requires-Dist: einops>=0.8.1
|
|
40
41
|
Requires-Dist: einx>=0.3.0
|
|
42
|
+
Requires-Dist: ema-pytorch
|
|
41
43
|
Requires-Dist: hl-gauss-pytorch
|
|
44
|
+
Requires-Dist: hyper-connections>=0.2.1
|
|
42
45
|
Requires-Dist: torch>=2.4
|
|
43
46
|
Requires-Dist: torchvision
|
|
47
|
+
Requires-Dist: vit-pytorch>=1.15.3
|
|
44
48
|
Requires-Dist: x-mlps-pytorch>=0.0.29
|
|
45
49
|
Provides-Extra: examples
|
|
46
50
|
Provides-Extra: test
|
|
@@ -50,11 +54,100 @@ Description-Content-Type: text/markdown
|
|
|
50
54
|
|
|
51
55
|
<img src="./dreamer4-fig2.png" width="400px"></img>
|
|
52
56
|
|
|
53
|
-
## Dreamer 4
|
|
57
|
+
## Dreamer 4
|
|
54
58
|
|
|
55
59
|
Implementation of Danijar's [latest iteration](https://arxiv.org/abs/2509.24527v1) for his [Dreamer](https://danijar.com/project/dreamer4/) line of work
|
|
56
60
|
|
|
57
|
-
[
|
|
61
|
+
[Discord channel](https://discord.gg/PmGR7KRwxq) for collaborating with other researchers interested in this work
|
|
62
|
+
|
|
63
|
+
## Appreciation
|
|
64
|
+
|
|
65
|
+
- [@dirkmcpherson](https://github.com/dirkmcpherson) for fixes to typo errors and unpassed arguments!
|
|
66
|
+
|
|
67
|
+
## Install
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
$ pip install dreamer4
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Usage
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
import torch
|
|
77
|
+
from dreamer4 import VideoTokenizer, DynamicsWorldModel
|
|
78
|
+
|
|
79
|
+
# video tokenizer, learned through MAE + lpips
|
|
80
|
+
|
|
81
|
+
tokenizer = VideoTokenizer(
|
|
82
|
+
dim = 512,
|
|
83
|
+
dim_latent = 32,
|
|
84
|
+
patch_size = 32,
|
|
85
|
+
image_height = 256,
|
|
86
|
+
image_width = 256
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
video = torch.randn(2, 3, 10, 256, 256)
|
|
90
|
+
|
|
91
|
+
# learn the tokenizer
|
|
92
|
+
|
|
93
|
+
loss = tokenizer(video)
|
|
94
|
+
loss.backward()
|
|
95
|
+
|
|
96
|
+
# dynamics world model
|
|
97
|
+
|
|
98
|
+
world_model = DynamicsWorldModel(
|
|
99
|
+
dim = 512,
|
|
100
|
+
dim_latent = 32,
|
|
101
|
+
video_tokenizer = tokenizer,
|
|
102
|
+
num_discrete_actions = 4,
|
|
103
|
+
num_residual_streams = 1
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
# state, action, rewards
|
|
107
|
+
|
|
108
|
+
video = torch.randn(2, 3, 10, 256, 256)
|
|
109
|
+
discrete_actions = torch.randint(0, 4, (2, 10, 1))
|
|
110
|
+
rewards = torch.randn(2, 10)
|
|
111
|
+
|
|
112
|
+
# learn dynamics / behavior cloned model
|
|
113
|
+
|
|
114
|
+
loss = world_model(
|
|
115
|
+
video = video,
|
|
116
|
+
rewards = rewards,
|
|
117
|
+
discrete_actions = discrete_actions
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
loss.backward()
|
|
121
|
+
|
|
122
|
+
# do the above with much data
|
|
123
|
+
|
|
124
|
+
# then generate dreams
|
|
125
|
+
|
|
126
|
+
dreams = world_model.generate(
|
|
127
|
+
10,
|
|
128
|
+
batch_size = 2,
|
|
129
|
+
return_decoded_video = True,
|
|
130
|
+
return_for_policy_optimization = True
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
# learn from the dreams
|
|
134
|
+
|
|
135
|
+
actor_loss, critic_loss = world_model.learn_from_experience(dreams)
|
|
136
|
+
|
|
137
|
+
(actor_loss + critic_loss).backward()
|
|
138
|
+
|
|
139
|
+
# learn from environment
|
|
140
|
+
|
|
141
|
+
from dreamer4.mocks import MockEnv
|
|
142
|
+
|
|
143
|
+
mock_env = MockEnv((256, 256), vectorized = True, num_envs = 4)
|
|
144
|
+
|
|
145
|
+
experience = world_model.interact_with_env(mock_env, max_timesteps = 8, env_is_vectorized = True)
|
|
146
|
+
|
|
147
|
+
actor_loss, critic_loss = world_model.learn_from_experience(experience)
|
|
148
|
+
|
|
149
|
+
(actor_loss + critic_loss).backward()
|
|
150
|
+
```
|
|
58
151
|
|
|
59
152
|
## Citation
|
|
60
153
|
|
|
@@ -70,11 +163,4 @@ Implementation of Danijar's [latest iteration](https://arxiv.org/abs/2509.24527v
|
|
|
70
163
|
}
|
|
71
164
|
```
|
|
72
165
|
|
|
73
|
-
|
|
74
|
-
@misc{xiong2025ndrope,
|
|
75
|
-
author = {Jerry Xiong},
|
|
76
|
-
title = {On n-dimensional rotary positional embeddings},
|
|
77
|
-
year = {2025},
|
|
78
|
-
url = {https://jerryxio.ng/posts/nd-rope/}
|
|
79
|
-
}
|
|
80
|
-
```
|
|
166
|
+
*the conquest of nature is to be achieved through number and measure - angels to Descartes in a dream*
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
dreamer4/__init__.py,sha256=Jssh1obzDRtTfBLZl36kXge1cIQlMjf_8DyjPulvKSk,183
|
|
2
|
+
dreamer4/dreamer4.py,sha256=8jpmFTkBCPimC4tOguess9O1DQBcWiN5SNCtFr5_eFQ,125820
|
|
3
|
+
dreamer4/mocks.py,sha256=TfqOB_Gq6N_GggBYwa6ZAJQx38ntlYbXZe23Ne4jshw,2502
|
|
4
|
+
dreamer4/trainers.py,sha256=h_BMi-P2QMVi-IWQCkejPmyA0UzHgKtE1n7Qn1-IrxE,15093
|
|
5
|
+
dreamer4-0.1.16.dist-info/METADATA,sha256=O8GkW6lS7Ri7qB1M87tzex55z3Zn07VXp1AshMfhADI,4973
|
|
6
|
+
dreamer4-0.1.16.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
7
|
+
dreamer4-0.1.16.dist-info/licenses/LICENSE,sha256=1yCiA9b5nhslTavxPjsQAO-wpOnwJR9-l8LTVi7GJuk,1066
|
|
8
|
+
dreamer4-0.1.16.dist-info/RECORD,,
|
dreamer4-0.0.7.dist-info/RECORD
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
dreamer4/__init__.py,sha256=8iFCRNKFe6jyZszN1MZ8DRORtNp_AN_d-wKePaNZ60o,90
|
|
2
|
-
dreamer4/dreamer4.py,sha256=TpVyr7b3UT6hAY0fugiNncmLY-QLJ7AopfUPJUVf2Gg,54982
|
|
3
|
-
dreamer4/trainers.py,sha256=14s_vYAug2iUbk1voXx7CEQA_D66nTmhPn9K6xHKChY,318
|
|
4
|
-
dreamer4-0.0.7.dist-info/METADATA,sha256=iPIcrpWNVGFTLNg2ve4C4axrG9ga5wuIO1adf8JVz5Q,3157
|
|
5
|
-
dreamer4-0.0.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
6
|
-
dreamer4-0.0.7.dist-info/licenses/LICENSE,sha256=1yCiA9b5nhslTavxPjsQAO-wpOnwJR9-l8LTVi7GJuk,1066
|
|
7
|
-
dreamer4-0.0.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|