[keras] model save & load 하는 방법

모델 저장하기 Weights + Model Architecture 각각 저장하는 방법 # Save the weights model.save_weights( "mnist_weights.h5" ) # Save the model architecture as json with open ( "mnist_architecture.json" , "w" ) as fp: fp.write(model.to_json( indent = " \t " )) model.save_weights(filepath) Notes 모델의 가중치 값을 HDF5 파일 형식으로 저장합니다. model.to_json() Notes model architecture만 json 형태로 저장합니다. 가중치는 저장하지 않습니다. json에서 indent="\t"가 궁금하신 분은 https://daewoonginfo.blogspot.com/2019/04/python-json.html 참조해주시기 바랍니다. Weights + Model Architecture + Optimizer State 한번에 저장하는 방법 # Creates a single HDF5 file model.save( "mnist_model.h5" ) model.save(filepath) Notes 모델의 Weights, Architecture, Optimizer State를 모두 포함하는 HDF5 파일 형식으로 저장합니다. 모델 불러오기 Weights + Model Architecture 각각 불러오는 방법 from keras.models import model_from_json # Reconfigure model in json file with open ( "mnist_architecture...