LSUV-keras icon indicating copy to clipboard operation
LSUV-keras copied to clipboard

Runtime Error in TensorFlow 2.4.1

Open michelebechini opened this issue 4 years ago • 3 comments

If I run your code, the following error arises:

RuntimeError: The layer has never been called and thus has no defined input.

It is due to model.get_input_at(0) in def get_activations(model, layer, X_batch):, but I can not manage how to fix it...

Thanks in advance.

michelebechini avatar May 11 '21 18:05 michelebechini

Hi,

I am afraid that cannot help here :( this code was written in keras-theano times and I haven't written any tensorflow code since then. Probably it would be much simpler to re-implement everything from scratch.

ducha-aiki avatar May 11 '21 20:05 ducha-aiki

Thank you for your quick reply. I reimplemented everything in TF 2.4.1, the only problem is how to run the first batch through the layer on which the LSUV is applied and get the activations.

I will try to solve this issue. Thanks again.

michelebechini avatar May 11 '21 20:05 michelebechini

Hi, you can replace

    intermediate_layer_model = Model(
        inputs=model.get_input_at(0),
        outputs=layer.get_output_at(0)
    )

with

intermediate_layer_model = Model(
        inputs=model.input,
        outputs=layer.get_output_at(0)
    )

and the initialization works as expected.

phrasenmaeher avatar Oct 11 '21 16:10 phrasenmaeher