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 ...
随机推荐
- 剑指Offer面试题:7.斐波那契数列
一 题目:斐波那契数列 题目:写一个函数,输入n,求斐波那契(Fibonacci)数列的第n项.斐波那契数列的定义如下: 二 效率很低的解法 很多C/C++/C#/Java语言教科书在讲述递归函数的时 ...
- fft蝶形算法的特点
- openfaas 私有镜像配置
备注: 此项目是使用nodejs 生成唯一id 的\ 预备环境 docker harbor faas-cli openfaas k8s 1. 项目初始化 faas-cli new node --la ...
- 有返回值的多线程demo
package com.jimmy.demo.util; import java.util.HashMap;import java.util.concurrent.*;import java.util ...
- Linux IO 监控与深入分析
https://jaminzhang.github.io/os/Linux-IO-Monitoring-and-Deep-Analysis/ Linux IO 监控与深入分析 引言 接昨天电话面试,面 ...
- Linux 应用层open调用驱动层open过程
内核版本:3.0.8 open.close.read.write.ioctl等等都是类似. ====================================================== ...
- javaMail邮件接收解析内容及附件 及删除邮件
参考自: http://blog.csdn.net/xyang81/article/details/7675160 package com.szy.project.utils; import jav ...
- RecyclerView(滚动控件)的用法
1.首先在build.gradle中添加依赖库 compile 'com.android.support:recyclerview-v7:24.2.1' 2.修改activity_main.xml & ...
- 【转】Jmeter常见问题
说明:这些问答是从网上转载的,自己修改了其中的一些内容,如果大家兴趣,可以将大家在使用Jmeter的时候碰到的问题写下来,我们一起补充到这个问答里面,共同努力完善jmeter的资料. 1. JMet ...
- logging模块讲解
logging模块 很多程序都有记录日志的需求,并且日志中包含的信息即有正常的程序访问日志,还可能有错误.警告等信息输出,python的logging模块提供了标准的日志接口,你可以通过它存储各种格式 ...