Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add inverse option #305

Open
charlesmartin14 opened this issue Feb 24, 2024 · 2 comments
Open

add inverse option #305

charlesmartin14 opened this issue Feb 24, 2024 · 2 comments

Comments

@charlesmartin14
Copy link
Member

To support the doubel descent example

@charlesmartin14
Copy link
Member Author

Option added in version 0.7.4.8
Still needs unit tests

@dexterdev
Copy link

TypeError: analyze() got an unexpected keyword argument 'inverse'

I am using the code below. It gave invere error!

import numpy as np
import weightwatcher as ww
X_train = np.random.normal(0, 1, (128, 128))

import torch
import torch.nn as nn

class SingleLayerModel(nn.Module):
    def __init__(self, weights):
        super(SingleLayerModel, self).__init__()

        # Infer dimensions from weights
        output_dim, input_dim = weights.shape

        # Initialize the linear layer without bias
        self.linear = nn.Linear(in_features=input_dim, out_features=output_dim, bias=False)

        # Set custom weights
        self.linear.weight = nn.Parameter(torch.tensor(weights, dtype=torch.float))

    def forward(self, x):
        # Forward pass through the linear layer
        return self.linear(x)

model = SingleLayerModel(weights=X_train)
watcher = ww.WeightWatcher(model=model)
details = watcher.analyze(inverse=True, plot=True, detX=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants