Example #1
0
 def __init__(self):
     ChoiceParam.__init__(
         self,
         name="Activation",
         choices=[Sigmoid(), Tanh(), ReLU(),
                  SELU()],
         cprobs=[i / 4 for i in range(1, 5)],
         is_random=False,
     )
Example #2
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple(
         "EmbeddingBag",
         [
             "num_embeddings",
             "embedding_dim",
             "max_norm",
             "norm_type",
             "scale_grad_by_freq",
             "mode",
             "sparse",
             "_weight",
         ],
     )
     self.params = self.template_fn(
         num_embeddings=IntParam(name="num_embeddings", default=1),
         embedding_dim=IntParam(name="embedding_dim", default=1),
         max_norm=Param(name="max_norm", default=None),
         norm_type=IntParam(name="norm_type", default=2.0),
         scale_grad_by_freq=BinaryParam(name="scale_grad_by_freq",
                                        default=False,
                                        true_prob=0.5),
         mode=ChoiceParam(name="mode",
                          choices=("mean", ),
                          cprobs=(1, ),
                          default="mean"),
         sparse=BinaryParam(name="sparse", default=False, true_prob=0.5),
         _weight=Param(name="_weight", default=None),
     )
     for k, v in kwargs.items():
         getattr(self.params, k).val = v
Example #3
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple(
         "ConvTranspose3d",
         [
             "in_channels",
             "out_channels",
             "kernel_size",
             "stride",
             "padding",
             "output_padding",
             "groups",
             "bias",
             "dilation",
             "padding_mode",
         ],
     )
     self.params = self.template_fn(
         in_channels=IntParam(name="in_channels", default=1),
         out_channels=IntParam(name="out_channels", default=1),
         kernel_size=TupleParam(
             name="kernel_size",
             size=3,
             limits=((1, 1, 1), (1, 1, 1)),
             default=(1, 1, 1),
         ),
         stride=TupleParam(
             name="stride", size=3, limits=((1, 1, 1), (1, 1, 1)), default=(1, 1, 1)
         ),
         padding=TupleParam(
             name="padding", size=3, limits=((0, 0, 0), (0, 0, 0)), default=(0, 0, 0)
         ),
         output_padding=TupleParam(
             name="output_padding",
             size=3,
             limits=((0, 0, 0), (0, 0, 0)),
             default=(0, 0, 0),
         ),
         groups=IntParam(name="groups", default=1),
         bias=BinaryParam(name="bias", default=True, true_prob=0.5),
         dilation=TupleParam(
             name="dilation",
             size=3,
             limits=((1, 1, 1), (1, 1, 1)),
             default=(1, 1, 1),
         ),
         padding_mode=ChoiceParam(
             name="padding_mode", choices=("zeros",), cprobs=(1,), default="zeros"
         ),
     )
     for k, v in kwargs.items():
         getattr(self.params, k).val = v
Example #4
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple("MultiLabelMarginLoss",
                                   ["size_average", "reduce", "reduction"])
     self.params = self.template_fn(
         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
Example #5
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple(
         "RNNCell", ["input_size", "hidden_size", "bias", "nonlinearity"])
     self.params = self.template_fn(
         input_size=IntParam(name="input_size", default=1),
         hidden_size=Param(name="hidden_size", default=None),
         bias=BinaryParam(name="bias", default=True, true_prob=0.5),
         nonlinearity=ChoiceParam(name="nonlinearity",
                                  choices=("tanh", ),
                                  cprobs=(1, ),
                                  default="tanh"),
     )
     for k, v in kwargs.items():
         getattr(self.params, k).val = v
Example #6
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple(
         "Upsample", ["size", "scale_factor", "mode", "align_corners"])
     self.params = self.template_fn(
         size=Param(name="size", default=None),
         scale_factor=IntParam(name="scale_factor", default=1),
         mode=ChoiceParam(name="mode",
                          choices=("nearest", ),
                          cprobs=(1, ),
                          default="nearest"),
         align_corners=Param(name="align_corners", default=None),
     )
     for k, v in kwargs.items():
         getattr(self.params, k).val = v
Example #7
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple("CTCLoss",
                                   ["blank", "reduction", "zero_infinity"])
     self.params = self.template_fn(
         blank=IntParam(name="blank", default=0),
         reduction=ChoiceParam(name="reduction",
                               choices=("mean", ),
                               cprobs=(1, ),
                               default="mean"),
         zero_infinity=BinaryParam(name="zero_infinity",
                                   default=False,
                                   true_prob=0.5),
     )
     for k, v in kwargs.items():
         getattr(self.params, k).val = v
Example #8
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple(
         "CosineEmbeddingLoss",
         ["margin", "size_average", "reduce", "reduction"])
     self.params = self.template_fn(
         margin=IntParam(name="margin", default=0.0),
         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
Example #9
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple(
         "NLLLoss",
         ["weight", "size_average", "ignore_index", "reduce", "reduction"])
     self.params = self.template_fn(
         weight=Param(name="weight", default=None),
         size_average=Param(name="size_average", default=None),
         ignore_index=IntParam(name="ignore_index", default=-100),
         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
Example #10
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
Example #11
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple(
         "BCEWithLogitsLoss",
         ["weight", "size_average", "reduce", "reduction", "pos_weight"],
     )
     self.params = self.template_fn(
         weight=Param(name="weight", default=None),
         size_average=Param(name="size_average", default=None),
         reduce=Param(name="reduce", default=None),
         reduction=ChoiceParam(name="reduction",
                               choices=("mean", ),
                               cprobs=(1, ),
                               default="mean"),
         pos_weight=Param(name="pos_weight", default=None),
     )
     for k, v in kwargs.items():
         getattr(self.params, k).val = v
Example #12
0
 def __init__(self, **kwargs):
     _Factory.__init__(self)
     self.template_fn = namedtuple(
         "MultiMarginLoss",
         ["p", "margin", "weight", "size_average", "reduce", "reduction"],
     )
     self.params = self.template_fn(
         p=IntParam(name="p", default=1),
         margin=IntParam(name="margin", default=1.0),
         weight=Param(name="weight", default=None),
         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
Example #13
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
Example #14
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