TypeError: 'module' object is not callable


问题描述

运行命令

错误日志

Traceback (most recent call last):
  File "./run.py", line 125, in <module>
    model = get_unet()
  File "./run.py", line 103, in get_unet
    up6 = merge([UpSampling2D(size=(2, 2))(conv5), conv4], mode='concat', concat_axis=1)
TypeError: 'module' object is not callable

解决方法

安装历史版本 Keras 2.1.6 之前的版本。[ Releases ]

# pip install https://github.com/keras-team/keras/releases/tag/2.1.6

问题分析

1、根据错误日志,找不到模块。
2、查看(搜索路径下),是否真的没有这个模块。

>>> import sys
>>> print(sys.path)

3、看一下是否有Keras的安装路径下是否有merge.py这个模块(文件)。

$ pip install keras

4、已经安装了keras,在头文件也是引入了 from keras.layers import merge。但是为什么找不到呢?

5、确实也存在merge模块(文件)

6、打开merge.py,发现并没有merge()函数,那自然就无法调用了。[Ref]


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM