Skip to content
This repository was archived by the owner on Jun 14, 2024. It is now read-only.

Changing variable broadcasting for factors #133

Merged
merged 12 commits into from
Nov 23, 2018

Conversation

zhenwendai
Copy link
Contributor

Description of changes:

Implemented the according to the Design Proposal 1.

The changes include:

  • Removed the broadcasting decorators for distributions and changed the implementations of distributions accordingly.
  • Remove the broadcasting decorator for FunctionEvaluation and changed its implementation.
  • Implement the broadcast_to operator to allow users to explicitly broadcast variables.
  • Changed the example notebooks.
  • Updated the model definition design doc.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@zhenwendai zhenwendai added this to the MXFusion v0.3.0 milestone Nov 19, 2018
@codecov-io
Copy link

codecov-io commented Nov 19, 2018

Codecov Report

Merging #133 into develop will decrease coverage by 0.13%.
The diff coverage is 91.8%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #133      +/-   ##
===========================================
- Coverage    85.25%   85.11%   -0.14%     
===========================================
  Files           77       77              
  Lines         4163     3817     -346     
  Branches       731      653      -78     
===========================================
- Hits          3549     3249     -300     
+ Misses         411      375      -36     
+ Partials       203      193      -10
Impacted Files Coverage Δ
mxfusion/util/util.py 57.14% <ø> (+12.27%) ⬆️
mxfusion/components/distributions/normal.py 96.52% <100%> (+1.81%) ⬆️
mxfusion/components/distributions/gp/gp.py 87.5% <100%> (-2.25%) ⬇️
mxfusion/modules/gp_modules/svgp_regression.py 82.48% <100%> (+0.08%) ⬆️
mxfusion/components/distributions/dirichlet.py 88.57% <100%> (-0.32%) ⬇️
mxfusion/components/distributions/gp/cond_gp.py 88.88% <100%> (-2.21%) ⬇️
...fusion/components/functions/function_evaluation.py 98.21% <100%> (+5.35%) ⬆️
mxfusion/components/functions/gluon_func_eval.py 100% <100%> (ø) ⬆️
mxfusion/components/distributions/wishart.py 96.36% <100%> (+3.1%) ⬆️
mxfusion/components/distributions/laplace.py 92.59% <100%> (-0.52%) ⬇️
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e8f8b90...1a23374. Read the comment docs.

@zhenwendai zhenwendai added the enhancement New feature or request label Nov 20, 2018


def broadcast_samples_dict(F, array_dict, num_samples=None):

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring?

@@ -155,7 +89,19 @@ def log_cdf(self, F=None, **kwargs):
"""
raise NotImplementedError

def draw_samples(self, rv_shape, num_samples=1, F=None, **kwargs):
def draw_samples(self, F, variables, num_samples=1, targets=None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring? As above with the variable replacement comment?

replicant.broadcastable = self.broadcastable
return replicant

def eval(self, F, variables, always_return_tuple=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring? Explaining what this function does with samples in particular thanks.



def broadcast_to(data, shape):
"""The broadcast_to operator"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you expand this operator's docstring a bit?
Maybe even include a small example/typical usage like in the docs:

m.x.set_prior(Gaussian(mean=broadcast_to(array([0]), m.x.shape),
                       variance=broadcast_to(array([1]), m.x.shape)))

@meissnereric meissnereric merged commit 82e7120 into amzn:develop Nov 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants