Skip to content

오그멘테이션 하이퍼파라미터 수정#45

Open
Ronalmoo wants to merge 41 commits intoDeepBaksuVision:developfrom
Ronalmoo:master
Open

오그멘테이션 하이퍼파라미터 수정#45
Ronalmoo wants to merge 41 commits intoDeepBaksuVision:developfrom
Ronalmoo:master

Conversation

@Ronalmoo
Copy link
Contributor

dictionary로 하이퍼파라미터 값을 넘겨주는 형태로 수정했습니다

@chromatices
Copy link
Contributor

고생하셨습니다!

], p=0.2),
OneOf([
MotionBlur(p=config["MotionBlur"]),
MedianBlur(blur_limit=config["blur_limit"], p=0.1),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p값은 별도로 제어 안해도 될까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분을 고민해봤는데 나중에 라이트닝에서 사용하는 파서로 아래 방식처럼 리스트로 옵션(확률값)을 주는게 어떨까요?
parser.opt_list('--drop_prob', default=0.2, options=[0.2, 0.5], type=float, tunable=False)
사실 저 p를 어느정도까지 세밀하게 해야하는지를 모르겠습니다ㅠ

Copy link
Contributor

@ssaru ssaru Oct 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네네 list로 줘도 괜찮을 것 같습니다.

ShiftScaleRotate로 예를 들어보겠습니다.
configuration 파일은 json으로 구성한다고 가정합시다.
(json으로 구성해서 python에서 파싱하면 dict로 파싱되니, config 데이터 타입은 dict로 가정합니다.)

ShiftScaleRotate API를 확인해보니 아래와 같이 구성되어있음을 확인할 수 있습니다.
ShiftScaleRotate(shift_limit=0.0625, scale_limit=0.1, rotate_limit=45, interpolation=1, border_mode=4, value=None, mask_value=None, always_apply=False, p=0.5)

그러면 config은 다음과 같이 작성할 수 있습니다.
dict로 파싱하면 아래와 같습니다.

{
    ...
    "augmentation" : {
        "shift_scale_rotate": {
            "shift_limit": 0.0625,
            "scale_limit": 0.1, 
            "rotate_limit": 45,
            "interpolation": 1, 
            "border_mode": 4
            "value": None,
            "mask_value": None, 
            "always_apply": false, 
            "p": 0.5
        }
    }
    ...
}

config 파싱한 결과는 실제 사용할 때, 아래와 같이 사용할 수 있습니다.

aug(config: dict) -> Compose:
    return Compose([
        ...
        ShiftScaleRotate(**config["augmentation"]["shift_scale_rotate"])
        ...
    ])

이렇게 사용하게되면 모든 제어를 config.json 설정을 통해서 할 수 있게됩니다.

(제 예시는 슈도코드입니다. 실제 사용하실 때는 테스트해보시면서 작동하는 것을 확인해보면서 작성하셔야합니다.)

추가적으로 라이트닝이 Argparser와 유사한 메카니즘의 파서를 사용한다면 저는 하이드라를 사용하는게 더 좋을 것 같습니다.
Argparser은 하이드라와 비교했을 때, 별도의 저장 로직이 코드상에 없다면 상대적으로 히스토리 추적이 어렵고 오타 확률이 높고 default값을 제외한 커스텀 값은 매번 타이핑 해야해서 불편합니다.

라이트닝에 탑재되어있는 파서는 저장 로직이 심어져있을 것으로 추측되지만, Argparser의 메카니즘을 따라가면 저는 하이드라를 사용하는 것이 더 좋다는 생각입니다.

Comment on lines 12 to 24
def aug(config:{}, p=0.5):
return Compose([
HorizontalFlip(True),
RandomRotate90(True),
Flip(),
Transpose(),
OneOf([
IAAAdditiveGaussianNoise(),
GaussNoise(),
], p=0.2),
OneOf([
MotionBlur(p=config["MotionBlur"]),
MedianBlur(blur_limit=config["blur_limit"], p=0.1),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config값의 default값이 {}로 되어있는데, 빈 딕셔너리가 들어오면 함수가 어떻게 동작하나요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

대형 삑사리가..

@pl.data_loader
def train_dataloader(self):
return DataLoader(MNIST(os.getcwd(), train=True, download=True, transform=transforms.ToTensor()), batch_size=128)
return DataLoader(MNIST(os.getcwd(), train=True, download=True, transform=aug()), batch_size=128)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기서 aug()로 파라미터가 존재하는데 위에서 default valie가 {}로 빈 dict입니다. 실행이 되나요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

모델에서는 테스트를 못했더니 미스가 났군요ㅜ 수정하였습니다.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

항상 짜신 모듈에 대해서는 철저하게 테스트 하셔야합니다.

Copy link
Contributor

@ssaru ssaru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 완료하였습니다!
코멘트 남겼으니 확인 부탁드려요~

Copy link
Contributor

@ssaru ssaru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2차 리뷰 완료하였습니다.
확인 부탁드립니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants