import pickle
# Create model and train ...
#save the weights for each layer in your model
network_config = {
'layer1': layer1.get_weights(),
'layer2': layer2.get_weights(),
'layer3': layer3.get_weights()
}
with open('network_config.pickle', 'wb') as file:
pickle.dump(network_config, file)
然后,只能为仍在使用的层加载权重。你知道吗
with open('network_config.pickle', 'rb') as file:
network_config = pickle.load(file)
#build new model that may be missing some layers
layer1.set_weights(network_config['layer1'])
layer3.set_weights(network_config['layer3'])
不用将整个模型保存到一个.h5文件中,你可以用你自己的格式分别保存每个层的权重。e、 g
然后,只能为仍在使用的层加载权重。你知道吗
使用所需的超参数创建模型,并使用
load_weight()
将参数加载到模型中。你知道吗相关问题 更多 >
编程相关推荐