mirror of
https://gitee.com/fastnlp/fastNLP.git
synced 2024-11-29 18:59:01 +08:00
修正 _TruncatedDataLoader 2
This commit is contained in:
parent
e86645380a
commit
0033219fe1
@ -132,9 +132,16 @@ class _TruncatedDataLoader:
|
||||
def __getattr__(self, item):
|
||||
return getattr(self.dataloader, item)
|
||||
|
||||
# def __setattr__(self, key, value):
|
||||
# # 添加该函数使得在进行实验性训练或者评测时,用户对于 trainer.dataloader 的感觉和正常训练完全一样;
|
||||
# setattr(self.dataloader, key, value)
|
||||
def __setattr__(self, key, value):
|
||||
# 添加该函数使得在进行实验性训练或者评测时,用户对于 trainer.dataloader 的感觉和正常训练完全一样;
|
||||
# 注意这里不能直接 ``setattr(self.dataloader, key, value)``,会导致死循环;
|
||||
if "dataloader" in self.__dict__:
|
||||
if hasattr(self.dataloader, key):
|
||||
setattr(self.dataloader, key, value)
|
||||
else:
|
||||
self.__dict__[key] = value
|
||||
else:
|
||||
self.__dict__[key] = value
|
||||
|
||||
|
||||
def check_evaluate_every(evaluate_every):
|
||||
|
Loading…
Reference in New Issue
Block a user