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

EigenReporter and VINC algorithm #124

Merged
merged 30 commits into from
Mar 15, 2023
Merged

EigenReporter and VINC algorithm #124

merged 30 commits into from
Mar 15, 2023

Conversation

norabelrose
Copy link
Member

No description provided.

@norabelrose norabelrose marked this pull request as ready for review March 12, 2023 10:40
elk/math_util.py Show resolved Hide resolved
elk/training/ccs_reporter.py Outdated Show resolved Hide resolved
elk/math_util.py Outdated Show resolved Hide resolved
elk/training/eigen_reporter.py Outdated Show resolved Hide resolved
num_heads: The number of reporter heads to fit. In other words, the number
of eigenvectors to compute from the VINC matrix.
"""

inv_weight: float = 5.0
neg_cov_weight: float = 5.0

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to add a var_weight as well, because we might want to set var_weight=0 (the confidence term).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you commit this

Copy link
Collaborator

@lauritowal lauritowal Mar 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's now resolved, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually it looks like it's not

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see it earlier for some reason

elk/training/eigen_reporter.py Outdated Show resolved Hide resolved
elk/training/eigen_reporter.py Outdated Show resolved Hide resolved
LOSSES[name](logit0, logit1, coef) for name, coef in self.loss_dict.items()
)
return assert_type(torch.Tensor, loss)

def reset_parameters(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abstractmethod missing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not missing because EigenReporter doesn't need it

torch.zeros(in_features, in_features, device=device, dtype=dtype),
)
self.register_buffer(
"intracluster_cov",
Copy link
Collaborator

@lauritowal lauritowal Mar 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@norabelrose @AlexTMallen I changed the name of this, since it was "intercluster_cov_M2" before... which was already registered in line 77. The fix prevents the error:

  File "/mnt/ssd-1/nora/miniconda3/lib/python3.10/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/mnt/ssd-1/notodai/walter/elk/elk/training/train.py", line 103, in train_reporter
    reporter = EigenReporter(x0.shape[-1], cfg.net, device=device)
  File "/mnt/ssd-1/notodai/walter/elk/elk/training/eigen_reporter.py", line 74, in __init__
    self.intracluster_cov
  File "/mnt/ssd-1/notodai/walter/elk/.venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1269, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'EigenReporter' object has no attribute 'intracluster_cov'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/mnt/ssd-1/notodai/walter/elk/.venv/bin/elk", line 8, in <module>
    sys.exit(run())
  File "/mnt/ssd-1/notodai/walter/elk/elk/__main__.py", line 57, in run
    train(args.run, args.output)
  File "/mnt/ssd-1/notodai/walter/elk/elk/training/train.py", line 195, in train
    for i, *stats in tqdm(mapper(fn, layers), total=len(layers)):
  File "/mnt/ssd-1/notodai/walter/elk/.venv/lib/python3.10/site-packages/tqdm/std.py", line 1195, in __iter__
    for obj in iterable:
  File "/mnt/ssd-1/nora/miniconda3/lib/python3.10/multiprocessing/pool.py", line 873, in next
    raise value
AttributeError: 'EigenReporter' object has no attribute 'intracluster_cov' 

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks good catch

@norabelrose norabelrose merged commit 026af7a into main Mar 15, 2023
@norabelrose norabelrose deleted the eigen-reporter branch March 15, 2023 22:23
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

Successfully merging this pull request may close these issues.

None yet

4 participants