greentfrapp / lucent

Lucid library adapted for PyTorch
Apache License 2.0
597 stars 89 forks source link

Propagating KeyboardInterrupt in render_vis #33

Open TomFrederik opened 2 years ago

TomFrederik commented 2 years ago

Currently, when one executes for i in range(num_channels): _ = render.render_vis(model, objective.channels(layer_name, i))

and then interrupts, e.g. by hitting the stop button in Colab, then it will simply stop the current optimization and then continue to loop. This is annoying for interactive programming. I suggest re-raising the KeyboradInterrupt after catching it with the except. This way the code is still stopped when interrupting from keyboard.