keras model:
2种类型: the Sequential model 和 the Model class ,二者有共同的方法。
1 model.summary():计算出model的摘要表示
2 model.get_config(): 一个保存着该模型配置的字典,可以使用字典来重新加载模型,如下代码所示:
config = model.get_config()
model = Model.from_config(config)
# or, for Sequential:
model = Sequential.from_config(config)
3model.get_weights()
:返回所有的tensor的权重,以numpy数字
4model.set_weights(weights): 设置这个模型的权重值,但是weigths的shape应该和model.get_weights()的shape一样
5model.to_json():返回模型的json表示方式,但是只有结构,没有权重也可以通过这个表示方式重建出一个模型的结构,但是权重需要另外设置
from models import model_from_json
json_string = model.to_json()
model = model_from_json(json_string)
6model.to_yaml():返回模型的yaml表示方式,也是只有结构无权重,也可以通过这个表示方式重建出一个模型的结构,但是权重需要另外设置
from models import model_from_yaml
yaml_string = model.to_yaml()
model = model_from_yaml(yaml_string)