keras example--the solution to AttributeError: 'Tensor' object has no attribute '_keras_history'
2018-01-10 14:41
1426 查看
input1.shape=(batch_size,sequence_length)
input1通过Embedding映射成(batch_size,sequence_length,embedding_size)#词向量
input2.shape=(batch_size,sequence_length)
通过编写自己的层转换为(batch_size,sequence_length,embedding)#与词向量对应的tf-idf值
若使用result=input1*input2,此时就会出现上述错误,这里的result是一个tensor,但不是一个keras tensor,
故需使用keras.layers.multiply([input1,input2])#keras官方解释:该层接收一个列表的同shape张量,并返回它们的逐元素积的向量,shape不变。
此时代码可以调通。
相关文章推荐
- AttributeError: 'Tensor' object has no attribute '_keras_history'
- 【问题】Keras AttributeError: 'Tensor' object has no attribute '_keras_history'
- AttributeError: 'Tensor' object has no attribute '_keras_history'
- Importing theano: AttributeError: 'module' object has no attribute 'find_graphviz'
- solution:AttributeError: 'module' object has no attribute 'PY2'
- tensorflow AttributeError: 'module' object has no attribute 'cpu_count'
- Tensorflow protobuf版本报错问题解决(AttributeError: 'module' object has no attribute 'Default')
- tensorflow AttributeError: 'module' object has no attribute 'cpu_count'
- windows tensorflow AttributeError: 'NoneType' object has no attribute 'bucketize'
- 关于import tensorflow as tf的错误:AttributeError: type object 'NewBase' has no attribute 'is_abstract'
- TensorBoard tf.summary.merge_all() AttributeError: 'NoneType' object has no attribute 'bucket 错误
- AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'seq2seq'
- AttributeError: 'dict' object has no attribute 'items' 问题
- Python 保存数组至.mat文件,报错:AttributeError: 'numpy.ndarray' object has no attribute 'items'
- scapy AttributeError: 'NoneType' object has no attribute 'route'解决办法
- AttributeError: 'NoneType' object has no attribute 'recovery'
- Scrapy安装报错:AttributeError: 'module' object has no attribute 'OP_NO_TLSv1_1'解决办法
- RabbitVCS(0.14.2)不显示右键设置(settings)菜单,AttributeError: 'gtk.VBox' object has no attribute 'set_visible
- matplotlib显示AttributeError: 'module' object has no attribute 'verbose'
- tensorflow报错:AttributeError: 'module' object has no attribute 'get_or_create_global_step'