기존 모델 및 가중치 저장 및 불러오기

model load and save

모델 저장, 로드 및 Weight 저장, 로드

  • 불러오는 모델과 가중치는 서로 구조가 맞지 않으면 로드가 되지 않는다.
In [ ]:
import numpy
import pandas as pd
from keras.callbacks import ModelCheckpoint
from keras.models import model_from_json

모델 저장

  • 모델의 신경망 구조
In [ ]:
model_json = model.to_json()
with open("model.json", "w") as json_file : 
    json_file.write(model_json)

모델 가중치 저장

  • 신경망의 각 학습된 가중치
  • 저장 전에는 컴퓨터 메모리에 저장
In [ ]:
model.save_weights("model.h5")

모델 불러오기

In [ ]:
json_file = open("model.json", "r")
loaded_model_json = json_file.read() json_file.close()
loaded_model = model_from_json(loaded_model_json)

모델 가중치 불러오기

In [ ]:
loaded_model.load_weights("model.h5")

모델 활용

In [ ]:
loaded_model.compile(loss="binary_crossentropy", optimizer="adam", metrics=['accuracy'])
score = loaded_model.evaluate(X,Y)

13 thoughts on “기존 모델 및 가중치 저장 및 불러오기

  1. Hi, I think your blog could be having internet browser compatibility
    problems. When I look at your website in Safari, it looks fine but when opening in Internet Explorer, it has some
    overlapping issues. I simply wanted to provide you with a quick heads up!
    Besides that, great site!

    My blog post :: out g

  2. I like the valuable information you provide in your articles.
    I’ll bookmark your blog and check again here regularly.
    I’m quite sure I’ll learn a lot of new stuff right here! Best of luck for the next!

    Here is my webpage; who g

  3. Can I simply just say what a relief to discover somebody who actually knows what
    they’re discussing on the internet. You definitely realize g how to bring an issue
    to light and make it important. More and more people ought to
    read this and understand this side of the story.
    It’s surprising you’re not more popular because you surely possess the gift.

  4. I loved as much as you will receive carried out right here.
    The sketch is tasteful, your authored subject matter stylish.
    nonetheless, you command get got an nervousness over that you wish be
    delivering the following. unwell unquestionably come further formerly again as exactly the same nearly a lot often inside case you
    shield this hike.

    Look at my web site :: g rsacwgxy

  5. My programmer is trying to persuade me to move to .net from PHP.

    I have always disliked the idea because of the expenses.
    But he’s tryiong none the less. I’ve been using Movable-type on various websites for about a year and
    am concerned about switching to another platform. I have heard excellent things about blogengine.net.
    Is there a way I can import all my wordpress content into it?
    Any help would be greatly appreciated!

    Visit my web-site cbd oil (http://eng.prokatavtomobil.by/)

  6. I got this web page from my friend who told me concerning this web page and now this
    time I am visiting this web page and reading very informative articles here.

    My site … cbd oil (tinyurl.com)

  7. Can You Take Amoxicillin With Aspirin [url=https://agenericcialise.com/]buy cialis canada[/url] Knee Infection Keflex Cialis Buy Abilify

  8. Statistics And Probability With Applications For Engineers
    And Scientists Using Minitab R And Jmp The Garden Of Last Days Emilia Clarke

    Here is my web site :: best books

댓글 남기기