python history没有定义_python – AttributeError:’Tensor’对象没有属性’_keras_history’...

我找了所有“’Tensor’对象没有属性***”但似乎没有一个与Keras相关(除了

TensorFlow: AttributeError: ‘Tensor’ object has no attribute ‘log10’没有帮助)…

我正在制作一种GAN(Generative Adversarial Networks).在这里你可以找到结构.

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.事情是我预先训练了model_2,列表由0和1组成,但是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

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.

感谢您提供的任何帮助!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值