Keras 2.0版本运行
Keras 2.0版本运行demo出错:
d:\program\python3\lib\site-packages\ipykernel_launcher.py:8: UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(32, (3, 3), activation="relu")`
使用Keras时用到了卷积层Convolution2D( )以及Model.fit( ):
x = Convolution2D(8, 3, 3, activation='relu', border_mode='same')(x)
Model.fit(x_train, x_train, nb_epoch=10, batch_size=256, shuffle=True, validation_data=(x_test, x_test))
遇到了如下错误:
UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(1, (3, 3), padding="same", activation="sigmoid")`
decoded = Convolution2D(1, 3, 3, activation='sigmoid', border_mode='same')(x)
在查看了github上的Keras 2.0发行说明后,发现这是从Keras 1到Keras 2发生的变化.
此处涉及到的有:
Convolution* 层被重新命名 Conv* ;
border_mode - > padding ;
nb_epoch - > epochs;
kernel_size可以设置为一个整数,例如Conv2D(10, 3)相当于Conv2D(10, (3, 3));
因此,
x = Convolution2D(8, 3, 3, activation='relu', border_mode='same')(x)
Model.fit(x_train, x_train, nb_epoch=10, batch_size=256, shuffle=True, validation_data=(x_test, x_test))
改为:
x = Conv2D(8, 3, activation='relu', padding='same')(x)
Model.fit(x_train, x_train, epochs=10, batch_size=256, shuffle=True, validation_data=(x_test, x_test))
修正后版本:
from keras.models import *
from keras.layers import *
import sys input_tensor = Input((height, width, 3))
x = input_tensor
for i in range(4):
x = Conv2D(32*2**i, 3, activation='relu')(x)
x = Conv2D(32*2**i, 3, activation='relu')(x)
x = MaxPooling2D((2, 2))(x) x = Flatten()(x)
x = Dropout(0.25)(x)
x = [Dense(n_class, activation='softmax', name='c%d'%(i+1))(x) for i in range(4)]
model = Model(inputs=input_tensor, outputs=x) model.compile(loss='categorical_crossentropy',
optimizer='adadelta',
metrics=['accuracy'])
其他更多变化参见:Keras 2.0发行说明
原文:https://blog.csdn.net/akadiao/article/details/80405766
ImportError: No module named 'keras.utils.visualize_util'
1、Q:ImportError: No module named visualize_util
A:自从2017年之后,visualize_util 变成vis_utils, 并且plot函数重新命名成plot_model.
You will have to either fix the code manually, or downgrade Keras.
By looking at the commit history of that module, you can see that it was renamed on February 28, 2017 from visualize_util to vis_utils. The plot function was also renamed to plot_model.
python 版本问题
Traceback (most recent call last):
File “<pyshell#32>”, line 1, in <module>
f.next()
AttributeError: ‘generator’ object has no attribute ‘next’
原因是在python 3.x中 generator(有yield关键字的函数则会被识别为generator函数)中的next变为__next__了,next是python 3.x以前版本中的方法
修改为下面这样运行正常
f=fab(5)
f.__next__()
Keras 2.0版本运行的更多相关文章
- win7+cuda+anaconda python+tensorflow-gpu+keras安装成功版本匹配汇总
win7+cuda+anaconda python+tensorflow-gpu+keras安装成功版本匹配汇总 2019-09-20 15:06:03 wyx100 阅读数 38更多 分类专栏: M ...
- hadoop源码编译——2.5.0版本
强迫症必治: WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using b ...
- RDIFramework.NET ━ .NET快速信息化系统开发框架钜献 V3.0 版本强势发布
继上个版本“RDIFramework.NET V2.9版本”的推出,受到了重多客户的认可与选择,V2.9版本是非常成功与稳定的版本,感谢大家的认可与长期以来的关注与支持.V3.0版本在V2.9版本的基 ...
- 结对编程--基于android平台的黄金点游戏(2.0版本)
在昨天上传完博客之后发现一个重大的bug...故在此推出2.0版本. 博文详情见:http://www.cnblogs.com/RayShea/p/5372398.html coding地址:http ...
- Android 6.0的运行时权限
原文 http://droidyue.com/blog/2016/01/17/understanding-marshmallow-runtime-permission/ 主题 安卓开发 Andr ...
- iOS开发---百度地图配置流程,2.6.0 版本 支持64位
1.首先需要在百度地图下载最新SDK:地址: http://developer.baidu.com/map/index.php?title=iossdk/sdkiosdev-download 2. ...
- Cocos2dx-3.0版本 从开发环境搭建(Win32)到项目移植Android平台过程详解
作为重量级的跨平台开发的游戏引擎,Cocos2d-x在现今的手游开发领域占有重要地位.那么问题来了,作为Cocos2dx的学习者,它的可移植特性我们就需要掌握,要不然总觉得少一门技能.然而这个时候各种 ...
- MySQL5.0版本的安装图解教程
MySQL5.0版本的安装图解教程是给新手学习的,当前mysql5.0.96是最新的稳定版本. mysql 下载地址 http://www.jb51.net/softs/2193.html 下面的是M ...
- ExtJS 5.0版本问题+Sencha cmd
ExtJS 5.0版本官方网站给的图表例子,以散点图作说明: Ext.create('Ext.Container', { //renderTo: Ext.getBody(), width: 600, ...
随机推荐
- vcenter 5.1安装亲历
这一步死活提示nslookup 解析不了 ping的结果如下: 下载http://support.microsoft.com/kb/929852 工具 禁用IPv6即可,而且还需要在DNS中创建反向查 ...
- Audition CC2019 MME设备内部错误怎么解决!
安装完了AA2019,没有想到像昨天安装系统那么不顺利... 当然出现问题的原因是因为我安装了win10 并且我禁用了麦克风的所有应用权限. 设置里面搜索 麦克风 权限 Ok工作啦, 好开森~ ...
- web.xml关于spring的讲解
<context-param>的作用: web.xml的配置中<context-param>配置作用 . 启动一个WEB项目的时候,容器(如:Tomcat)会去读它的配置文件w ...
- PhpStorm 2017.1安装及破解过程
1.下载原安装文件和破解文件:magnet:?xt=urn:btih:7FD357910B7AFBFC8FBA3647A2FAC8F15F0D02F0 (直接放到迅雷里下载) 2.Licence S ...
- 【Linux】创建不可修改文件
有时候,我们害怕别人修改我们创建的文件,或者是误删我们创建的文件,那么我们可以使用下面的方法进行控制即可 1.创建不可删除文件 Linux:/qinys/oliver # touch test.sh ...
- Eureka客户端网卡和网段选择
当机器上有多个网卡或者机器上配置了回环地址的时候,Eureka客户端呈报给服务端的IP将不可预见,为了指定IP我们需要增加以下配置: 在bootstrap.yml中增加配置内容: spring: cl ...
- Arduino——My-Clock项目 发布时间:2018-12-31
技术:Arduino.光敏传感器.DHT11.DS1302.OLED显示屏 概述 项目My-Clock是一个环境监测时钟,接入光敏传感器和温湿度传感器监测环境信息,加入DS1302模块用于获取时间 ...
- ios中修改数字键盘
自定义文本框: #import <UIKit/UIKit.h> //自定义键盘的键定义 @interface DIYKey : NSObject { } @property(copy, n ...
- 得到类所在的jar包路径
//理论上用class.getProtectionDomain().getCodeSource().getLocation().getFile();比较准. //不过有两个需要注意的: //1.返 ...
- Eclipse中10个最有用的快捷键组合(转)
Eclipse中10个最有用的快捷键组合 一个Eclipse骨灰级开发者总结了他认为最有用但又不太为人所知的快捷键组合.通过这些组合可以更加容易的浏览源代码,使得整体的开发效率和质量得到提升. ...