Sequential模型
导入functional模型。
导入Keras序列模型入门
from keras.models import Sequential
from keras.layers import Dense
model = Sequential()
model.add(Dense(units=64, activation='relu', input_dim=100))
model.add(Dense(units=10, activation='softmax'))
model.compile(loss='categorical_crossentropy',optimizer='sgd', metrics=['accuracy'])model.save('full_model.h5') # save everything in HDF5 format
model_json = model.to_json() # save just the config. replace with "to_yaml" for YAML serialization
with open("model_config.json", "w") as f:
f.write(model_json)
model.save_weights('model_weights.h5') # save just the weights.载加你的Keras模型
Last updated
Was this helpful?