keras-surgeon
keras-surgeon copied to clipboard
get_apoz throws when passing np.ndarray as x_val.
https://github.com/BenWhetton/keras-surgeon/blob/459e8dfcd9606a35299468a5e9c18b27453d3cfb/src/kerassurgeon/identify.py#L63
The following exception is thrown by the above line:
AttributeError: 'numpy.ndarray' object has no attribute 'n'
You can clone from https://github.com/MrMimic/keras-surgeon, beug's corrected here. I pulled request the OP.
Add to imports:
from keras.preprocessing.image import ImageDataGenerator
Change:
if hasattr(x_val, "__iter__"):
temp_model = Model(model.inputs,
act_layer.get_output_at(act_index))
a = temp_model.predict_generator(
x_val, x_val.n // x_val.batch_size)
to
if hasattr(x_val, "__iter__"):
temp_model = Model(model.inputs,
act_layer.get_output_at(act_index))
datagen = ImageDataGenerator(rescale=1./255)
a = temp_model.predict_generator(
datagen.flow(x_val, batch_size=bs),
steps=x_val.shape[0] // bs)
where bs
is passed as a function parameter in:
def get_apoz(model, layer, x_val, bs, node_indices=None):