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, ...
随机推荐
- C++ 第三课:常量转义字符
常量转义字符 以下的转义字符使普通字符表示不同的意义. 转义字符 描述 \' 单引号 \" 双引号 \\ 反斜杠 \0 空字符 \a 响铃 \b 后退 \f 走纸 \n 换行 \r 回车 \ ...
- POSTGRESQL 创建表结构、修改字段、导入导出数据库(支持CSV)
这两个月经常使用postgresql,总结一些经常使用的语句: --创建表 CREATE TABLE customers ( customerid SERIAL primary key , compa ...
- java.lang.NoSuchMethodError: org.apache.commons.lang.StringUtils.endsWith(Ljava/lang/String;Ljava/lang/String;)Z
这是一个包冲突的典型错误,今天搞了一天.从错误信息就能看出是commons.lang出现的问题,解决方案:去掉新增加的conmons.lang依赖,加载其他的版本. 1.在编译之后的目录查看加载的包版 ...
- FILTER——JAVA
一.概念 Filter也称之为过滤器,它是Servlet技术中比较激动人心的技术,WEB开发人员通过Filter技术,对web服务器管理的所有web资源:例如Jsp, Servlet, 静态图片文件或 ...
- ubuntu 下 cajview 替代方案
.caj 是知网提供的论文的标准格式,但是,知网只提供 win 版的工具.这里尝试了两个两个方案,均可行,做一下记录在此. 1. 使用 wine 版的 cajview pdf 可以正常用,但是 ca ...
- merge-intervals 合并区间
Given a collection of intervals, merge all overlapping intervals. For example,Given[1,3],[2,6],[8,10 ...
- 我的第一个android应用——装逼神器《微博尾》
继<微博尾>之<玩转尾巴>好玩尾巴积分版传送门:http://blog.csdn.net/love_5209/article/details/39473983 (本文andro ...
- LeetCode 225 Implement Stack using Queues(用队列来实现栈)(*)
翻译 用队列来实现栈的例如以下操作. push(x) -- 将元素x加入进栈 pop() -- 从栈顶移除元素 top() -- 返回栈顶元素 empty() -- 返回栈是否为空 注意: 你必须使用 ...
- V-rep学习笔记:外部函数调用方式
The remote API functions are interacting with V-REP via socket communication in a way that reduces l ...
- django之创建第9个项目-管理后台admin
django之创建第9个项目-管理后台admin配置 1.配置setting文件INSTALLED_APPS = ( 'django.contrib.auth', 'django.cont ...