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. 关于RF对于不在屏幕内的页面元素的处理办法

    1.碰到的问题: 最近在公司用Robot framework+Selenium2Library做项目,碰到部分页面比较长,无法完全显示在屏幕内,需要上下滚动滚动条才能看到下半部分的页面元素.于是呼,问 ...

  2. POSTGRESQL表分区

    最近发现POSTGRESQL的一张表(下面统称为test表)达到67G大小,不得不进行重新分区,下面记录一下步骤: 前言.查看数据表结构(表结构肯定是虚构的) CREATE TABLE test ( ...

  3. hibernate调用mysql存储过程

    在mysql中创建两个存储过程,如下: 1.根据id查找某条数据: )) begin select * from emp where empId=id; end; 2.根据id查找某个字段,并返回 ) ...

  4. Android——开机自启动app

    android在开机完成后会发送一个android.intent.action.BOOT_COMPLETED的广播,告诉系统内app们已经开机. 我们可以在需要开机自启动的app中定义一个广播接收器, ...

  5. ADAMS与外部程序通信(Adams Command Server)

    The Adams Command Server is an Adams View (or Adams Car) component that manages communication betwee ...

  6. RHEL SHELL快捷键

    Shell快捷键 CTRL+a  调到命令行头  e  调到命令行尾 CTRL+u  光标前面的删除  k  光标后面的删除 CTRL+→词的头   词的尾 ESC+.   粘贴上个命令的尾词 杀掉远 ...

  7. 实现两个Mysql数据库同步

    一.     概述  MySQL从3.23.15版本以后提供数据库复制(replication)功能,利用该功能可以实现两个数据库同步.主从模式.互相备份模式的功能.本文档主要阐述了如何在linux系 ...

  8. 微信小程序与手机APP区别

    微信小程序与手机APP区别 ------------------<><><><>------------------ 微信小程序自去年年初,张小龙放话要 ...

  9. 命令行参数解析函数getopt和getopt_long函数【转】

    原文地址:http://blog.csdn.net/cashey1991/article/details/7942809 getopt和getopt_long函数   平时在写程序时常常需要对命令行参 ...

  10. ubuntu安装wkhtmltopdf

    下载安装wkhtmltox系统环境 http://wkhtmltopdf.org/downloads.html wget https://bitbucket.org/wkhtmltopdf/wkhtm ...