Esempio n. 1
0
 def __init__(self, value, name, log_determinant=None, learnable=False, has_bias=False, is_observed=False, variable_range=geometric_ranges.UnboundedRange(),
              is_policy=False, is_reward=False):
     self._type = "Deterministic node"
     if not isinstance(log_determinant, PartialLink):
         if log_determinant is None:
             log_determinant = torch.tensor(np.zeros((1, 1))).float().to(device)
         var2link(log_determinant)
     ranges = {"value": variable_range,
               "log_determinant": geometric_ranges.UnboundedRange()}
     super().__init__(name, value=value, log_determinant=log_determinant, learnable=learnable, has_bias=has_bias,
                      ranges=ranges, is_observed=is_observed, is_policy=is_policy, is_reward=is_reward)
     self.distribution = distributions.DeterministicDistribution()
Esempio n. 2
0
 def __init__(self,
              value,
              name,
              learnable=False,
              is_observed=False,
              variable_range=geometric_ranges.UnboundedRange()):
     self._type = "Deterministic node"
     ranges = {"value": variable_range}
     super().__init__(name,
                      value=value,
                      learnable=learnable,
                      ranges=ranges,
                      is_observed=is_observed)
     self.distribution = distributions.DeterministicDistribution()
Esempio n. 3
0
 def __init__(self, data, name, learnable=False, is_observed=False):
     self.name = name
     self.distribution = distributions.DeterministicDistribution()
     self._evaluated = False
     self._observed = is_observed
     self.parents = set()
     self.ancestors = set()
     self._type = "Deterministic"
     self.learnable = learnable
     self.link = None
     self._value = coerce_to_dtype(data, is_observed)
     if self.learnable:
         if not is_discrete(data):
             self._value = torch.nn.Parameter(coerce_to_dtype(data, is_observed), requires_grad=True)
             self.link = ParameterModule(self._value) # add to optimizer; opt checks links
         else:
             self.learnable = False
             warnings.warn('Currently discrete parameters are not learnable. Learnable set to False')