Open nbro opened 4 years ago
For consistency, wouldn't it be better to just use
default_mean_field_normal_fn
to also initialize the prior (by providing default parameters when calling it, or maybe have an alias, but not another function that does the same thing), or am I missing something?
The problem is: if we use default_mean_field_normal_fn
to initialise the prior, the prior will be trainable, which may be undesirable!
default_multivariate_normal_fn
creates a non-trainable Gaussian (that's why it deletes the parameter trainable
). However, the API is really badly designed and inconsistent. There should be only the need for one function that creates either a trainable or non-trainable Gaussian (posterior or prior). There's no need for two functions that do so similar things. You can also have default_non_trainable_normal_prior_fn
, but that should just be an alias for a call to a single function with specific parameters (and not a completely different implementation/function).
The current implementation of
default_multivariate_normal_fn
looks like (excluding doc-strings)If
name
,trainable
andadd_variable_fn
are unused, why do you even require them to be passed as arguments? Furthermore, you initialize thescale
parameter of theNormal
distribution withdtype.as_numpy_dtype(1)
, which is as weird as it can be.Why not simply have a method that returns a Normal initialized with 0s as means and 1s as scales, and require only the shape of that distribution?
Also, why does this function even exist, if you already have
default_mean_field_normal_fn
, which returns a closuredef _fn(dtype, shape, name, trainable, add_variable_fn)
, which thus has the same parameters asdefault_multivariate_normal_fn
and does more or less the same thing (apart from the fact that_fn
uses its parameters to define theloc
andscale
, rather than deleting more than half of them). For consistency, wouldn't it be better to just usedefault_mean_field_normal_fn
to also initialize the prior (by providing default parameters when calling it, or maybe have an alias, but not another function that does the same thing), or am I missing something?