Closed xand-stapleton closed 1 year ago
This is how I got your example to work:
class TrivialDataset(Dataset):
def __init__(self):
self.data = torch.arange(1, 10, dtype=torch.float32).view(1,9)
def __getitem__(self, index):
return (self.data[index], )
def __len__(self):
return len(self.data)
As of now, it is required that every example generated by the DataLoader is a tuple. It should be fixed in the future.
Thanks for your help. It now works!
I'm trying to use the latest git release of NNGeometry's FIM to find the Fisher metric of my trivial model. As a simple example I create a model which has a single Linear layer, a single training sample, and solves the matrix equation Ax=b, where A is a 3x3 matrix, whilst x, b are 3x1 col. vectors.
Here's my code (it's not meant for anything functional -- it's just to see how these things work):
Now I create a dataloader with a single batch containing the single training sample:
Attempting to compute the Fisher metrics gives a runtime error due to the differentiated tensors not being used. `
RuntimeError: One of the differentiated Tensors appears to not have been used in the graph. Set allow_unused=True if this is the desired behavior.`
I'm at an utter loss as to why this is happening. Is this a bug in NNGeometry (unlikely) or am I doing something extremely stupid (increasingly likely)? Thanks!