Train
enhancement.UnpairedTrainer
Enhancement 모델을 학습시키기 위한 UnpairedTrainer class 입니다.
Usage
demo/train.py 참고
build(config, data)
classmethod
UnpairedTrainer class의 instance를 생성합니다.
Parameters:
Returns:
| Name | Type | Description |
|---|---|---|
UnpairedTrainer |
UnpairedTrainer
|
build가 완료된 enhancement.UnpairedTrainer class의 instance를 반환합니다. |
to_device(device)
Trainer의 device를 변경합니다. (cpu/gpu)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device |
Union[device, str, int]
|
변경하고자 하는 device 입니다.
|
required |
Returns: None: None
train_one_step()
학습을 1스텝 수행하고, 결과를 반환합니다.
Returns:
validation_enabled()
Trainer가 validation이 가능한지 bool로 반환합니다. 현재 IEN은 validation을 지원하지 않습니다.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
Trainer가 validation이 가능하면 True를, 불가능하다면 False를 반환합니다. |
post_train_process(save_root)
PairedTrainer의 학습에 사용할 데이터를 생성하고, PairedTrainer의 build에 필요한 data config를 리턴합니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
save_root |
str
|
학습에 사용할 데이터를 저장할 root path 입니다. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Dict |
Dict
|
Usage
post_train_process로 PairedTrainer의 학습에 사용할 데이터를 생성하여 build 하는 예시입니다. 상세 내용은 demo/train.py를 참고해주세요.
save_checkpoint(checkpoint_path, metadata=None, password=None)
현재 Trainer의 상태를 암호화하여 저장합니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
checkpoint_path |
str
|
checkpoint를 저장할 path 입니다. |
required |
metadata |
Optional[Dict]
|
checkpoint에 저장할 추가 metadata. Defaults to None. |
None
|
password |
Optional[str]
|
checkpoint 파일에서 중요한 정보를 암호화 하는데 사용되는 password 입니다. None이면 암호화하지 않습니다. Defaults to None. |
None
|
Returns: None: None
load_checkpoint(checkpoint_path, password=None)
저장한 checkpoint로부터 Trainer의 상태를 불러오고, metadata를 반환합니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
checkpoint_path |
str
|
load할 checkpoint가 저장 되어 있는 path 입니다. |
required |
password |
Optional[str]
|
checkpoint 파일에서 중요한 정보를 복호화 하는데 사용되는 password 입니다. None이면 복호화하지 않습니다. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Dict |
Dict
|
save_checkpoint에서 저장했던 metadata 입니다. |
enhancement.PairedTrainer
Enhancement 모델을 학습시키기 위한 PairedTrainer class 입니다.
Usage
demo/train.py 참고
build(config, data)
classmethod
PairedTrainer class의 instance를 생성합니다.
Parameters:
Returns:
| Name | Type | Description |
|---|---|---|
PairedTrainer |
PairedTrainer
|
build가 완료된 enhancement.PairedTrainer class의 instance를 반환합니다. |
to_device(device)
Trainer의 device를 변경합니다. (cpu/gpu)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device |
Union[device, str, int]
|
변경하고자 하는 device 입니다.
|
required |
Returns: None: None
train_one_step()
학습을 1스텝 수행하고, 결과를 반환합니다.
Returns:
validation_enabled()
Trainer가 validation이 가능한지 bool로 반환합니다. 현재 IEN은 validation을 지원하지 않습니다.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
Trainer가 validation이 가능하면 True를, 불가능하다면 False를 반환합니다. |
post_train_process()
save_checkpoint(checkpoint_path, metadata=None, password=None)
현재 Trainer의 상태를 암호화하여 저장합니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
checkpoint_path |
str
|
checkpoint를 저장할 path 입니다. |
required |
metadata |
Optional[Dict]
|
checkpoint에 저장할 추가 metadata. Defaults to None. |
None
|
password |
Optional[str]
|
checkpoint 파일에서 중요한 정보를 암호화 하는데 사용되는 password 입니다. None이면 암호화하지 않습니다. Defaults to None. |
None
|
Returns: None: None
load_checkpoint(checkpoint_path, password=None)
저장한 checkpoint로부터 Trainer의 상태를 불러오고, metadata를 반환합니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
checkpoint_path |
str
|
load할 checkpoint가 저장 되어 있는 path 입니다. |
required |
password |
Optional[str]
|
checkpoint 파일에서 중요한 정보를 복호화 하는데 사용되는 password 입니다. None이면 복호화하지 않습니다. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Dict |
Dict
|
save_checkpoint에서 저장했던 metadata 입니다. |