keras_conversion.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:deeplift 作者: kundajelab 项目源码 文件源码
def load_keras_model(weights, yaml=None, json=None,
                     normalise_conv_for_one_hot_encoded_input=False,
                     axis_of_normalisation=None,
                     name_of_conv_layer_to_normalise=None): 
    if (normalise_conv_for_one_hot_encoded_input):
        assert axis_of_normalisation is not None,\
         "specify axis of normalisation for normalising one-hot encoded input"
    assert yaml is not None or json is not None,\
     "either yaml or json must be specified"
    assert yaml is None or json is None,\
     "only one of yaml or json must be specified"
    if (yaml is not None):
        from keras.models import model_from_yaml 
        model = model_from_yaml(open(yaml).read()) 
    else:
        from keras.models import model_from_json 
        model = model_from_json(open(json).read()) 
    model.load_weights(weights) 
    if (normalise_conv_for_one_hot_encoded_input):
        mean_normalise_first_conv_layer_weights(
         model,
         axis_of_normalisation=axis_of_normalisation,
         name_of_conv_layer_to_normalise=name_of_conv_layer_to_normalise)
    return model
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号