marcotcr / lime

Lime: Explaining the predictions of any machine learning classifier
BSD 2-Clause "Simplified" License
11.64k stars 1.81k forks source link

Multi-input keras model and data with four channels #238

Closed satyanarayan-rao closed 6 years ago

satyanarayan-rao commented 6 years ago

Hi,

I have a keras model with two separate input and output in [0,1] (please see the model architecture below). The loss function used here is mse. multiple_inputs

Both input data has four channels. And prediction is done as per the standard keras call:

model = load_model("trained_model.h5")
pred = model.predict([test_inp1, test_inp2])

I tried to use lime_image module, but it doesn't support list as input instance to predict function. To address this concern, I followed lime_image.py to create another file (attached as txt) lime_multi_input.py.txt lime_multi_input.py.txt

Another issue I have is that my input has four channels and SegmentationAlgorithm function throws error:

ValueError: the input array must be have a shape == (.., ..,[ ..,] 3)), got (1, 24, 4, 4)

Has someone encountered similar issues? I am wondering how to handle input with four channels. And how feasible it is to do for regression?

Thanks!

satyanarayan-rao commented 6 years ago

Hi @marcotcr,

Could you please look into this problem setting and let me know if there are significant changes to be made to make it work.

Thanks a lot, Satya

marcotcr commented 6 years ago

Yeah , I think we assume the image will have 3 channels (which I think is pretty standard for images) throughout lime_image.py. The segmentation function definitely assumes it, and so does the part that hides superpixels. Sorry, I won't make the changes to make it work with 4. They're not super major, but I think 3 is standard enough.