Пример #1
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple(
         "SyncBatchNorm",
         [
             "num_features",
             "eps",
             "momentum",
             "affine",
             "track_running_stats",
             "process_group",
         ],
     )
     self.params = self.template_fn(
         num_features=Param(name="num_features", default=None),
         eps=FloatParam(name="eps", default=1e-05),
         momentum=FloatParam(name="momentum", default=0.1),
         affine=BinaryParam(name="affine", default=False, true_prob=0.5),
         track_running_stats=BinaryParam(name="track_running_stats",
                                         default=False,
                                         true_prob=0.5),
         process_group=Param(name="process_group", default=None),
     )
     for k, v in kwargs.items():
         getattr(self.params, k).val = v
Пример #2
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple("RReLU", ["lower", "upper", "inplace"])
     self.params = self.template_fn(
         lower=FloatParam(name="lower", default=0.125),
         upper=FloatParam(name="upper", default=0.3333333333333333),
         inplace=BinaryParam(name="inplace", default=False, true_prob=0.5),
     )
     for k, v in kwargs.items():
         getattr(self.params, k).val = v
Пример #3
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple("CrossMapLRN2d",
                                   ["size", "alpha", "beta", "k"])
     self.params = self.template_fn(
         size=Param(name="size", default=None),
         alpha=FloatParam(name="alpha", default=0.0001),
         beta=FloatParam(name="beta", default=0.75),
         k=IntParam(name="k", default=1),
     )
     for k, v in kwargs.items():
         getattr(self.params, k).val = v
Пример #4
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple("Softshrink", ["lambd"])
     self.params = self.template_fn(
         lambd=FloatParam(name="lambd", default=0.5))
     for k, v in kwargs.items():
         getattr(self.params, k).val = v
Пример #5
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple("CosineSimilarity", ["dim", "eps"])
     self.params = self.template_fn(
         dim=IntParam(name="dim", default=1),
         eps=FloatParam(name="eps", default=1e-08),
     )
     for k, v in kwargs.items():
         getattr(self.params, k).val = v
Пример #6
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple("FeatureAlphaDropout", ["p", "inplace"])
     self.params = self.template_fn(
         p=FloatParam(name="p", default=0.5),
         inplace=BinaryParam(name="inplace", default=False, true_prob=0.5),
     )
     for k, v in kwargs.items():
         getattr(self.params, k).val = v
Пример #7
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple("Softplus", ["beta", "threshold"])
     self.params = self.template_fn(
         beta=FloatParam(name="beta", default=1),
         threshold=IntParam(name="threshold", default=20),
     )
     for k, v in kwargs.items():
         getattr(self.params, k).val = v
Пример #8
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple("PReLU", ["num_parameters", "init"])
     self.params = self.template_fn(
         num_parameters=IntParam(name="num_parameters", default=1),
         init=FloatParam(name="init", default=0.25),
     )
     for k, v in kwargs.items():
         getattr(self.params, k).val = v
Пример #9
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple("CELU", ["alpha", "inplace"])
     self.params = self.template_fn(
         alpha=FloatParam(name="alpha", default=1.0),
         inplace=BinaryParam(name="inplace", default=False, true_prob=0.5),
     )
     for k, v in kwargs.items():
         getattr(self.params, k).val = v
Пример #10
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple("LeakyReLU",
                                   ["negative_slope", "inplace"])
     self.params = self.template_fn(
         negative_slope=FloatParam(name="negative_slope", default=0.01),
         inplace=BinaryParam(name="inplace", default=False, true_prob=0.5),
     )
     for k, v in kwargs.items():
         getattr(self.params, k).val = v
Пример #11
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple("PairwiseDistance", ["p", "eps", "keepdim"])
     self.params = self.template_fn(
         p=IntParam(name="p", default=2.0),
         eps=FloatParam(name="eps", default=1e-06),
         keepdim=BinaryParam(name="keepdim", default=False, true_prob=0.5),
     )
     for k, v in kwargs.items():
         getattr(self.params, k).val = v
Пример #12
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple("ConstantPad1d", ["padding", "value"])
     self.params = self.template_fn(
         padding=TupleParam(
             name="padding", size=1, limits=((0,), (0,)), default=(0,)
         ),
         value=FloatParam(name="value", default=0.0),
     )
     for k, v in kwargs.items():
         getattr(self.params, k).val = v
Пример #13
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple(
         "GroupNorm", ["num_groups", "num_channels", "eps", "affine"])
     self.params = self.template_fn(
         num_groups=Param(name="num_groups", default=None),
         num_channels=Param(name="num_channels", default=None),
         eps=FloatParam(name="eps", default=1e-05),
         affine=BinaryParam(name="affine", default=False, true_prob=0.5),
     )
     for k, v in kwargs.items():
         getattr(self.params, k).val = v
Пример #14
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple(
         "LayerNorm", ["normalized_shape", "eps", "elementwise_affine"])
     self.params = self.template_fn(
         normalized_shape=Param(name="normalized_shape", default=None),
         eps=FloatParam(name="eps", default=1e-05),
         elementwise_affine=BinaryParam(name="elementwise_affine",
                                        default=False,
                                        true_prob=0.5),
     )
     for k, v in kwargs.items():
         getattr(self.params, k).val = v
Пример #15
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple(
         "TransformerDecoderLayer",
         ['d_model', 'nhead', 'dim_feedforward', 'dropout', 'activation'])
     self.params = self.template_fn(
         d_model=Param(name="d_model", default=None),
         nhead=Param(name="nhead", default=None),
         dim_feedforward=IntParam(name="dim_feedforward", default=2048),
         dropout=FloatParam(name="dropout", default=0.1),
         activation=ChoiceParam(name="activation",
                                choices=("relu", ),
                                cprobs=(1, ),
                                default="relu"),
     )
     for k, v in kwargs.items():
         getattr(self.params, k).val = v
Пример #16
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple(
         "TripletMarginLoss",
         [
             "margin", "p", "eps", "swap", "size_average", "reduce",
             "reduction"
         ],
     )
     self.params = self.template_fn(
         margin=IntParam(name="margin", default=1.0),
         p=IntParam(name="p", default=2.0),
         eps=FloatParam(name="eps", default=1e-06),
         swap=BinaryParam(name="swap", default=False, true_prob=0.5),
         size_average=Param(name="size_average", default=None),
         reduce=Param(name="reduce", default=None),
         reduction=ChoiceParam(name="reduction",
                               choices=("mean", ),
                               cprobs=(1, ),
                               default="mean"),
     )
     for k, v in kwargs.items():
         getattr(self.params, k).val = v
Пример #17
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple(
         "PoissonNLLLoss",
         [
             "log_input", "full", "size_average", "eps", "reduce",
             "reduction"
         ],
     )
     self.params = self.template_fn(
         log_input=BinaryParam(name="log_input",
                               default=True,
                               true_prob=0.5),
         full=BinaryParam(name="full", default=False, true_prob=0.5),
         size_average=Param(name="size_average", default=None),
         eps=FloatParam(name="eps", default=1e-08),
         reduce=Param(name="reduce", default=None),
         reduction=ChoiceParam(name="reduction",
                               choices=("mean", ),
                               cprobs=(1, ),
                               default="mean"),
     )
     for k, v in kwargs.items():
         getattr(self.params, k).val = v