Praneet9 / Visualising-LSTM-Activations

Visualising what each LSTM cell learns from data.
https://medium.com/@praneet9/visualising-lstm-activations-in-keras-b50206da96ff
24 stars 13 forks source link

The layer sequential_1 has never been called and thus has no defined {attr_name} #1

Open AslanDevbrat opened 2 years ago

AslanDevbrat commented 2 years ago

hey i was trying to reproduce your results. I just ran your code cell be by but i am getting the error

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
[<ipython-input-25-1ffcfad7c4a9>](https://localhost:8080/#) in <module>()
      1 lstm = model.layers[2]
----> 2 attn_func = K.function(inputs = [model.get_input_at(0), K.learning_phase()],
      3            outputs = [lstm.output]
      4           )

1 frames
[/usr/local/lib/python3.7/dist-packages/keras/engine/base_layer.py](https://localhost:8080/#) in _get_node_attribute_at_index(self, node_index, attr, attr_name)
   2699     """
   2700     if not self._inbound_nodes:
-> 2701       raise RuntimeError(f'The layer {self.name} has never been called '
   2702                          'and thus has no defined {attr_name}.')
   2703     if not len(self._inbound_nodes) > node_index:

RuntimeError: The layer sequential_1 has never been called and thus has no defined {attr_name}.
enricgrau commented 2 years ago

@AslanDevbrat I'm having the same issue. Are you using the same versions? (i.e.:Python - 3.x, Keras - 2.2.5, Tensorflow - 1.15.0). Also, check that you can use CuDNNLSTM as it is only for a GPU. Instead, try LSTM and see what happens.