I looked for all the \"\'Tensor\' object has no attribute ***\" but none seems related to Keras (except for TensorFlow: AttributeError: 'Tensor' object has no attrib
Try this:
def make_gan(GAN_in, model1, model2, model3):
model1_out = model1(GAN_in)
model1_out = Lambda(lambda x: K.round(x), output_shape=...)(model1_out)
model2_out = model2([GAN_in, 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
My problem was using '+' instead of 'Add' on keras
@'Maëva LC': I can't post a comment, this answers your None
issue.
but the code is working fine without the line
model1_out = (lambda x: K.round(x), output_shape=...)(model1_out)
and not anything else. Anyway, thank you for trying.
Function round()
is not differentiable, hence the gradient is None. I suggest you just remove the line.
Since the error comes directly from here:
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)
, and the inputs of your models depend on the outputs from previous models, I believe the bug lies in the codes in your model.
In you model code, please check line by line whether or not you apply a non-Keras operation, especially in the last few lines. For example ,for element-wise addition, you might intuitively use +
or even numpy.add
, but keras.layers.Add()
should be used instead.