kevin-toolbox-dev 1.2.7__py3-none-any.whl → 1.3.0__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.
- kevin_toolbox/__init__.py +2 -2
- kevin_toolbox/computer_science/algorithm/registration/registry.py +35 -11
- kevin_toolbox/computer_science/algorithm/statistician/__init__.py +1 -0
- kevin_toolbox/computer_science/algorithm/statistician/accumulator_base.py +146 -0
- kevin_toolbox/computer_science/algorithm/statistician/average_accumulator.py +9 -36
- kevin_toolbox/computer_science/algorithm/statistician/exponential_moving_average.py +10 -18
- kevin_toolbox/computer_science/algorithm/statistician/init_var/__init__.py +2 -0
- kevin_toolbox/computer_science/algorithm/statistician/init_var/init_by_data_format.py +24 -0
- kevin_toolbox/computer_science/algorithm/statistician/init_var/init_by_like.py +20 -0
- kevin_toolbox/data_flow/file/json_/read_json.py +1 -1
- kevin_toolbox/data_flow/file/markdown/generate_table.py +117 -13
- kevin_toolbox/nested_dict_list/copy_.py +7 -7
- kevin_toolbox/nested_dict_list/serializer/__init__.py +1 -0
- kevin_toolbox/nested_dict_list/serializer/enum_variable.py +12 -0
- kevin_toolbox/nested_dict_list/serializer/read.py +2 -1
- kevin_toolbox/nested_dict_list/serializer/variable.py +0 -12
- kevin_toolbox/nested_dict_list/serializer/write.py +2 -1
- kevin_toolbox/nested_dict_list/set_value.py +8 -2
- kevin_toolbox/patches/for_numpy/__init__.py +1 -0
- kevin_toolbox/patches/for_numpy/linalg/softmax.py +40 -4
- kevin_toolbox/patches/for_optuna/sample_from_feasible_domain.py +39 -13
- kevin_toolbox/patches/for_os/__init__.py +1 -0
- kevin_toolbox/patches/for_os/remove.py +4 -2
- kevin_toolbox/patches/for_os/walk.py +167 -0
- kevin_toolbox_dev-1.3.0.dist-info/METADATA +73 -0
- {kevin_toolbox_dev-1.2.7.dist-info → kevin_toolbox_dev-1.3.0.dist-info}/RECORD +28 -23
- kevin_toolbox/computer_science/algorithm/statistician/_init_var.py +0 -27
- kevin_toolbox_dev-1.2.7.dist-info/METADATA +0 -69
- {kevin_toolbox_dev-1.2.7.dist-info → kevin_toolbox_dev-1.3.0.dist-info}/WHEEL +0 -0
- {kevin_toolbox_dev-1.2.7.dist-info → kevin_toolbox_dev-1.3.0.dist-info}/top_level.txt +0 -0
@@ -1,27 +0,0 @@
|
|
1
|
-
import torch
|
2
|
-
import numpy as np
|
3
|
-
|
4
|
-
|
5
|
-
def _init_var(like=None, data_format=None):
|
6
|
-
if like is not None:
|
7
|
-
if torch.is_tensor(like):
|
8
|
-
var = torch.zeros_like(like)
|
9
|
-
elif isinstance(like, (np.ndarray,)):
|
10
|
-
var = np.zeros_like(like)
|
11
|
-
elif isinstance(like, (int, float, np.number,)):
|
12
|
-
var = 0.0
|
13
|
-
else:
|
14
|
-
raise ValueError("paras 'like' should be np.ndarray, torch.tensor or int/float")
|
15
|
-
elif data_format is not None:
|
16
|
-
assert isinstance(data_format, (dict,)) and "type_" in data_format and "shape" in data_format
|
17
|
-
k_s = copy.deepcopy(data_format)
|
18
|
-
k_s.pop("type_")
|
19
|
-
k_s.pop("shape")
|
20
|
-
if data_format["type_"] == "torch":
|
21
|
-
var = torch.zeros(size=data_format["shape"], **k_s)
|
22
|
-
else:
|
23
|
-
var = np.zeros(shape=data_format["shape"], **k_s)
|
24
|
-
else:
|
25
|
-
var = None
|
26
|
-
|
27
|
-
return var
|
@@ -1,69 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: kevin-toolbox-dev
|
3
|
-
Version: 1.2.7
|
4
|
-
Summary: 一个常用的工具代码包集合
|
5
|
-
Home-page: https://github.com/cantbeblank96/kevin_toolbox
|
6
|
-
Download-URL: https://github.com/username/your-package/archive/refs/tags/v1.0.0.tar.gz
|
7
|
-
Author: kevin hsu
|
8
|
-
Author-email: xukaiming1996@163.com
|
9
|
-
License: MIT
|
10
|
-
Keywords: mathematics,pytorch,numpy,machine-learning,algorithm
|
11
|
-
Classifier: License :: OSI Approved :: MIT License
|
12
|
-
Classifier: Programming Language :: Python
|
13
|
-
Classifier: Programming Language :: Python :: 3
|
14
|
-
Requires-Python: >=3.6
|
15
|
-
Description-Content-Type: text/markdown
|
16
|
-
Requires-Dist: torch (>=1.2.0)
|
17
|
-
Requires-Dist: numpy (>=1.19.0)
|
18
|
-
Provides-Extra: plot
|
19
|
-
Requires-Dist: matplotlib (>=3.0) ; extra == 'plot'
|
20
|
-
Provides-Extra: rest
|
21
|
-
Requires-Dist: pytest (>=6.2.5) ; extra == 'rest'
|
22
|
-
Requires-Dist: line-profiler (>=3.5) ; extra == 'rest'
|
23
|
-
|
24
|
-
# kevin_toolbox
|
25
|
-
|
26
|
-
一个通用的工具代码包集合
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
环境要求
|
31
|
-
|
32
|
-
```shell
|
33
|
-
numpy>=1.19
|
34
|
-
pytorch>=1.2
|
35
|
-
```
|
36
|
-
|
37
|
-
安装方法:
|
38
|
-
|
39
|
-
```shell
|
40
|
-
pip install kevin-toolbox --no-dependencies
|
41
|
-
```
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
[项目地址 Repo](https://github.com/cantbeblank96/kevin_toolbox)
|
46
|
-
|
47
|
-
[使用指南 User_Guide](./notes/User_Guide.md)
|
48
|
-
|
49
|
-
[免责声明 Disclaimer](./notes/Disclaimer.md)
|
50
|
-
|
51
|
-
[版本更新记录](./notes/Release_Record.md):
|
52
|
-
|
53
|
-
- v 1.2.7 (2023-09-18)【bug fix】
|
54
|
-
- nested_dict_list
|
55
|
-
- 【bug fix】fix bug in set_value(),修复了无法强制设置以@开头的name的问题
|
56
|
-
- 【bug fix】fix bug in serializer.read(),修复了在不进行解压时仍然构造temp_dir的问题
|
57
|
-
- 【bug fix】fix bug in copy_(),修复了无法复制带有 grad_func 的tensor的问题。
|
58
|
-
- 添加了测试用例。
|
59
|
-
- 注意:本修复只解决节点是tensor的情况,对于节点是含有不能deepcopy的tensor的变量,比如由带有 grad_func 的tensor组成的tuple等的结构,copy_()函数仍然会报错。考虑到这种情况非常复杂,因此不作解决,只能尽量避免,或者出错时专门排查。
|
60
|
-
- 改造模块加载方式,支持通过x.y间接加载子模块,比如 nested_dict_list.serializer 等
|
61
|
-
- 【new feature】modify copy_(),增加了 b_keep_internal_references 参数用于控制是否保留内部的引用关系。
|
62
|
-
- 当使用 b_keep_internal_references=True 时,将保留 ndl 中结构与结构之间或者节点与节点之间的引用关系。默认为 True(当b_deepcopy=True时与 copy.deepcopy 的行为一致)。
|
63
|
-
- 什么是引用关系?
|
64
|
-
- 比如我们将某个字典 A 多次加入到某个 list 中,那么这个 list 中的这些字典实际上都指向内存上同一个字典,因此对其中某个字典的修改将影响到其他 list 中的其他元素。这种内存上指向同一个位置的关系就是引用。
|
65
|
-
- 与 b_deepcopy 的配合:
|
66
|
-
- 当 b_deepcopy=False 进行浅拷贝时,参数 b_keep_internal_references 仅作用于结构,反之则同时作用于结构和节点。
|
67
|
-
- 添加了测试用例。
|
68
|
-
- nested_dict_list.serializer
|
69
|
-
- modify write(),只对输入进行浅拷贝,减少对内存的消耗。
|
File without changes
|
File without changes
|