module 'keras.engine.topology' has no attribute 'load_weights_from_hdf5_group_by_name'
参考:
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'的更多相关文章
- AttributeError:module 'keras.engine.topology' has no attribute 'load_weights_from_hdf5_group_by_name
在jupyter notebooks上运行tensorflow-keras的Mask R-CNN时遇到如下错误: 参考博客中写了两种解决方案: 解决方案一:报错是由于keras版本不对造成的.load ...
- Python 报错 AttributeError: module 'django.db.models' has no attribute 'SubfieldBase'
AttributeError: module 'django.db.models' has no attribute 'SubfieldBase' http://www.guanggua.com/qu ...
- pyinstaller打包:AttributeError: module ‘win32ctypes.pywin32.win32api’ has no attribute ‘error’
pyinstaller打包:AttributeError: module 'win32ctypes.pywin32.win32api' has no attribute 'error' 是因为pyin ...
- Python Keras module 'keras.backend' has no attribute 'image_data_format'
问题: 当使用Keras运行示例程序mnist_cnn时,出现如下错误: 'keras.backend' has no attribute 'image_data_format' 程序路径https: ...
- 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)
- AttributeError: module 'Crypto.PublicKey.RSA' has no attribute 'import_key'
I solved this problem by pip install pycryptodome
- Keras:基于Theano和TensorFlow的深度学习库
catalogue . 引言 . 一些基本概念 . Sequential模型 . 泛型模型 . 常用层 . 卷积层 . 池化层 . 递归层Recurrent . 嵌入层 Embedding 1. 引言 ...
- 用Keras搞一个阅读理解机器人
catalogue . 训练集 . 数据预处理 . 神经网络模型设计(对话集 <-> 问题集) . 神经网络模型设计(问题集 <-> 回答集) . RNN神经网络 . 训练 . ...
- 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 ...
随机推荐
- vim编辑器安装命令使用命令和设置的使用总结
vim编辑器的安装 vi(vim)是上Linux非常常用的编辑器,很多Linux发行版都默认安装了vi(vim).vi(vim)命令繁多但是如果使用灵活之后将会大大提高效率.本文讲解主要是在Cento ...
- ArcGIS Runtime SDK for WPF之测量距离和面积
bu不多说,上代码 using System.Windows; using ESRI.ArcGIS.Client; using ESRI.ArcGIS.Client.Tasks; using ESRI ...
- python3 tesserocr 安装 来解决部分爬虫遇到的字符识别问题
1. OCR OCR,即Optical Character Recognition,光学字符识别,是指通过扫描字符,然后通过其形状将其翻译成电子文本的过程.对于图形验证码来说,它们都是一些不规则的字符 ...
- cnn(卷积神经网络)比较系统的讲解
本文整理了网上几位大牛的博客,详细地讲解了CNN的基础结构与核心思想,欢迎交流. [1]Deep learning简介 [2]Deep Learning训练过程 [3]Deep Learning模型之 ...
- 剑指offer-第六章面试中的各项能力(翻转单词的顺序VS左旋转字符串)
//题目1:翻转单词顺序例如“Hello world!”翻转后为world! Hello. //思路:首先翻转整个字符串,然后再分别翻转每个单词. //题目2:左旋转字符串,是将字符串的前面几个(n) ...
- 2.1 一个简单的Web工程例子
一个简单的Web工程例子 开发环境: Eclipse: Neon Release (4.6.0) JDK:1.8.0_92 Tomcat:8.5.9 Maven:3.3.9 1. 在Eclipse中创 ...
- Maven无法上传到到私服
在pom.xml中插入如下代码: <distributionManagement> <repository> <id>nexus</id> <ur ...
- ④SpringBoot之thymeleaf使用
本文介绍SpringBoot使用的模板技术thymeleaf以及通过webJar进行前端资源的引入以及使用thymeleaf介绍简单说, Thymeleaf 是一个跟 Velocity.FreeMar ...
- spring mvc处理http请求报错:java.lang.IllegalStateException: getInputStream() has already been called for this request
发送post请求到controller处理失败,报错日志如下: java.lang.IllegalStateException: getInputStream() has already been c ...
- 使用XV-11激光雷达做hector_slam
大家在学习ROS中不可避免需要使用激光雷达,高精地图.实时定位以及障碍物检测等多项技术,而这些技术都离不开光学雷达的支持,但是呢雷达这真是太贵了,大部分人是负担不起(实验室.研究所土豪可以略过),但是 ...