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.

down voteaccepted

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版本运行的更多相关文章

  1. win7+cuda+anaconda python+tensorflow-gpu+keras安装成功版本匹配汇总

    win7+cuda+anaconda python+tensorflow-gpu+keras安装成功版本匹配汇总 2019-09-20 15:06:03 wyx100 阅读数 38更多 分类专栏: M ...

  2. hadoop源码编译——2.5.0版本

    强迫症必治: WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using b ...

  3. RDIFramework.NET ━ .NET快速信息化系统开发框架钜献 V3.0 版本强势发布

    继上个版本“RDIFramework.NET V2.9版本”的推出,受到了重多客户的认可与选择,V2.9版本是非常成功与稳定的版本,感谢大家的认可与长期以来的关注与支持.V3.0版本在V2.9版本的基 ...

  4. 结对编程--基于android平台的黄金点游戏(2.0版本)

    在昨天上传完博客之后发现一个重大的bug...故在此推出2.0版本. 博文详情见:http://www.cnblogs.com/RayShea/p/5372398.html coding地址:http ...

  5. Android 6.0的运行时权限

    原文  http://droidyue.com/blog/2016/01/17/understanding-marshmallow-runtime-permission/ 主题 安卓开发   Andr ...

  6. iOS开发---百度地图配置流程,2.6.0 版本 支持64位

      1.首先需要在百度地图下载最新SDK:地址: http://developer.baidu.com/map/index.php?title=iossdk/sdkiosdev-download 2. ...

  7. Cocos2dx-3.0版本 从开发环境搭建(Win32)到项目移植Android平台过程详解

    作为重量级的跨平台开发的游戏引擎,Cocos2d-x在现今的手游开发领域占有重要地位.那么问题来了,作为Cocos2dx的学习者,它的可移植特性我们就需要掌握,要不然总觉得少一门技能.然而这个时候各种 ...

  8. MySQL5.0版本的安装图解教程

    MySQL5.0版本的安装图解教程是给新手学习的,当前mysql5.0.96是最新的稳定版本. mysql 下载地址 http://www.jb51.net/softs/2193.html 下面的是M ...

  9. ExtJS 5.0版本问题+Sencha cmd

    ExtJS 5.0版本官方网站给的图表例子,以散点图作说明: Ext.create('Ext.Container', { //renderTo: Ext.getBody(), width: 600, ...

随机推荐

  1. LintCode: Search A 2d Matrix

    1. 设查找的数位y,第一行最后一列的数位x 如果x<y,x是第一行最大的,所以第一行都小于y,删除第一行: 如果x>y,x是最后一列最小的,所以最后一列都大于y,删除最后一列: 这样保证 ...

  2. NUMA总结。

    vsphere 5.1性能最佳实践http://www.vmware.com/pdf/Perf_Best_Practices_vSphere5.1.pdf vNUMA 要求:硬件版本8以上. 1.整个 ...

  3. Go语言中使用MySql数据库

    Go语言中使用MySql数据库 1.MySQL驱动 Go中支持MySQL的驱动目前比较多,有如下几种,有些是支持database/sql标准,而有些是采用了自己的实现接口,常用的有如下几种: http ...

  4. vs2015使用Apache Cordova用JavaScript来访问本地设备的功能,比如摄像头、加速计

    看到下面这张图就代表着我VS2015 跨平台Moblie开发工具安装成功了. 上周安装成功后本想一睹跨平台开发的乐趣,可是一直找不到合适的入口.这周又来捯饬一下结果发现了一个入口.于是来写一个Hell ...

  5. MACD判断定背离,底背离

    MACD背离: 价格创新高而指标却下跌 价格创新低而指标却上涨 缠中说禅背离 多次缠绕中唇吻的面积更小 看图说话:

  6. Java I/O 操作及优化建议

    Java I/O I/O,即 Input/Output(输入/输出) 的简称.就 I/O 而言.概念上有 5 种模型:blocking I/O.nonblocking I/O,I/O multiple ...

  7. Aerospike系列:5:安装AMC

    1:需要安装的包,如果缺少,请安装. python (2.6+) gcc python-devel 安装相应的模块 sudo pip install markupsafe sudo pip insta ...

  8. Linux下通用打印系统CUPS使用教程

    昨天研究了一下关于在Linux下实现打印操作的相关内容,整理记录如下: 1.什么是CUPS CUPS(Common UNIX Printing System,即通用Unix打印系统)是FedoraCo ...

  9. 利用Linux文件系统内存cache来提高性能

    https://www.linuxjournal.com/article/6345 利用Linux文件系统内存cache来提高性能 本地磁盘文件->socket发送,4步骤数据流向: hard ...

  10. 【DB2】设置表不记录日志,但是回滚导致表不可用报错:DB2 SQL Error: SQLCODE=-1477, SQLSTATE=55019, SQLERRMC=LEN.TMP;5;3, DRIVER=3.57.82

    今天在生产发现个问题,很多表报错:SQLCODE=-1477 后来线下模拟出这种场景 出现这个问题,此时对表做reorg.runstats都是无效的. 那么怎么来解决这个问题呢? 只能重建表解决问题