skorch
skorch copied to clipboard
Document intermediate value debugging in FAQ
I think this is a topic that is relevant to many users and we can document the multiple output case there as well. See #428 as well.
There seems to be two big use cases for multiple outputs:
- The multIple outputs are used to calculate the loss.
- In #428 where one of the outputs is used to view layers of the model.
For case 1, we explore some for the possible ways to handle this in issue https://github.com/dnouri/skorch/issues/422.
For case 2, I prefer the use of the forward_hooks. In any case, this would require the user to keep track of some state.
For case 2 we could provide callbacks that do the bookkeeping for the user, e.g.
net = Net(...,
callbacks=[
EpochLogger('fc', lambda mod, in, out: out),
]
)
# ... fit/predict ...
dict(net.callbacks_)['EpochLogger'].values
The name is obviously a matter of discussion, as is the callback itself.
Regarding said callback: We could also have a more general function signature that takes the callback and the other arguments as input. This would allow things like this:
# function that just appends the values, as suggested above; could be default
def func(callback, mod, in, out):
callback.values_.append(out)
# function that logs to visdom
def func(callback, mod, in, out):
do_visdom_things(out)
(btw., in is not a valid variable name ;) )