Trying to use keract.get_activations() for days, keep getting stuck
evanrmurphy opened this issue · 3 comments
I've been trying for several days to successfully use keract.get_activations()
on an acoustic or speech recognition ML model. This is the failure I've encountered most often:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-20-bf90f67762d7> in <module>()
----> 1 activations = get_activations(model_proper, speech_encoded, auto_compile=True)
/usr/local/lib/python3.7/dist-packages/keract/keract.py in get_activations(model, x, layer_names, nodes_to_evaluate, output_format, nested, auto_compile)
328 'Network layers are [{}]'.format(', '.join(layer_names), network_layers))
329 else:
--> 330 raise ValueError('Nodes list is empty. Or maybe the model is empty.')
331
332 # The placeholders are processed later (Inputs node in Keras). Due to a small bug in tensorflow.
ValueError: Nodes list is empty. Or maybe the model is empty.
I've been working in Colab using the wav2vec2 model. The notebook I was using had some elements not directly related to this, so I've copied only the relevant parts into a more streamlined Colab that's easier to follow:
https://colab.research.google.com/drive/15NVey3pT9e78qJHZ_9gqBAmvvnV5814Q
The first part of the Colab is all preparing the model, so you can scroll toward the bottom where keract actually comes into play.
Here's a screenshot of the failure in the Colab (image of the same error pasted in text above):
Can you please help me get past this issue and to a successful use of get_activations()
on this model? Your library could be really useful for my interpretability research.
I tried running a debugger and looking closer at the keract.py code to see what the problem is. This led me to redefining my model from a sole KerasLayer to a Keras Model containing that layer, as you'll see in the Colab linked above. But the problem still continues.
@evanrmurphy Hey Evan! Can you distill the minimum snippet that can reproduce the issue you have? Copy paste here that I can have a look!
I already did distill it into the Colab linked above. 😕 Admittedly there is still a fair amount of setup in that notebook though, I guess that's what you mean...
I was able to unblocked and at what I needed moment using another library so I probably won't be working on the keract integration again unless/until I hit major issues with that. Thank you, Philippe.
@evanrmurphy okay no problem! Thanks for pointing out the issue!