Directory 만들기 | Directory 내 file 존재 유무 확인
# 디렉토리 없을 경우 생성
import os
# --------------------------------------------------------------------------------
DIR_WEIGHTS = './kereas_conv_wts/'
if not os.path.exists(DIR_WEIGHTS):
os.mkdir(DIR_WEIGHTS)
# --------------------------------------------------------------------------------
# 파일이 제대로 저장 됐는지 확인
# save wts
# --------------------------------------------------------------------------------
filename_wts = DIR_WEIGHTS + "keras_conv_seq_model_{0}.wts".format(datetime.now().strftime("%Y.%m.%d.%H:%M:%S"))
# --------------------------------------------------------------------------------
model.save_weights(filename_wts, overwrite=False)
# check save wts
wts_list = os.listdir(DIR_WEIGHTS)
if filename_wts.split('/')[-1] in wts_list:
print '{0} is saved.'.format(filename_wts)
else:
print '{0} is not saved. check your cource code'.format(filename_wts)
# temp
'Python > Examples' 카테고리의 다른 글
Python | Examples | String to datetime (0) | 2016.03.02 |
---|---|
Python | Example | convert (encoding/decoding) URL Unicode to UTF-8 characters (0) | 2016.02.26 |
Python | Examples | xlwt, xlrd, xlutils 사용하기 | python - excel 파일 다루기 (0) | 2016.01.12 |
Python | Study | 파일 자동으로 filepath 만 주면 directory 까지 만들어서 저장하는 방법 (0) | 2016.01.07 |
Python | 특정 폴더의 파일 리스트 가져오기 (0) | 2015.12.08 |