Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVGD #1671

Merged
merged 5 commits into from Feb 13, 2017
Merged

SVGD #1671

merged 5 commits into from Feb 13, 2017

Conversation

twiecki
Copy link
Member

@twiecki twiecki commented Jan 14, 2017

No description provided.

@twiecki twiecki changed the base branch from master to 3.1 January 14, 2017 15:51
Copy link
Contributor

@springcoil springcoil left a comment

Choose a reason for hiding this comment

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

This looks fine to me - let's see how the tests behave. (Just saw the WIP).

Needs more tests I imagine, and there might be some errors with the build. Not merging yet obviously.

@twiecki
Copy link
Member Author

twiecki commented Jan 14, 2017

This is still WIP.

@twiecki twiecki added the WIP label Jan 14, 2017
Copy link
Member

@ferrine ferrine left a comment

Choose a reason for hiding this comment

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

I would rather refactor pymc3.variational.updates

class Update(object):

def __init__(self):
self.__dict__.update(locals())
Copy link
Member

Choose a reason for hiding this comment

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

I'm still not satisfied about the current solution.

  1. Here you don't need init at all
  2. locals have self and create circular reference


def __init__(self, lr=0.01, *args, **kwargs):
Update.__init__(self, *args, **kwargs)
self.__dict__.update(locals())
Copy link
Member

Choose a reason for hiding this comment

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

You update dict twice, moreover passing any additional argument will cause an error, but signature allows it (e.g. SGD(foo=1) will fail, but it is not obvious)

Update.__init__(self, *args, **kwargs)
self.__dict__.update(locals())

def __call__(self, p, g):
Copy link
Member

Choose a reason for hiding this comment

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

Current implementation does not handle the case when list of shared variables is passed, moreover dict is better format of return value. The same comments are about other updates.

def __init__(self):
self.__dict__.update(locals())

def __call__(self, params, grads):
Copy link
Member

Choose a reason for hiding this comment

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

Why not computing grads from objective wrt params(potentially list of params) on the fly? That forces user to do unnecessary work
Update method can be just a helper function overriden below. What call will do is computing gradients and creating updates.

Copy link
Member

@ferrine ferrine Jan 17, 2017

Choose a reason for hiding this comment

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

BTW, signature(interface) changes in inherited classes, it must be the same according to OOP style

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

@twiecki I think Lasagne has good and reliable implementation. If they don't mind copy-paste that would be great. Otherwise we should probably change api so that it will be the same as Lasagne's api.

@twiecki twiecki changed the base branch from 3.1 to master January 18, 2017 08:01
@twiecki twiecki changed the title SVGD for 3.1 SVGD Jan 18, 2017
@twiecki
Copy link
Member Author

twiecki commented Feb 4, 2017

@ferrine I added updates.py from lasagne. Not sure it works correctly yet.

@ferrine
Copy link
Member

ferrine commented Feb 7, 2017

Great! We can check it with simple advi problem.
PS what's up with travis?

@ferrine
Copy link
Member

ferrine commented Feb 11, 2017

@twiecki is there any work left? I'm looking forward merging this PR as it will be useful in many cases

Copy link
Member

@ferrine ferrine left a comment

Choose a reason for hiding this comment

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

If there is any work, what about moving updates.py in a separate PR?

@@ -0,0 +1 @@
docs/source/notebooks/
Copy link
Member

Choose a reason for hiding this comment

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

New line

sumkxy = tt.sum(Kxy, axis=1).dimshuffle(0, 'x')
dxkxy = tt.add(dxkxy, tt.mul(X, sumkxy)) / (h ** 2)

return (Kxy, dxkxy)
Copy link
Member

Choose a reason for hiding this comment

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

Redundant parentheses

@twiecki twiecki merged commit fd03291 into master Feb 13, 2017
@twiecki twiecki deleted the svgd3.1 branch February 13, 2017 08:06
@twiecki
Copy link
Member Author

twiecki commented Feb 13, 2017

@ferrine I went ahead and merged to get things moving. I'll address the parentheses thing and add docs in a separate PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants