【问题】Keras AttributeError: 'Tensor' object has no attribute '_keras_history'
来源:互联网 发布:小学宝这款软件怎么样 编辑:程序博客网 时间:2024/06/05 23:45
问题
在Keras函数式模型中加入后端函数操作时出现的错误。
from keras import backend as K...input1 = Input(shape(2,))input2 = Input(shape(3,))output = K.concatenate([input1,input2], axis=-1)model = Model(inputs=[input1,input2],outputs=output)...
此时运行则会爆出错误
AttributeError: 'Tensor' object has no attribute '_keras_history'
原因可能是backend执行的操作返回值没有错误中提到的_keras_history。
解决方法
1、将backend的操作用Keras封装好的层(layer)来实现,比如上面的concatenate(),可用keras.layer.Concatenate层,或者keras.layer.concatenate函数(本质是Concatenate层的接口)。
2、使用Lambda层来对操作进行封装。还是刚才的操作,代码为:
from keras.layers import Lambda...my_concat = Lambda(lambda x: K.concatenate([x[0],x[1]],axis=-1))output = my_concat([input1,input2])...
阅读全文
0 0
- 【问题】Keras AttributeError: 'Tensor' object has no attribute '_keras_history'
- AttributeError: ‘module’ object has no attribute’ 问题
- AttributeError: 'module' object has no attribute 'post'问题
- 【TensorFlow问题】AttributeError:'module' object has no attribute 'mul'
- 上传问题之AttributeError: '_socketobject' object has no attribute 'set_tlsext_host_name'
- 问题AttributeError: ‘module’ object has no attribute ‘sub’
- 【TensorFlow问题】AttributeError:'module' object has no attribute 'mul'
- AttributeError: 'classmethod' object has no attribute '__module__'
- AttributeError: 'module' object has no attribute 'getpass'
- AttributeError: ‘NoneType’ object has no attribute ‘clone’
- AttributeError: 'module' object has no attribute 'Serial'
- AttributeError: 'NoneType' object has no attribute 'clone'
- AttributeError: 'tuple' object has no attribute 'Multi'
- AttributeError: 'Response' object has no attribute 'json'
- AttributeError: 'module' object has no attribute(转)
- AttributeError: 'Connection' object has no attribute 'connection_errors'
- AttributeError: 'module' object has no attribute 'randint'
- AttributeError: 'module' object has no attribute 'HAVE_DECL_MPZ_POWM_SEC'
- 微博深度学习平台架构和实践
- Linux vi 快捷键
- 那些女程序员们的故事
- 程序包org.apache.http不存在,解决方式
- 马云说,即使阿里巴巴死了,达摩院也要活着
- 【问题】Keras AttributeError: 'Tensor' object has no attribute '_keras_history'
- ubuntu的FTP服务配置
- Linux 安装Mysql rpm包
- VR开发之VRTK插件使用(一)
- Tomcat启动时有不允许有匹配 "[xX][mM][理指令目标。
- Java中的clone方法
- C# 读取WebConfig配置信息
- Visual Studio 2017强制更新方法
- c#中用IComparable实现排序