'NoneType' object has no attribute 'summary'

Posted on 2020-04-04 21:35  希望永远十七  阅读(1684)  评论(0)    收藏  举报

1. 什么是NoneType

来自stackoverflow上的回答:NoneType is the type for the None object, which is an object that indicates no valueNone is the return value of functions that "don't return anything". It is also a common default return value for functions that search for something and may or may not find it;

2 . 出现的问题

问题代码如下

1 model = AE()
2 model = model.build(input_shape=(None, 784))
3 model.summary()

第2行代码出错了,model.build()是不返回什么的。所以此时model变成了NoneType object,而NoneType object并没有summary属性,所以直接报错'NoneType' object has no attribute 'summary'