参考:

https://blog.csdn.net/heiheiya/article/details/81111932

https://blog.csdn.net/c20081052/article/details/80745969

打开 model.py,找到load_weights  函数,大概在2842行,修改位置如下:

--------------------------------------------------------------------

def load_weights(self, filepath, by_name=False, exclude=None):
    """Modified version of the correspoding Keras function with
    the addition of multi-GPU support and the ability to exclude
    some layers from loading.
    exlude: list of layer names to excluce
    """
    import h5py

    #修改第一处
    #from keras.engine import topology
    from keras.engine import saving

    if exclude:
      by_name = True

    if h5py is None:
      raise ImportError('`load_weights` requires h5py.')
    f = h5py.File(filepath, mode='r')
    if 'layer_names' not in f.attrs and 'model_weights' in f:
      f = f['model_weights']

    # In multi-GPU training, we wrap the model. Get layers
    # of the inner model because they have the weights.
    keras_model = self.keras_model
    layers = keras_model.inner_model.layers if hasattr(keras_model, "inner_model")\
      else keras_model.layers

    # Exclude some layers
    if exclude:
      layers = filter(lambda l: l.name not in exclude, layers)

    if by_name:

      #修改第二处
      #topology.load_weights_from_hdf5_group_by_name(f, layers)
      saving.load_weights_from_hdf5_group_by_name(f, layers)
    else:

      #修改第三处
      #topology.load_weights_from_hdf5_group(f, layers)
      saving.load_weights_from_hdf5_group(f, layers)
    if hasattr(f, 'close'):
      f.close()

    # Update the log directory
    self.set_log_dir(filepath)

--------------------------------------------------------------------

修改成功以后保存,并重启,然后运行代码

module 'keras.engine.topology' has no attribute 'load_weights_from_hdf5_group_by_name'的更多相关文章

  1. AttributeError:module 'keras.engine.topology' has no attribute 'load_weights_from_hdf5_group_by_name

    在jupyter notebooks上运行tensorflow-keras的Mask R-CNN时遇到如下错误: 参考博客中写了两种解决方案: 解决方案一:报错是由于keras版本不对造成的.load ...

  2. Python 报错 AttributeError: module 'django.db.models' has no attribute 'SubfieldBase'

    AttributeError: module 'django.db.models' has no attribute 'SubfieldBase' http://www.guanggua.com/qu ...

  3. pyinstaller打包:AttributeError: module ‘win32ctypes.pywin32.win32api’ has no attribute ‘error’

    pyinstaller打包:AttributeError: module 'win32ctypes.pywin32.win32api' has no attribute 'error' 是因为pyin ...

  4. Python Keras module 'keras.backend' has no attribute 'image_data_format'

    问题: 当使用Keras运行示例程序mnist_cnn时,出现如下错误: 'keras.backend' has no attribute 'image_data_format' 程序路径https: ...

  5. module 'tensorflow.contrib.rnn' has no attribute 'core_rnn_cell'

    #tf.contrib.rnn.core_rnn_cell.BasicLSTMCell(lstm_size) tf.contrib.rnn.BasicLSTMCell(lstm_size)

  6. AttributeError: module 'Crypto.PublicKey.RSA' has no attribute 'import_key'

    I solved this problem by pip install pycryptodome

  7. Keras:基于Theano和TensorFlow的深度学习库

    catalogue . 引言 . 一些基本概念 . Sequential模型 . 泛型模型 . 常用层 . 卷积层 . 池化层 . 递归层Recurrent . 嵌入层 Embedding 1. 引言 ...

  8. 用Keras搞一个阅读理解机器人

    catalogue . 训练集 . 数据预处理 . 神经网络模型设计(对话集 <-> 问题集) . 神经网络模型设计(问题集 <-> 回答集) . RNN神经网络 . 训练 . ...

  9. Django整合Keras报错:ValueError: Tensor Tensor("Placeholder:0", shape=(3, 3, 1, 32), dtype=float32) is not an element of this graph.解决方法

    本人在写Django RESful API时,碰到一个难题,老出现,整合Keras,报如下错误:很纠结,探索找资料近一个星期,皇天不负有心人,解决了 Internal Server Error: /p ...

随机推荐

  1. Python之MySQLdb

    MySQLdb是用于Python链接Mysql数据库的接口,它实现了Python数据库API规范V2.0,基于MySql C API上建立的. 1. MySQLdb安装 (1)安装Mysql,参考上篇 ...

  2. webstorm-前端javascript开发神器中文教程和技巧分享(转)

    webstorm是一款前端javascript开发编辑的神器,此文介绍webstorm的中文教程和技巧分享. webstorm8.0.3中文汉化版下载:百度网盘下载:http://pan.baidu. ...

  3. 企业建站系统MiinCMP1.0.5 版公布!

    2014-5-4,在青年节,Juuluu公布了其企业建站系统的新版1.0.5,经过两周多的奋战,Juuluu团队为MiinCMP新浪云版的移植工作做了大量工作.1.0.5已可完美执行于国内免费的jav ...

  4. Mouse without Borders 跨屏鼠标

    Mouse without Borders 跨屏鼠标 软件方式 当你有几台电脑同时工作时,不停的换鼠标和键盘是非常不方便的. 如果用的 Mouse without Borders 就不一样了,可以在多 ...

  5. Aix之 xmanager 2.0连接AIX服务器

    xmanager连接AIX服务器可以分为两种情况:1.连接IBM服务器,使用远程桌面功能进行系统维护.要求这台服务器已经安装了图形桌面,如CDE等,并启动到图形界面.在xmanager中的Xbrows ...

  6. IDC单IP绑定多域名(包括端口)

    本文件已上传到文件列表中. ServerName 222.186.36.116:80 DocumentRoot "/home" <Directory "/home& ...

  7. spring mvc从@ResponseBody取到json发现中文乱码

    问题背景:如题. 问题定位:代码跟踪,从源头入手,一步一步跟进,直到设置中文编码的地方. 问题代码: /** * 获取单个测试桩接口内容 * * @author wulinfeng * @param ...

  8. java代码Calendar类

    总结:时间类Calendar.类代表当前时 Calendar c=Calendar.getInstance();,,Calendar是抽象类.Calendar的构造方法是私有的,API提供了getIn ...

  9. 第十五届浙江省赛 F Now Loading!!!

    Now Loading!!! Time Limit: 1 Second      Memory Limit: 131072 KB DreamGrid has  integers . DreamGrid ...

  10. php 语句块耗时性能测试

    $t= microtime(true);        .............................        echo microtime(true) - $t; 1查看从入口文件 ...