x-transformers 2.9.0__py3-none-any.whl → 2.9.1__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.
x_transformers/attend.py CHANGED
@@ -171,6 +171,9 @@ class Attend(Module):
171
171
  qk_norm = False,
172
172
  l2_distance = False,
173
173
  sigmoid = False,
174
+ gumbel_softmax = False,
175
+ gumbel_softmax_temp = 1.,
176
+ gumbel_softmax_hard = True,
174
177
  custom_attn_fn: Callable | None = None,
175
178
  flash = False,
176
179
  softclamp_logits = False,
@@ -203,7 +206,7 @@ class Attend(Module):
203
206
  assert not (flash and hard), 'hard attention not available for flash'
204
207
  assert not (flash and is_sparse_topk_attn), 'topk attention not available for flash'
205
208
 
206
- assert at_most_one_of(sigmoid, hard, l2_distance, is_sparse_topk_attn)
209
+ assert at_most_one_of(sigmoid, hard, l2_distance, gumbel_softmax, is_sparse_topk_attn)
207
210
 
208
211
  if exists(custom_attn_fn):
209
212
  self.attn_fn = custom_attn_fn
@@ -213,6 +216,8 @@ class Attend(Module):
213
216
  self.attn_fn = one_hot_straight_through
214
217
  elif is_sparse_topk_attn:
215
218
  self.attn_fn = partial(sparse_topk_attn, sparse_topk = sparse_topk, straight_through = sparse_topk_straight_through)
219
+ elif gumbel_softmax:
220
+ self.attn_fn = partial(F.gumbel_softmax, dim = -1, tau = gumbel_softmax_temp, hard = gumbel_softmax_hard)
216
221
  else:
217
222
  softmax_fn = partial(F.softmax, dim = -1)
218
223
  self.attn_fn = partial(softmax_fn, dtype = torch.float32) if not qk_norm else softmax_fn
@@ -1336,6 +1336,9 @@ class Attention(Module):
1336
1336
  value_rmsnorm = False, # used in alphagenome and bytedance's GR3 for further stability
1337
1337
  l2_distance = False,
1338
1338
  sigmoid = False,
1339
+ gumbel_softmax = False,
1340
+ gumbel_softmax_temp = 1.,
1341
+ gumbel_softmax_hard = True,
1339
1342
  selective = False,
1340
1343
  custom_attn_fn: Callable | None = None,
1341
1344
  hybrid_module: Module | None = None,
@@ -1541,6 +1544,9 @@ class Attention(Module):
1541
1544
  scale = qk_norm_scale if qk_norm else self.scale,
1542
1545
  l2_distance = l2_distance,
1543
1546
  sigmoid = sigmoid,
1547
+ gumbel_softmax = gumbel_softmax,
1548
+ gumbel_softmax_temp = gumbel_softmax_temp,
1549
+ gumbel_softmax_hard = gumbel_softmax_hard,
1544
1550
  selective = selective,
1545
1551
  custom_attn_fn = custom_attn_fn,
1546
1552
  add_zero_kv = add_zero_kv,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: x-transformers
3
- Version: 2.9.0
3
+ Version: 2.9.1
4
4
  Summary: X-Transformers
5
5
  Project-URL: Homepage, https://pypi.org/project/x-transformers/
6
6
  Project-URL: Repository, https://github.com/lucidrains/x-transformers
@@ -2574,4 +2574,16 @@ ids_out, num_out, is_number_mask = model.generate(start_ids, start_nums, 17)
2574
2574
  }
2575
2575
  ```
2576
2576
 
2577
+ ```bibtex
2578
+ @misc{yan2017hierarchicalmultiscaleattentionnetworks,
2579
+ title = {Hierarchical Multi-scale Attention Networks for Action Recognition},
2580
+ author = {Shiyang Yan and Jeremy S. Smith and Wenjin Lu and Bailing Zhang},
2581
+ year = {2017},
2582
+ eprint = {1708.07590},
2583
+ archivePrefix = {arXiv},
2584
+ primaryClass = {cs.CV},
2585
+ url = {https://arxiv.org/abs/1708.07590},
2586
+ }
2587
+ ```
2588
+
2577
2589
  *solve intelligence... then use that to solve everything else.* - Demis Hassabis
@@ -1,5 +1,5 @@
1
1
  x_transformers/__init__.py,sha256=aVuhUU0572TJHW88BVc4yA2tla0Zb8l3NH7W4RZ1AEs,1005
2
- x_transformers/attend.py,sha256=jzOwrtCIdAt1dRQBO68htDsgtjdTx6TAQQVB2xflS1w,18091
2
+ x_transformers/attend.py,sha256=mQj3p4RMfifL_P-S-hCtEolIU_GDDLwHZJ2cT8wBf7Q,18356
3
3
  x_transformers/autoregressive_wrapper.py,sha256=BsGO9xfVYkvynqbU1__tu_S_cxl7gss0YwnkhIa2baY,18401
4
4
  x_transformers/belief_state_wrapper.py,sha256=YLUMk6t2MhFBEw5lHDDHJHcoCxTIkHvxTNY__GGZEKU,13374
5
5
  x_transformers/continuous.py,sha256=WwpQCjyVY4PtuEAOFY68zqgklbF9I7AL5w6874YlDe8,13249
@@ -10,10 +10,10 @@ x_transformers/multi_input.py,sha256=tCh-fTJDj2ib4SMGtsa-AM8MxKzJAQSwqAXOu3HU2mg
10
10
  x_transformers/neo_mlp.py,sha256=XCNnnop9WLarcxap1kGuYc1x8GHvwkZiDRnXOxSl3Po,3452
11
11
  x_transformers/nonautoregressive_wrapper.py,sha256=hMQqNimGtchNIe13cR5LZule1V7I1qM5LmY8VQfVdnA,11698
12
12
  x_transformers/up_wrapper.py,sha256=YC2LN14_7Xx9Wtiek2rtEJ_qHqdfSmKlh3d7Cgxwd80,7073
13
- x_transformers/x_transformers.py,sha256=xIaM5LGimNmDThr9WK0ZF5vfm3sSp0OMll0aRIqjymQ,125443
13
+ x_transformers/x_transformers.py,sha256=o6B10urcC7MRUrmoHOgYJgkrVDzHhX-jt6zZY3pZEgA,125700
14
14
  x_transformers/xl_autoregressive_wrapper.py,sha256=CvZMJ6A6PA-Y_bQAhnORwjJBSl6Vjq2IdW5KTdk8NI8,4195
15
15
  x_transformers/xval.py,sha256=AwwYUm8yDAtKQyKJDIhYMsiLTJ_skh3scUFMjp5sda8,8597
16
- x_transformers-2.9.0.dist-info/METADATA,sha256=tQ93i_TSfQIf9OViWNJj57ezY0Slred1NblIyf4UIs0,94986
17
- x_transformers-2.9.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
- x_transformers-2.9.0.dist-info/licenses/LICENSE,sha256=As9u198X-U-vph5noInuUfqsAG2zX_oXPHDmdjwlPPY,1066
19
- x_transformers-2.9.0.dist-info/RECORD,,
16
+ x_transformers-2.9.1.dist-info/METADATA,sha256=XMP7KEX4fg8VvvcpULmJT_1KBKfwIG8yyiHvCnscOyg,95381
17
+ x_transformers-2.9.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
+ x_transformers-2.9.1.dist-info/licenses/LICENSE,sha256=As9u198X-U-vph5noInuUfqsAG2zX_oXPHDmdjwlPPY,1066
19
+ x_transformers-2.9.1.dist-info/RECORD,,