2017-11-19 4 views
0
Model description: 
cnn1=Sequential() 
cnn1.add(Conv2D(128,(2,300), activation = 'relu',input_shape = (maxLenofSent,300,1))) 

cnn1.add(MaxPooling2D(1,3)) 

cnn1.add(Flatten()) 
cnn1.add(Dense(100, activation = 'relu')) 

cnn2=Sequential() 
cnn2.add(Conv2D(128,(2,300), activation = 'relu',input_shape = (maxLenofSent,300,1))) 
cnn2.add(MaxPooling2D(1,3)) 
cnn2.add(Flatten()) 
cnn2.add(Dense(100, activation = 'relu')) 


classifier2=Sequential() 
classifier2.add(Merge([cnn1,cnn2], mode='concat')) 
classifier2.add(Dense(70,activation='sigmoid')) 
classifier2.add(Dropout(0.2)) 
classifier2.add(Dense(2,activation='tanh')) 
sgd = SGD(lr = 0.01, momentum = 0.9, decay=1e-2, nesterov = False) 
classifier2.compile(loss = 'categorical_crossentropy', optimizer = sgd, metrics = ['accuracy']) 

전체 모델을 저장하여 나중에 테스트 할 수 있도록 저장하는 방법. 두 개의 cnn 출력이 ann으로 이동하여 분류됩니다. 당신은 모든 시대에서 모델과 가중치를 저장 콜백 검색을 시도 할 경우keras python에서 모델을 저장하는 방법은 무엇입니까?

model_json = model.to_json() 
with open("<path.json>", "w") as json_file: 
    json_file.write(model_json) 
model.save_weights("<path.hdf5>", overwrite=True) 

: 모델을 저장하는 방법은 다음과

+0

을 저장 classifier2.fit()

https://keras.io/models/sequential/#fit

사용하여 훈련을해야합니까? 빠른 검색을 통해 https://keras.io/getting-started/faq/#how-can-i-save-a-keras-model이 이미 문제에 대한 답을 얻었습니다. –

+3

[Keras : 모델을 저장하고 교육을 계속하는 방법]의 가능한 복제본 (https://stackoverflow.com/questions/45393429/keras-how-to-save-model-and-continue-training) –

답변

0

모델을 저장하기 전에, 당신은 모델의 사용이 시도 무엇 classifier2.save('filename.hdf5')

관련 문제