-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to globally override callback caching (#971)
Resolves #957 (look there for motivation) Description I went with the option to add an argument to the NeuralNet class itself that can override the caching behavior of the scoring callbacks. This seemed more straightforward than going with a context manager, which is not a pattern we typically require of skorch users. The disadvantage is that we have yet one more parameter on the NeuralNet. By default, the caching behavior of the callbacks is not changed, i.e. this should be fully backwards compatible. Implementation Ideally, I would have liked to implement this in a way that any new (or user defined) callback don't have to do anything special to honor the parameter. However, this is not really possible. Although I moved the logic of whether to use inference caching inside of skorch.callbacks.scoring._cache_net_forward_iter, so that the global override is automatically taken into account here, there are other places in the callbacks whose behavior changes depending on the use of caching (e.g. target extraction). The check for whether there is a caching override thus has to be performed multiple times.
- Loading branch information
1 parent
c6c2ef5
commit 48cb4a1
Showing
4 changed files
with
151 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters