metacontroller-pytorch 0.0.1__py3-none-any.whl → 0.0.3__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.
@@ -49,6 +49,7 @@ class MetaController(Module):
49
49
  self,
50
50
  dim_latent,
51
51
  *,
52
+ switch_per_latent_dim = True,
52
53
  decoder_expansion_factor = 2.,
53
54
  decoder_depth = 1,
54
55
  hypernetwork_low_rank = 16,
@@ -70,8 +71,10 @@ class MetaController(Module):
70
71
 
71
72
  # switching unit
72
73
 
74
+ self.switch_per_latent_dim = switch_per_latent_dim
75
+
73
76
  self.switching_unit = GRU(dim_latent, dim_latent)
74
- self.to_switching_unit_beta = nn.Linear(dim_latent, 1, bias = False)
77
+ self.to_switching_unit_beta = nn.Linear(dim_latent, dim_latent if switch_per_latent_dim else 1, bias = False)
75
78
 
76
79
  self.switch_gating = AssocScan(**assoc_scan_kwargs)
77
80
 
@@ -154,7 +157,7 @@ class MetaController(Module):
154
157
  switch_beta = self.to_switching_unit_beta(switching_unit_gru_out).sigmoid()
155
158
 
156
159
  action_intent_for_gating = rearrange(sampled_action_intents, 'b n d -> (b d) n')
157
- switch_beta = repeat(switch_beta, 'b n 1 -> (b d) n', d = dim)
160
+ switch_beta = repeat(switch_beta, 'b n d -> (b r d) n', r = dim if not self.switch_per_latent_dim else 1)
158
161
 
159
162
  forget = 1. - switch_beta
160
163
  gated_action_intent = self.switch_gating(action_intent_for_gating * forget, switch_beta)
@@ -212,6 +215,8 @@ class Transformer(Module):
212
215
 
213
216
  self.meta_controller = meta_controller
214
217
 
218
+ self.register_buffer('zero', tensor(0.), persistent = False)
219
+
215
220
  def evolve(
216
221
  self,
217
222
  environment,
@@ -235,7 +240,7 @@ class Transformer(Module):
235
240
  discovery_phase = False,
236
241
  return_latents = False
237
242
  ):
238
- meta_controller = default(meta_controller, self.meta_controller, Identity())
243
+ meta_controller = default(meta_controller, self.meta_controller)
239
244
 
240
245
  embed = self.embed(ids)
241
246
 
@@ -243,7 +248,10 @@ class Transformer(Module):
243
248
 
244
249
  # meta controller acts on residual stream here
245
250
 
246
- modified_residual_stream, vae_aux_loss = meta_controller(residual_stream, discovery_phase = discovery_phase)
251
+ if exists(meta_controller):
252
+ modified_residual_stream, vae_aux_loss = meta_controller(residual_stream, discovery_phase = discovery_phase)
253
+ else:
254
+ modified_residual_stream, vae_aux_loss = residual_stream, self.zero
247
255
 
248
256
  # modified residual stream sent back
249
257
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: metacontroller-pytorch
3
- Version: 0.0.1
3
+ Version: 0.0.3
4
4
  Summary: Transformer Metacontroller
5
5
  Project-URL: Homepage, https://pypi.org/project/metacontroller/
6
6
  Project-URL: Repository, https://github.com/lucidrains/metacontroller
@@ -0,0 +1,6 @@
1
+ metacontroller/__init__.py,sha256=lj7IOGpN--qMxJWbB-4SGqoPXG7Hd4mgtToTRSyTZ58,57
2
+ metacontroller/metacontroller.py,sha256=JZHAkyYbonP5aj_Ob-Xe41ziLEoJLL0KjJy3Dm_bXGY,8091
3
+ metacontroller_pytorch-0.0.3.dist-info/METADATA,sha256=XO3zKqbfSpGmYe34P0uXetIygqkfD1QLuKSSClEeZhk,3706
4
+ metacontroller_pytorch-0.0.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
5
+ metacontroller_pytorch-0.0.3.dist-info/licenses/LICENSE,sha256=1yCiA9b5nhslTavxPjsQAO-wpOnwJR9-l8LTVi7GJuk,1066
6
+ metacontroller_pytorch-0.0.3.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- metacontroller/__init__.py,sha256=lj7IOGpN--qMxJWbB-4SGqoPXG7Hd4mgtToTRSyTZ58,57
2
- metacontroller/metacontroller.py,sha256=Pyv6iNGj8qyNKTF8AVHo9MK-Jg8g7A0xo5jZTeSU4Ys,7717
3
- metacontroller_pytorch-0.0.1.dist-info/METADATA,sha256=PuTRLQAP7vDagLO4f_bSQJJDS1tbhltwcczoQg_QZzk,3706
4
- metacontroller_pytorch-0.0.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
5
- metacontroller_pytorch-0.0.1.dist-info/licenses/LICENSE,sha256=1yCiA9b5nhslTavxPjsQAO-wpOnwJR9-l8LTVi7GJuk,1066
6
- metacontroller_pytorch-0.0.1.dist-info/RECORD,,