Skip to content

Commit 573bf43

Browse files
TongjiliboTongjilibo
Tongjilibo
authored and
Tongjilibo
committed
add JsonConfig
1 parent c90a8b7 commit 573bf43

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pip install git+https://github.com/Tongjilibo/torch4keras.git
8585
- **v0.0.1**:20221019 初始版本
8686
8787
## 5. 更新:
88-
- **20230907**: 增加from_pretrained和save_pretrained方法,增加log_warn_once方法,compile()中可设置成员变量,默认move_to_model_device设置为True
88+
- **20230907**: 增加from_pretrained和save_pretrained方法,增加log_warn_once方法,compile()中可设置成员变量,默认move_to_model_device设置为True, 增加JsonConfig
8989
- **20230901**: compile()可不传参,interval不一致报warning, 去除部分self.vars, 调整move_to_model_device逻辑,DDP每个epoch重新设置随机数,save_weights()和load_weights()可以按照`pretrained`格式
9090
- **20230821**: 代码结构调整,增加trainer.py文件,方便下游集成
9191
- **20230812**: 修复DeepSpeedTrainer,修复DDP

torch4keras/snippets.py

+8
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,14 @@ def allowDotting(self, state=True):
397397
self.__dict__ = self
398398
else:
399399
self.__dict__ = dict()
400+
KwargsConfig = DottableDict
401+
402+
403+
class JsonConfig:
404+
'''读取配置文件并返回可.操作符的字典'''
405+
def __new__(self, json_path, encoding='utf-8'):
406+
import json
407+
return DottableDict(json.load(open(json_path, "r", encoding=encoding)))
400408

401409

402410
def auto_set_cuda_devices(best_num: Optional[int] = None) -> str:

0 commit comments

Comments
 (0)