Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion mart/attack/initializer/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@ def initialize_(self, parameter: torch.Tensor) -> None:


class Uniform(Initializer):
def __init__(self, min: int | float, max: int | float):
def __init__(self, min: int | float, max: int | float, round: bool = False):
self.min = min
self.max = max
self.round = round

@torch.no_grad()
def initialize_(self, parameter: torch.Tensor) -> None:
torch.nn.init.uniform_(parameter, self.min, self.max)
if self.round:
parameter.round_()


class UniformLp(Initializer):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
_target_: mart.attack.initializer.Uniform
min: ???
max: ???
round: false
Loading