分享好友 人工智能首页 频道列表

AttributeError:module 'keras.engine.topology' has no attribute 'load_weights_from_hdf

keras教程  2023-02-09 16:008990

    在jupyter notebooks上运行tensorflow-keras的Mask R-CNN时遇到如下错误:

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

  参考博客中写了两种解决方案:

  解决方案一:报错是由于keras版本不对造成的。load_weighs_from_hdf5_group_by_name这个属性只在keras 2.0.8版本中出现(不清楚现在的新版本是否支持这个属性),要是你的版本大于2.0.8,就找不到这个属性了。解决办法是卸载现有版本,安装keras 2.0.8。具体操作:

  进入cmd命令行,运行如下两条命令:

1 pip uninstall keras
2 pip install keras==2.0.8

  解决方案二:(我使用了这个方法,成功解决。方案来源github issues:https://github.com/matterport/Mask_RCNN/issues/694

  在Mask R-CNN源码文件夹里,找到mrcnn/model.py文件,用“saving”替换"topology",总共替换三处,如下图

AttributeError: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

  注释掉的三句是原来的代码,注释下一行就是改后的代码,都将topology替换成了saving。

  替换后成功运行。

 

  参考至:https://blog.csdn.net/c20081052/article/details/80745969

查看更多关于【keras教程】的文章

展开全文
相关推荐
反对 0
举报 0
图文资讯
热门推荐
优选好物
更多热点专题
更多推荐文章
Keras2.2 predict和fit_generator的区别
查看keras文档中,predict函数原型:predict(self, x, batch_size=32, verbose=0)说明:只使用batch_size=32,也就是说每次将batch_size=32的数据通过PCI总线传到GPU,然后进行预测。在一些问题中,batch_size=32明显是非常小的。而通过PCI传数据是非常耗时的

0评论2023-02-09861

keras模块学习之-激活函数(activations)--笔记
本笔记由博客园-圆柱模板 博主整理笔记发布,转载需注明,谢谢合作!   每一个神经网络层都需要一个激活函数,例如一下样例代码:           from keras.layers.core import Activation, Densemodel.add(Dense(64))model.add(Activation('tanh'))或把

0评论2023-02-09550

keras: 在构建LSTM模型时,使用变长序列的方法
众所周知,LSTM的一大优势就是其能够处理变长序列。而在使用keras搭建模型时,如果直接使用LSTM层作为网络输入的第一层,需要指定输入的大小。如果需要使用变长序列,那么,只需要在LSTM层前加一个Masking层,或者embedding层即可。from keras.layers import

0评论2023-02-09679

keras channels_last、preprocess_input、全连接层Dense、SGD优化器、模型及编译
channels_last 和 channels_firstkeras中 channels_last 和 channels_first 用来设定数据的维度顺序(image_data_format)。对2D数据来说,"channels_last"假定维度顺序为 (rows,cols,channels), 而"channels_first"假定维度顺序为(channels, rows, cols)。

0评论2023-02-091012

将keras的h5模型转换为tensorflow的pb模型 keras 调用h5模型
h5_to_pb.pyfrom keras.models import load_modelimport tensorflow as tfimport os import os.path as ospfrom keras import backend as K#路径参数input_path = 'input path'weight_file = 'weight.h5'weight_file_path = osp.join(input_path,weight_file

0评论2023-02-09773

Keras MAE和MSE source code
def mean_squared_error(y_true, y_pred):if not K.is_tensor(y_pred):y_pred = K.constant(y_pred)y_true = K.cast(y_true, y_pred.dtype)return K.mean(K.square(y_pred - y_true), axis=-1)def mean_absolute_error(y_true, y_pred):if not K.is_tensor(y_

0评论2023-02-09801

Keras网络层之“关于Keras的层(Layer)” keras的embedding层
关于Keras的“层”(Layer)所有的Keras层对象都有如下方法:layer.get_weights():返回层的权重(numpy array)layer.set_weights(weights):从numpy array中将权重加载到该层中,要求numpy array的形状与layer.get_weights()的形状相同layer.get_config():返回

0评论2023-02-09888

Keras分类问题 keras 分类模型
#-*- coding: utf-8 -*-#使用神经网络算法预测销量高低import pandas as pd#参数初始化inputfile = 'data/sales_data.xls'data = pd.read_excel(inputfile, index_col = u'序号') #导入数据#数据是类别标签,要将它转换为数据#用1来表示“好”、“是”、“高

0评论2023-02-09923

更多推荐