philipperemy/keract

Activations for multi-output layers

jvahl opened this issue · 3 comments

jvahl commented

Is it possible to get activations for multi-output layers? See below for a simplified example.

import tensorflow as tf
import keract
import numpy as np

# define model
inputs = tf.keras.Input(shape=(None,),name='input')
emb = tf.keras.layers.Embedding(100,4,name='embeddding')(inputs)
lstm = tf.keras.layers.LSTM(4, return_sequences=True, return_state=True, name='lstm')
lstm_outputs, state_h, state_c = lstm(emb)
outputs = tf.keras.layers.Dense(1,name='final_dense')(state_h)

model = tf.keras.Model(inputs,outputs)
model.summary()


# create example
x = np.array([[1,2,3]])

# get activations
act = keract.get_activations(model, x, layer_names='lstm')
print(act)

Currently, the code raises
AttributeError: 'list' object has no attribute 'op'

I think the issue is similar to #110 but the fix therein does not solve this issue. I am using keract version 4.3.1

@jvahl right I think the fix didn't cover this case. Thanks for the detailed analysis. Will work on a fix tomorrow!

Problem solved in 4.3.2! Update keract :)