gpt4 book ai didi

python - AttributeError: 'Tensor' 对象没有属性 '_keras_history'

转载 作者:太空狗 更新时间:2023-10-29 17:24:07 25 4
gpt4 key购买 nike

我查找了所有“'Tensor' 对象没有属性 ***”,但似乎没有一个与 Keras 相关(TensorFlow: AttributeError: 'Tensor' object has no attribute 'log10' 除外,它没有帮助)...

我正在制作一种 GAN(生成对抗网络)。在这里您可以找到结构。

Layer (type)                     Output Shape          Param #         Connected to                     
_____________________________________________________________________________
input_1 (InputLayer) (None, 30, 91) 0
_____________________________________________________________________________
model_1 (Model) (None, 30, 1) 12558 input_1[0][0]
_____________________________________________________________________________
model_2 (Model) (None, 30, 91) 99889 input_1[0][0]
model_1[1][0]
_____________________________________________________________________________
model_3 (Model) (None, 1) 456637 model_2[1][0]
_____________________________________________________________________________

我预训练了 model_2 和 model_3。问题是我使用由 0 和 1 组成的列表对 model_2 进行了预训练,但 model_1 返回了接近的值。所以我考虑使用以下代码对 model1_output 进行舍入:model1_out 上的 K.round()。

import keras.backend as K
[...]
def make_gan(GAN_in, model1, model2, model3):
model1_out = model1(GAN_in)
model2_out = model2([GAN_in, K.round(model1_out)])
GAN_out = model3(model2_out)
GAN = Model(GAN_in, GAN_out)
GAN.compile(loss=loss, optimizer=model1.optimizer, metrics=['binary_accuracy'])
return GAN
[...]

我有以下错误:

AttributeError: 'Tensor' object has no attribute '_keras_history'

完整回溯:

Traceback (most recent call last):
File "C:\Users\Asmaa\Documents\BillyValuation\GFD.py", line 88, in <module>
GAN = make_gan(inputSentence, G, F, D)
File "C:\Users\Asmaa\Documents\BillyValuation\GFD.py", line 61, in make_gan
GAN = Model(GAN_in, GAN_out)
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\legacy\interfaces.py", line 88, in wrapper
return func(*args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\topology.py", line 1705, in __init__
build_map_of_graph(x, finished_nodes, nodes_in_progress)
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\topology.py", line 1695, in build_map_of_graph
layer, node_index, tensor_index)
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\topology.py", line 1695, in build_map_of_graph
layer, node_index, tensor_index)
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\topology.py", line 1665, in build_map_of_graph
layer, node_index, tensor_index = tensor._keras_history
AttributeError: 'Tensor' object has no attribute '_keras_history'

我在 Windows 7 上使用 Python 3.6 和 Spyder 3.1.4。我上周用 pip 升级了 TensorFlow 和 Keras。感谢您提供的任何帮助!

最佳答案

我的问题是在 keras 上使用“+”而不是“Add”

关于python - AttributeError: 'Tensor' 对象没有属性 '_keras_history',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44889187/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com