반응형
model_name = 'some_model'
#폴더 생성
try:
    if not os.path.exists(os.path.join('data','checkpoints',model_name)):
        os.makedirs(os.path.join('data','checkpoints',model_name))
    if not os.path.exists(os.path.join('data','tensorboard',model_name)):
        os.makedirs(os.path.join('data','tensorboard',model_name))
    if not os.path.exists(os.path.join('data','logs',model_name)):
        os.makedirs(os.path.join('data','logs',model_name))
except OSError:
    print('Error: create dir')
    
# 체크포인터
checkpointer = ModelCheckpoint(
        filepath=os.path.join('data', 'checkpoints',model_name, 'inception.{epoch:03d}-{val_loss:.2f}.hdf5'),
        verbose=1,
        save_best_only=True)

#얼리스토퍼
early_stopper = EarlyStopping(patience=1000)

#텐서보드
tensorboard = TensorBoard(log_dir=os.path.join('data', 'tensorboard',model_name))

#리듀스 러닝레이트
re_lr = ReduceLROnPlateau(monitor='val_loss', factor=0.9, patience=20, verbose=1)
반응형

+ Recent posts