What that error message is telling you is that x is not a tensor: it’s a Sequential model object. As Balaji says, it’s important to keep track of which things are functions and which are tensors. We’re in pretty deep waters here. One way to get a better view of all this is to have a look at this thread about the Keras Sequential and Functional models.