I’m trying have a keras functional API model and I want to use
EagerTensor.numpy() method in it, so it’s important to use the model in eager mode. Lets say that I want to run the code below:
input = tensorflow.keras.layers.Input((3,)) x = input.numpy() y = 2 * x model = keras.Model(input, y, name = "model")
But it gives me an error saying:
‘Tensor’ object has no attribute ‘numpy’
And thats because
Input layer returns a
Tensor not an
keras lets me to build a model in graph mode and then change it to eager mode (in models
compile method) but it’s weird that I cant build a model in eager mode and use its benefits (or actually there is a way that I don’t know).
My current solution is to use
GradientTape and forget the model. But I’m waiting for a better solution.
Source: Python Questions