def to_link(self): args = self.to_chainer_args() del args["use_weightnorm"] # mean if hasattr(self, "_initialW_mean"): args["initialW"] = getattr(self, "_initialW_mean") if self.use_weightnorm: layer_mean = weightnorm.Linear(**args) else: layer_mean = chainer.links.Linear(**args) # ln_var if hasattr(self, "_initialW_ln_var"): args["initialW"] = getattr(self, "_initialW_ln_var") if self.use_weightnorm: layer_ln_var = weightnorm.Linear(**args) else: layer_ln_var = chainer.links.Linear(**args) return links.Gaussian(layer_mean, layer_ln_var)
def to_link(self): args = self.to_chainer_args() del args["use_weightnorm"] if self.use_weightnorm: if hasattr(self, "_initialW"): args["initialV"] = self._initialW return weightnorm.Linear(**args) if hasattr(self, "_initialW"): args["initialW"] = self._initialW return chainer.links.Linear(**args)
def to_link(self): link = links.Merge() for i in xrange(self.num_inputs): args = self.to_chainer_args() del args["use_weightnorm"] del args["num_inputs"] if self.use_weightnorm: if hasattr(self, "_initialW"): args["initialV"] = self._initialW merge_layer = weightnorm.Linear(None, **args) else: if hasattr(self, "_initialW_%d" % i): args["initialW"] = getattr(self, "_initialW_%d" % i) merge_layer = chainer.links.Linear(None, **args) link.append_layer(merge_layer) return link