• Debug 路漫漫-08: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

  • 相关阅读:
    创建zabbix监控,添加监控机(server、agent、windows)
    KVM虚拟化平台简介及环境部署
    利用nginx的stream模块实现内网端口的转发代理
    Mysql主主同步+keepalived实现高可用
    基于 MHA 的 MySQL 高可用方案
    mysql基于Amoeba(变形虫)实现读写分离
    mysql主从异步复制
    基于mysqld_multi实现MySQL多实例多进程配置
    基于Haproxy+Keepalived构建高可用负载均衡集群
    yum 安装报错The GPG keys listed for the "CentOS-7
  • 原文地址:https://www.cnblogs.com/shenxiaolin/p/11219607.html
Copyright © 2020-2023  润新知