returnn 1.20251023.135024__py3-none-any.whl → 1.20251027.117__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 returnn might be problematic. Click here for more details.

returnn/PKG-INFO CHANGED
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: returnn
3
- Version: 1.20251023.135024
3
+ Version: 1.20251027.117
4
4
  Summary: The RWTH extensible training framework for universal recurrent neural networks
5
5
  Home-page: https://github.com/rwth-i6/returnn/
6
6
  Author: Albert Zeyer
@@ -1,2 +1,2 @@
1
- version = '1.20251023.135024'
2
- long_version = '1.20251023.135024+git.38ff979'
1
+ version = '1.20251027.000117'
2
+ long_version = '1.20251027.000117+git.f3e7971'
returnn/datasets/meta.py CHANGED
@@ -1348,7 +1348,10 @@ class CombinedDataset(CachedDataset2):
1348
1348
  if dataset_data_key is not None:
1349
1349
  return dataset.get_data(dataset_seq_idx, dataset_data_key)
1350
1350
  else:
1351
- return numpy.array([], self.data_dtypes[data_key])
1351
+ shape: List[int] = [0] * self.num_outputs[data_key][1]
1352
+ if shape and not self.is_data_sparse(data_key):
1353
+ shape[-1] = self.get_data_dim(data_key)
1354
+ return numpy.zeros(shape, dtype=self.data_dtypes[data_key])
1352
1355
 
1353
1356
  def _collect_single_seq(self, seq_idx):
1354
1357
  """
@@ -274,10 +274,17 @@ class Functional(Module):
274
274
  (This is often not necessary, but sometimes useful.)
275
275
  """
276
276
 
277
- def __init__(self, func):
277
+ def __init__(self, func, *, attribs: Optional[Dict[str, Any]] = None):
278
+ """
279
+ :param func: callable. you might want to use functools.partial if you want to fix some arguments.
280
+ :param attribs: optional dict of attributes to set on this module. e.g. ``out_dim``.
281
+ """
278
282
  super().__init__()
279
283
  assert callable(func)
280
284
  self.func = func
285
+ if attribs:
286
+ for k, v in attribs.items():
287
+ setattr(self, k, v)
281
288
 
282
289
  def __repr__(self):
283
290
  return f"{self.__class__.__name__}({self.func.__qualname__})"
@@ -0,0 +1,79 @@
1
+ """
2
+ Customized (derived) dict to pass as ``collected_outputs`` to some of the RF modules,
3
+ or potential other use cases.
4
+
5
+ You can predefine (by pattern) what kind of outputs you want to collect and store in this dict.
6
+ """
7
+
8
+ from typing import Optional, Union, Sequence
9
+ import fnmatch
10
+
11
+
12
+ class CollectOutputsDict(dict):
13
+ """
14
+ Customized (derived) dict, where you can predefine (by key pattern)
15
+ what kind of keys you want to collect and store in this dict.
16
+ Other keys will be ignored.
17
+ """
18
+
19
+ def __init__(self, *args, allowed_key_patterns: Optional[Sequence[str]] = None, **kwargs):
20
+ """
21
+ Initialize the CollectOutputsDict.
22
+
23
+ :param allowed_key_patterns:
24
+ List of key patterns (with wildcards) that are allowed to be stored in the dict.
25
+ If None, all keys are allowed.
26
+ """
27
+ super().__init__(*args, **kwargs)
28
+ self.allowed_key_patterns = allowed_key_patterns
29
+
30
+ def __setitem__(self, key, value):
31
+ """
32
+ Set an item in the dict if the key matches allowed patterns.
33
+ """
34
+ if self.is_key_allowed(key):
35
+ super().__setitem__(key, value)
36
+
37
+ def setdefault(self, key, default=None):
38
+ """
39
+ Set default value for a key if it matches allowed patterns.
40
+ """
41
+ if self.is_key_allowed(key):
42
+ return super().setdefault(key, default)
43
+ return None
44
+
45
+ def update(self, mapping, **kwargs):
46
+ """
47
+ Update the dict with another mapping, only adding allowed keys.
48
+ """
49
+ assert not kwargs
50
+ for key, value in mapping.items():
51
+ if self.is_key_allowed(key):
52
+ super().__setitem__(key, value)
53
+
54
+ def is_key_allowed(self, key: str) -> bool:
55
+ """
56
+ Check if the key matches any of the allowed patterns.
57
+
58
+ :param key:
59
+ :return: True if the key is allowed, False otherwise.
60
+ """
61
+ if self.allowed_key_patterns is None:
62
+ return True # If no patterns defined, allow all keys
63
+ for pattern in self.allowed_key_patterns:
64
+ if fnmatch.fnmatch(key, pattern):
65
+ return True
66
+ return False
67
+
68
+
69
+ def is_key_allowed_in_collect_outputs_dict(collect_outputs: Union[CollectOutputsDict, dict], key: str) -> bool:
70
+ """
71
+ Check if a key is allowed in the given CollectOutputsDict.
72
+
73
+ :param collect_outputs:
74
+ :param key:
75
+ :return: True if the key is allowed, False otherwise.
76
+ """
77
+ if isinstance(collect_outputs, CollectOutputsDict):
78
+ return collect_outputs.is_key_allowed(key)
79
+ return True # If it's a regular dict, all keys are allowed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: returnn
3
- Version: 1.20251023.135024
3
+ Version: 1.20251027.117
4
4
  Summary: The RWTH extensible training framework for universal recurrent neural networks
5
5
  Home-page: https://github.com/rwth-i6/returnn/
6
6
  Author: Albert Zeyer
@@ -1,9 +1,9 @@
1
- returnn/PKG-INFO,sha256=oMkcYAcARcjEl0nZwPeRXUqfvAq6axgzxZUwsJ3cKM8,5215
1
+ returnn/PKG-INFO,sha256=5Pb1iE8plEOp8u6YgK8RC_SSyBmyhFba_D-gcXEE8YI,5212
2
2
  returnn/__init__.py,sha256=biBtRsM0WZ406vShaeH-9WFoqJ8XwTbn6g0EeFJ7l8E,1012
3
3
  returnn/__main__.py,sha256=lHyZcu_0yc9f7Vf_Kfdy9PmeU0T76XVXnpalHi5WKro,31740
4
4
  returnn/__old_mod_loader__.py,sha256=nvsNY-xELdS_IPNkv66Q9Rmvg4dbGW0-EBRDcCmctos,7654
5
5
  returnn/__setup__.py,sha256=22kQn2fh11iPM0hLb2Fy5sLmoU1JGvmDxXRYuRgQkwU,4659
6
- returnn/_setup_info_generated.py,sha256=FlOAQ7mEXZZTomQ9YMRq04bUBY31BOZGo1abm1fLkFg,77
6
+ returnn/_setup_info_generated.py,sha256=KECmOblD-dsBEVI8f_tn-BVnMF4NTy5DuhuYtunMF1M,77
7
7
  returnn/config.py,sha256=3tmKhB6FnQZaNdtcYsiB61JnEY--iZ2qmJ4yq0b6tE0,29140
8
8
  returnn/forward_iface.py,sha256=A_OJiaXsX4MlXQRzST86ylyxSUZbC402PQL1REcqHjM,911
9
9
  returnn/learning_rate_control.py,sha256=ZvWryAn_tv9DhV8sh1LV3eE34Yltl3On3mYZAG4hR9s,34684
@@ -23,7 +23,7 @@ returnn/datasets/hdf.py,sha256=v5sjBenURR9Z-g7AQ9tsL84yDSye5RtbLpym3M6HSDE,67833
23
23
  returnn/datasets/huggingface.py,sha256=ls9WMR6gUcMgGksl80g0An1az5Xjya_V3ojbbbsZqrU,20047
24
24
  returnn/datasets/lm.py,sha256=rQ3jV43lSnlGkKu7m5jTTH7aK0BOMXQocsHfJ8OGec8,99950
25
25
  returnn/datasets/map.py,sha256=kOBJVZmwDhLsOplzDNByIfa0NRSUaMo2Lsy36lBvxrM,10907
26
- returnn/datasets/meta.py,sha256=6XPPxhiNSxWw9Hu5Z6wG8dD9Zk82FqiI-k9HGQSTKgw,95658
26
+ returnn/datasets/meta.py,sha256=E1ZOlIMk4PiNMd5bUCnxdAU7K2hLYEY4Jn6GqbFjjMw,95850
27
27
  returnn/datasets/multi_proc.py,sha256=BClXq0fActi1XQa4vcMhHmhYF0Q-fnnDzlIlbBM6_DM,22614
28
28
  returnn/datasets/normalization_data.py,sha256=J3njQCMvWAbIAVPepO2L_Xdau9eWYB7Zyd6STeGzTbc,14615
29
29
  returnn/datasets/numpy_dump.py,sha256=wl8bKIKAlff2HPJPtuu5wBg3TLOf16d2wLVB4lLAwTM,5158
@@ -104,7 +104,7 @@ returnn/frontend/loop.py,sha256=t-z6ke1X03I2aPUEqLYmVZWyMzfW3IedFvKUGc-TCX8,1616
104
104
  returnn/frontend/loss.py,sha256=uSvou2MPd13JiLAg_OIQ3AyyLvD3RHjMEVgFEN0gKqU,7440
105
105
  returnn/frontend/math_.py,sha256=A_RkZ5lH2uXMchfPIH3itraWtMNNCVckQHHpf7aIIZQ,17295
106
106
  returnn/frontend/matmul.py,sha256=xkueyxzSDz8MsYaWxPSjmV2Yy-tcaiOQDXbFt1IQM2A,1944
107
- returnn/frontend/module.py,sha256=219rh5mE0CD0-NdxXLsKyhv3BNtOI9jSyiI1Rb8MOyU,10700
107
+ returnn/frontend/module.py,sha256=nt35I9xyHuH42qobLHGUFoNI5-mVieAtA36SqK6NhpY,11065
108
108
  returnn/frontend/nested.py,sha256=PKsKWHwE2SI19DjZ9vRI8q4-ywIGMK3-TTUuqdXrVlM,15592
109
109
  returnn/frontend/normalization.py,sha256=NrIIaZ3c2yf-WH2R9lPaL2TAq4IcNQc4OE5kFYdoihw,14139
110
110
  returnn/frontend/parameter.py,sha256=zvrkhSYC1c_O9kVwgHvOtOnWNurl5J28lkS0i1LQpWU,10627
@@ -237,6 +237,7 @@ returnn/util/__init__.py,sha256=UIG1qw4idqhW71BV60ha7h9PktxvEVcBIu0lYRossK8,336
237
237
  returnn/util/basic.py,sha256=MBbyYddO0aJj8Xcb9RbQ5VeunC7htc9IGex09eao67o,143323
238
238
  returnn/util/better_exchook.py,sha256=39yvRecluDgYhViwSkaQ8crJ_cBWI63KeEGuK4RKe5w,70843
239
239
  returnn/util/bpe.py,sha256=LWFhICZsEOnMwNws0lybPNzKRX6rSr8yKCvP65vjl9Y,19656
240
+ returnn/util/collect_outputs_dict.py,sha256=CjpsftoMgmvyE4wNKTO6F-QQ_44QHXcOZIXMUMQVZ-8,2637
240
241
  returnn/util/debug.py,sha256=wuRzdg9zB84WWCGyTjmRR_zYypu8gXxlc0nZ6si9OC8,28224
241
242
  returnn/util/debug_helpers.py,sha256=0EINLK4uLtoSt5_kHs1M2NIFpMd0S7i4c4rx90U4fJk,2914
242
243
  returnn/util/file_cache.py,sha256=Wyx9u1P59PAo4HouVPh6uaGQeFIXGZHshDyvcRn4YlM,28786
@@ -254,8 +255,8 @@ returnn/util/sig_proc.py,sha256=Tjz0VOAVyqu2qDCF5HZ1JjALjcFsHcNkcd96WgZeKfE,7265
254
255
  returnn/util/task_system.py,sha256=y4sMVXQ25Qd2z0rx03uOlXlkE-jbCYC1Sjfn-XlraVU,26003
255
256
  returnn/util/train_proc_manager.py,sha256=Pjht28k6uz6BNQ47uW6Gf880iyq5q4wx7P_K2tmoAM8,3266
256
257
  returnn/util/watch_memory.py,sha256=BR5P2kvBN6UI81cE0_1WAA6Hd1SByLbBaiDxvLhPOew,4213
257
- returnn-1.20251023.135024.dist-info/LICENSE,sha256=ywBD_U2aD4vpuoIgNAsjIGBYydl0tVKll3De0Z8s77c,11041
258
- returnn-1.20251023.135024.dist-info/METADATA,sha256=oMkcYAcARcjEl0nZwPeRXUqfvAq6axgzxZUwsJ3cKM8,5215
259
- returnn-1.20251023.135024.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
260
- returnn-1.20251023.135024.dist-info/top_level.txt,sha256=Lsn4WZc5Pbfk0-xDQOgnFCxOoqxL4CyeM3N1TFbJncw,8
261
- returnn-1.20251023.135024.dist-info/RECORD,,
258
+ returnn-1.20251027.117.dist-info/LICENSE,sha256=ywBD_U2aD4vpuoIgNAsjIGBYydl0tVKll3De0Z8s77c,11041
259
+ returnn-1.20251027.117.dist-info/METADATA,sha256=5Pb1iE8plEOp8u6YgK8RC_SSyBmyhFba_D-gcXEE8YI,5212
260
+ returnn-1.20251027.117.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
261
+ returnn-1.20251027.117.dist-info/top_level.txt,sha256=Lsn4WZc5Pbfk0-xDQOgnFCxOoqxL4CyeM3N1TFbJncw,8
262
+ returnn-1.20251027.117.dist-info/RECORD,,