Keras版本升级函数变换导致的问题

Keras版本升级函数变换导致的问题

在使用 CNN的时候,报错: TypeError: (‘Keyword argument not understood:’, ‘padding’)
在这里插入图片描述
将“padding”改为“border_mode”,即可
在这里插入图片描述
原因:padding 是Keras 2.X的语法,而我的PC安装的是 Keras 1.X版本。

二者的API 有一些地方是有变化的。

如下:(从 1.X 到 2.X )

========【Models】

1、Constructor arguments for Model have been renamed:

input -> inputs
output -> outputs
2、The Sequential model not longer supports the set_input method.

3、For any model saved with Keras 2.0 or higher, weights trained with backend X will be converted to work with backend Y without any manual conversion step.

========【Layers】

1、Dense layer

Changed interface:
output_dim -> units
init -> kernel_initializer
added bias_initializer argument
W_regularizer -> kernel_regularizer
b_regularizer -> bias_regularizer
b_constraint -> bias_constraint
bias -> use_bias

2、Embedding

Convolutional layers :

Interface changes common to all convolutional layers:

nb_filter -> filters
float kernel dimension arguments become a single tuple argument, kernel size. E.g. a legacy call Conv2D(10, 3, 3) becomes Conv2D(10, (3, 3))
kernel_size can be set to an integer instead of a tuple, e.g. Conv2D(10, 3) is equivalent toConv2D(10, (3, 3)).
subsample -> strides. Can also be set to an integer.
border_mode -> padding
init -> kernel_initializer
added bias_initializer argument
W_regularizer -> kernel_regularizer
b_regularizer -> bias_regularizer
b_constraint -> bias_constraint
bias -> use_bias
dim_ordering -> data_format
In the SeparableConv2D layers, init is split into depthwise_initializer andpointwise_initializer.
Added dilation_rate argument in Conv2D and Conv1D.
1D convolution kernels are now saved as a 3D tensor (instead of 4D as before).
2D and 3D convolution kernels are now saved in format spatial_dims + (input_depth, depth)), even with data_format=“channels_first”.

3、Pooling1D

pool_length -> pool_size
stride -> strides
border_mode -> padding

4、Pooling2D,3D

border_mode -> padding
dim_ordering -> data_format

【Reference】
1、Keras 2.x和1.x的区别 :https://blog.csdn.net/ch1209498273/article/details/78287145
2、Keras 官方发布的 :Keras 2.0 release notes :https://github.com/keras-team/keras/wiki/Keras-2.0-release-notes
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值