philipperemy/keract

AttributeError: 'AxesSubplot' object has no attribute 'flat'

venergiac opened this issue · 6 comments

I applied keract to my VQ-VAE

on

kt.display_heatmaps(activations, img_o, save=False)

I got

AttributeError: 'AxesSubplot' object has no attribute 'flat'

but
kt.display_actovations(activations, save=False)

worked well.

I used VGG16 and keract worked well for both cases.

I solved changing the keract

def display_heatmaps(activations, input_image, directory='.', save=False, fix=True):

      if hasattr(axes,'flat'):
                axes.flat[i].imshow(input_image / 255.0)

                axes.flat[i].imshow(img, alpha=0.3, cmap='jet', interpolation='bilinear')
            else:
                axes.imshow(input_image / 255.0)
                axes.imshow(img, alpha=0.3, cmap='jet', interpolation='bilinear')
        if hasattr(axes,'flat'):
            axes.flat[i].axis('off')
        else:
            axes.axis('off')

but it is a workaround

@venergiac thanks for reporting. I'm going to see if there's a better way to handle this.

Do you have a snippet that reproduces the problem? I can't reproduce it on a toy example. Thanks!

I could reproduce the error. I guess this workaround works just fine for now. I'll push that to the codebase and will update it later when I have more time to understand exactly what's going on.

Fixed in 48ebbc7

Released in 4.2.2

yes confirmed now it works