Relative Content

Tag Archive for tensorflowkeras

Wrapping tf functions in layers: model.fit not working

I’ve been following along with a video series from 2020 that details how to build a variational autoencoder inside of Python, and I’ve had to reformat the code in some places to get it to work with the modern version of Tensorflow. I’ve run into an issue where I try to use K.function on a dense layer (called self.mu), but I keep getting an error saying that I can’t pass a Keras tensor into a Tensorflow function. For example, here is some of the problematic code:

How to access the the tensors between layers in keras as numpy

I have a keras model defined using Functional API. I also have its weights (.h5 file), and a single example input tensor (stored in a .npy file). I am trying to reimplement this exact model in pytorch. And i am getting a completely different result. I would like to see where did i go wrong by comparing the tensors between each layer. But i cant for the life of me extract those tensors.