def showarray(a, fmt='jpeg'): """Display image in windows""" a = np.uint8(np.clip(a, 0, 255)) f = StringIO() PIL.Image.fromarray(a).save(f, fmt) display(Image(data=f.getvalue())) # Class DD: DeepDream