Mean_std Aquisition function#8
Open
VannshJani wants to merge 8 commits intosustainability-lab:mainfrom
Open
Conversation
Pull Request Test Coverage Report for Build 6698196722
💛 - Coveralls |
patel-zeel
reviewed
Oct 31, 2023
| # Mean-STD acquisition function | ||
| # (n_nets/n_mc_samples, pool_dim, n_classes) logits shape | ||
| pool_num = logits.shape[1] | ||
| assert len(logits.shape) == 3, "logits shape must be 3-Dimensional" |
| # std = torch.std(logits, dim=0) # standard deviation over model parameters, shape (pool_dim, n_classes) | ||
| expectaion_of_squared = torch.mean(ab**2,dim=0) | ||
| expectation_squared = torch.mean(ab,dim=0)**2 | ||
| std = torch.sqrt(expectation_of_squared - expectation_squared) |
Member
There was a problem hiding this comment.
There is a direct method of calculating std in torch. You can use that. Also, logits should be converted to probs before using this method. What is ab?
Author
There was a problem hiding this comment.
I had used the direct method first bhaiya but it does not produce the same result as calculating (E[x**2] - E[x]**2)**0.5. I manually verified this with an example.
|
|
||
|
|
||
| # maximum mean standard deviation aquisition function | ||
| class Mean_std(EnsembleAcquisition,MCAcquisition): |
Member
There was a problem hiding this comment.
Class names follow Camel Case i.e. MeanStd
| expectation_squared = torch.mean(ab,dim=0)**2 | ||
| std = torch.sqrt(expectation_of_squared - expectation_squared) | ||
| scores = torch.mean(std, dim=1) # mean over classes, shape (pool_dim) | ||
| assert len(scores.shape) == 1 and scores.shape[0]==pool_num, "scores shape must be 1-Dimensional and must have length equal to that of pool dataset" |
Member
There was a problem hiding this comment.
This is not needed because, it is done by developer (You). We should have asserts to prevent users from passing invalid arguments.
Author
|
I have updated rest of the changes bhaiya. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implementing mean_std aquisition function using ensemble and MC strategy