-
Notifications
You must be signed in to change notification settings - Fork 705
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
Fix docstrings #22
Merged
Merged
Fix docstrings #22
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
f4525f3
Initial round of docstring refactoring
dd780c8
Add commends to tox
e534f6c
Fix issues with input_size
1263cf2
Stash changes
4637904
Stash changes
238b863
Merge branch 'development' into refactor/ashwin/fix_docstrings
38bf68c
Stash changes
30e5697
Fix docstrings
6049683
Fix breaking changes due to refactor
4808c05
Fix mypy issues
5ea3eee
Stash changes
0b10161
Address PR comments + update docs 📃
a76317f
Merge branch 'development' into refactor/ashwin/fix_docstrings
9929b63
🔧 fix code block
56d02f3
🔧 fix: change Tensor to tensor
4048257
🐞 fix: incorrect division
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,32 +18,37 @@ | |
from typing import Optional | ||
|
||
import torch | ||
from torch import Tensor | ||
|
||
from anomalib.core.model.dynamic_module import DynamicBufferModule | ||
|
||
|
||
class GaussianKDE(DynamicBufferModule): | ||
"""Gaussian Kernel Density Estimation.""" | ||
"""Gaussian Kernel Density Estimation. | ||
|
||
def __init__(self, dataset: Optional[torch.Tensor] = None): | ||
Args: | ||
dataset (Optional[Tensor], optional): Dataset on which to fit the KDE model. Defaults to None. | ||
""" | ||
|
||
def __init__(self, dataset: Optional[Tensor] = None): | ||
super().__init__() | ||
|
||
if dataset is not None: | ||
self.fit(dataset) | ||
|
||
self.register_buffer("bw_transform", torch.Tensor()) | ||
self.register_buffer("dataset", torch.Tensor()) | ||
self.register_buffer("norm", torch.Tensor()) | ||
self.register_buffer("bw_transform", Tensor()) | ||
self.register_buffer("dataset", Tensor()) | ||
self.register_buffer("norm", Tensor()) | ||
|
||
self.bw_transform = torch.Tensor() | ||
self.dataset = torch.Tensor() | ||
self.norm = torch.Tensor() | ||
self.bw_transform = Tensor() | ||
self.dataset = Tensor() | ||
self.norm = Tensor() | ||
|
||
def forward(self, features: torch.Tensor) -> torch.Tensor: | ||
def forward(self, features: Tensor) -> Tensor: | ||
"""Get the KDE estimates from the feature map. | ||
|
||
Args: | ||
features: torch.Tensor: Feature map extracted from the CNN | ||
features (Tensor): Feature map extracted from the CNN | ||
|
||
Returns: KDE Estimates | ||
""" | ||
|
@@ -57,11 +62,11 @@ def forward(self, features: torch.Tensor) -> torch.Tensor: | |
|
||
return estimate | ||
|
||
def fit(self, dataset: torch.Tensor) -> None: | ||
def fit(self, dataset: Tensor) -> None: | ||
"""Fit a KDE model to the input dataset. | ||
|
||
Args: | ||
dataset: torch.Tensor: Input dataset. | ||
dataset (Tensor): Input dataset. | ||
|
||
Returns: | ||
None | ||
|
@@ -88,12 +93,12 @@ def fit(self, dataset: torch.Tensor) -> None: | |
self.norm = norm | ||
|
||
@staticmethod | ||
def cov(tensor: torch.Tensor, bias: Optional[bool] = False) -> torch.Tensor: | ||
def cov(tensor: Tensor, bias: Optional[bool] = False) -> Tensor: | ||
"""Calculate covariance matrix. | ||
|
||
Args: | ||
tensor: torch.Tensor: Input tensor from which covariance matrix is computed. | ||
bias: Optional[bool]: (Default value = False) | ||
tensor (Tensor): Input tensor from which covariance matrix is computed. | ||
bias (Optional[bool]): (Default value = False) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a description for this parameter? |
||
|
||
Returns: | ||
Output covariance matrix. | ||
|
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something's missing between
from
andinto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file
?