Skip to content

Commit

Permalink
Jacobian generator function argument now defaults to model(x[0])
Browse files Browse the repository at this point in the history
  • Loading branch information
tfjgeorge committed Jan 15, 2021
1 parent 9867648 commit 555aefb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions nngeometry/generator/jacobian.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,25 @@ class Jacobian:
:param loader:
:type loader: Pytorch `utils.data.DataLoader`
:param function: A function :math:`f\left(X,Y,Z\\right)` where :math:`X,Y,Z` are minibatchs
returned by the dataloader (Note that in some cases :math:`Y,Z` are not required)
returned by the dataloader (Note that in some cases :math:`Y,Z` are not required). If None,
it defaults to `function = lambda *x: model(x[0])`
:type function: python function
:param n_output: How many output is there for each example of your function. E.g. in 10 class
classification this would probably be 10.
:type n_output: integer
"""
def __init__(self, model, loader, function, n_output=1,
def __init__(self, model, loader, function=None, n_output=1,
centering=False, layer_collection=None):
self.model = model
self.loader = loader
self.handles = []
self.xs = dict()
self.n_output = n_output
self.centering = centering

if function is None:
function = lambda *x: model(x[0])
self.function = function

if layer_collection is None:
Expand Down

0 comments on commit 555aefb

Please sign in to comment.