titans-pytorch 0.2.25__tar.gz → 0.2.27__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: titans-pytorch
3
- Version: 0.2.25
3
+ Version: 0.2.27
4
4
  Summary: Titans
5
5
  Project-URL: Homepage, https://pypi.org/project/titans-pytorch/
6
6
  Project-URL: Repository, https://github.com/lucidrains/titans-pytorch
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "titans-pytorch"
3
- version = "0.2.25"
3
+ version = "0.2.27"
4
4
  description = "Titans"
5
5
  authors = [
6
6
  { name = "Phil Wang", email = "lucidrains@gmail.com" }
@@ -73,12 +73,16 @@ def test_titans_attn_memory():
73
73
 
74
74
  assert seq.shape == retrieved.shape
75
75
 
76
- def test_neural_mem_chaining_chunks():
76
+ @pytest.mark.parametrize('gated_transition', (True, False))
77
+ def test_neural_mem_chaining_chunks(
78
+ gated_transition
79
+ ):
77
80
  mem = NeuralMemory(
78
81
  dim = 384,
79
82
  dim_head = 64,
80
83
  heads = 2,
81
- chunk_size = 16
84
+ chunk_size = 16,
85
+ gated_transition = gated_transition
82
86
  )
83
87
 
84
88
  seq = torch.randn(2, 48, 384)
@@ -872,11 +872,11 @@ class NeuralMemory(Module):
872
872
  last_update, _ = past_state
873
873
 
874
874
  if exists(gate):
875
- weights = TensorDict({param_name: v1.lerp(v2, gate) for (param_name, v1), (_, v2) in zip(weights.items(), last_update.items())})
875
+ weights = TensorDict({param_name: one_weight.lerp(one_last_update, gate) for (param_name, one_weight), (_, one_last_update) in zip(weights.items(), last_update.items())})
876
876
  else:
877
877
  weights = last_update
878
878
 
879
- next_neural_mem_state = tuple_index_set(next_neural_mem_state, 1, last_update)
879
+ next_neural_mem_state = tuple_index_set(next_neural_mem_state, 1, weights)
880
880
 
881
881
  next_neural_mem_state = tuple_index_set(next_neural_mem_state, -1, updates)
882
882
 
File without changes