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 ...
随机推荐
- touch-action属性
CSS属性 touch-action 用于指定某个给定的区域是否允许用户操作,以及如何响应用户操作(比如浏览器自带的划动.缩放等). /* Keyword values */touch-action: ...
- (四)java基本语法
关键字 被java赋予了特殊意义的单词: class,new,private,protected,public,static,final,abstract,interface,this,super,I ...
- 核PCA投影平面公式推导
样本方差推导 样本方差公式\[S = \frac{1}{n-1}\sum_{i=1}^n(x_i-\mu_i)^2\] 扩展开来得到\[S = \frac{1}{n-1}[(X-\frac{1}{n} ...
- Java中取整和四舍五入
import java.math.BigDecimal; import java.text.DecimalFormat; public class TestGetInt{ public stati ...
- 剑指offer-第五章优化时间和空间效率(最小的k个数)
题目:输入n个数,输出最小的k个数. 时间复杂度为O(n) 思路1:我们想的到的最直接的思路就是对这个N个数进行排序,然后就可以找到最小的k个了,同样可以用快排partition.但是只要找到前K个最 ...
- TOP K问题的若干实现
问题描述:在长度为n的序列中,找出其最大的K个数 1.冒泡排序 每冒泡一次,可将最大的数放到序列尾部,冒泡K次即可. 时间复杂度:O(K*n) 空间复杂度:O(1) 2.扫描数组,将最大的N个数存在缓 ...
- 1020. Tree Traversals (25) ——树的遍历
//题目 通过后续遍历 中序遍历 得出一棵树 ,然后按树的层次遍历打印 PS:以前对于这种用指针的题目是比较头痛的,现在做了一些链表操作后,感觉也不难 先通过后续中序建一棵树,然后通过BFS遍历这棵树 ...
- android中asynctask的使用实例
参考此blog写的非常的好http://www.cnblogs.com/devinzhang/archive/2012/02/13/2350070.html MainActivity.java imp ...
- FPGA各大厂商,不可不知
引言: FPGA市场前景诱人,但是门槛之高在芯片行业里无出其右.全球有60多家公司先后斥资数十亿美元,前赴后继地尝试登顶FPGA高地,其中不乏英特尔.IBM.德州仪器.摩托罗拉.飞利浦.东芝.三星这样 ...
- (转)Socket开发时,Available为0,实际还有数据的问题
本文转载自:http://blog.csdn.net/youbl/article/details/11067369 这段时间处理Socket通讯,比如文件传输,通常代码如下:string filena ...