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

Make the wrt variable optionally be a pair containing a setter and a getter #1

Open
bayerj opened this issue Feb 27, 2012 · 1 comment

Comments

@bayerj
Copy link
Contributor

bayerj commented Feb 27, 2012

Currently, the signature of optimizers only allows the following:

def __init__(self, wrt, f, ...):
    # ...

However, in some cases, this can lead to problems with the GPU: e.g. theano does not guarantee that changing shared variables (e.g. retrieved with borrow=True) will actually change the real thing in the background.

I therefore suggest to add the following behaviour:

def __init__(self, wrt, f, ...):
    if isinstance(wrt, tuple):
       self._get_wrt, self._set_wrt = wrt
    else:
        # the old methods from below work for the array
        self._wrt = wrt

def _get_wrt(self): return self._wrt
def _set_wrt(self, val): self._wrt[:] = val

The downside is that we will lose some inplace operations. But I am not too sure whether that is actually the case.

@smagt
Copy link

smagt commented Feb 27, 2012

thanks.

On Feb 27, 2012, at 21:50 , Justin Bayer wrote:

Currently, the signature of optimizers only allows the following:

def init(self, wrt, f, ...):
# ...

However, in some cases, this can lead to problems with the GPU: e.g. theano does not guarantee that changing shared variables (e.g. retrieved with borrow=True) will actually change the real thing in the background.

I therefore suggest to add the following behaviour:

def init(self, wrt, f, ...):
if isinstance(wrt, tuple):
self._get_wrt, self._set_wrt = wrt
else:
# the old methods from below work for the array
self._wrt = wrt

def _get_wrt(self): return self._wrt
def _set_wrt(self, val): self._wrt[:] = val

The downside is that we will lose some inplace operations. But I am not too sure whether that is actually the case.


Reply to this email directly or view it on GitHub:
#1

Patrick van der Smagt - DLR, Institute of Robotics and Mechatronics
P.O. Box 1116, 82230 Wessling, Germany - ph +49 8153 281152 - brml.de

@bayerj bayerj closed this as completed Aug 3, 2013
@bayerj bayerj reopened this Aug 3, 2013
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

No branches or pull requests

2 participants