-
Notifications
You must be signed in to change notification settings - Fork 1
96 cswrapp 85422 torch non parametric #97
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
34b2738
first initial propose non parametric layer
ab18d8d
tf activations
678e584
non parametric: torch layers naming + tf partial layer class + jax fu…
6ecd9d4
Moved bayesian layers list def to layer.py, renamed nonparametric.py …
43c05c7
mypy
68f367f
second option logo + rmd unused fixture
62e8533
specific layers for 1d vs 2d in JAX
cc756c3
CLASS WRAPPERS non parametric & cleaned docstrings & tf seed fixture …
f6bac83
black&flake8
b9d9892
cleaned comments
06badf4
rm comments + rm unused get_external_native_method
23a046b
example with redirected relu and maxpool
lucia-ferrer 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
|
Collaborator
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. Is it possible to adjust the image resolution so that it is at the edge of the content? |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| """JAX activation layer wrappers.""" | ||
|
|
||
| # Standard libraries | ||
| from functools import partial | ||
|
|
||
| # 3pps | ||
| from flax import nnx | ||
|
|
||
|
|
||
| class ReLU: | ||
| """Wrapper for JAX relu.""" | ||
|
|
||
| def __new__(cls, *args, **kwargs): | ||
| return partial(nnx.relu, *args, **kwargs) | ||
|
|
||
|
|
||
| class Sigmoid: | ||
| """Wrapper for JAX sigmoid.""" | ||
|
|
||
| def __new__(cls, *args, **kwargs): | ||
| return partial(nnx.sigmoid, *args, **kwargs) | ||
|
|
||
|
|
||
| class Tanh: | ||
| """Wrapper for JAX tanh.""" | ||
|
|
||
| def __new__(cls, *args, **kwargs): | ||
| return partial(nnx.tanh, *args, **kwargs) | ||
|
|
||
|
|
||
| class GELU: | ||
| """Wrapper for JAX gelu.""" | ||
|
|
||
| def __new__(cls, *args, **kwargs): | ||
| return partial(nnx.gelu, *args, **kwargs) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| """JAX normalization layer wrappers.""" | ||
|
|
||
| # 3pps | ||
| from flax import nnx | ||
|
|
||
|
|
||
| class BatchNorm1d: | ||
| """Wrapper for JAX BatchNorm for 1D inputs.""" | ||
|
|
||
| def __new__(cls, num_features, *args, **kwargs): | ||
| return nnx.BatchNorm(num_features, *args, **kwargs) | ||
|
|
||
|
|
||
| class BatchNorm2d: | ||
| """Wrapper for JAX BatchNorm for 2D inputs.""" | ||
|
|
||
| def __new__(cls, num_features, *args, **kwargs): | ||
| return nnx.BatchNorm(num_features, *args, **kwargs) | ||
|
|
||
|
|
||
| class LayerNorm: | ||
| """Wrapper for JAX LayerNorm.""" | ||
|
|
||
| def __new__(cls, *args, **kwargs): | ||
| return nnx.LayerNorm(*args, **kwargs) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| """JAX pooling layer wrappers.""" | ||
|
|
||
| # Standard libraries | ||
| from functools import partial | ||
|
|
||
| # 3pps | ||
| import flax.nnx as nnx | ||
|
|
||
|
|
||
| class MaxPool1d: | ||
| """Wrapper for JAX max_pool with 1D window.""" | ||
|
|
||
| def __new__(cls, *args, **kwargs): | ||
| return partial(nnx.max_pool, *args, **kwargs) | ||
|
|
||
|
|
||
| class MaxPool2d: | ||
| """Wrapper for JAX max_pool with 2D window.""" | ||
|
|
||
| def __new__(cls, *args, **kwargs): | ||
| return partial(nnx.max_pool, *args, **kwargs) | ||
|
|
||
|
|
||
| class AvgPool1d: | ||
| """Wrapper for JAX avg_pool with 1D window.""" | ||
|
|
||
| def __new__(cls, *args, **kwargs): | ||
| return partial(nnx.avg_pool, *args, **kwargs) | ||
|
|
||
|
|
||
| class AvgPool2d: | ||
| """Wrapper for JAX avg_pool with 2D window.""" | ||
|
|
||
| def __new__(cls, *args, **kwargs): | ||
| return partial(nnx.avg_pool, *args, **kwargs) |
Oops, something went wrong.
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.
Is it possible to adjust the image resolution so that it is at the edge of the content?