zoukankan      html  css  js  c++  java
  • keras中遇到的错误

    在运行其他开源keras项目时,遇到了一些问题:

    1、在导入_obtain_input_shape时

    from keras.applications.imagenet_utils import _obtain_input_shape
    

    出现错误如下:

    ImportError: cannot import name '_obtain_input_shape'
    

    原因是在keras 2.2.2中,keras.applications.imagenet_utils模块不再有_obtain_input_shape方法。解决方法:
    将导入语句修改如下

    from keras_applications.imagenet_utils import _obtain_input_shape
    
    • 重点:使用keras_applications代替keras.applications

    2、在使用_obtain_input_shape方法时出现错误:

    _obtain_input_shape() got an unexpected keyword argument 'include_top'
    

    原因是我们的调用中使用了

    input_shape = _obtain_input_shape(input_shape,
                                      default_size=224,
                                      min_size=32,
                                      data_format=K.image_data_format(),
                                      include_top=include_top or weights)
    

    而在keras 2.2.2中函数 _obtain_input_shape() 的形式为:

    def _obtain_input_shape(input_shape,
                            default_size,
                            min_size,
                            data_format,
                            require_flatten,
                            weights=None):
    

    自然没有include_top属性。因此把调用中的include_top改为require_flatten即可

  • 相关阅读:
    properties的编码问题
    在Spring中读取properties文件
    Intellij IDEA常用配置记录
    基于Shiro的登录功能 设计思路
    在SpringMVC中操作Session、Request、Response对象
    使用MockMVC与Junit进行单体测试
    django: form fileupload
    django: form
    django: db
    django: db
  • 原文地址:https://www.cnblogs.com/sssaltyfish/p/10656766.html
Copyright © 2011-2022 走看看