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

to support variable length argument in cgt.dimshuffle #27

Open
avostryakov opened this issue Sep 15, 2015 · 3 comments
Open

to support variable length argument in cgt.dimshuffle #27

avostryakov opened this issue Sep 15, 2015 · 3 comments

Comments

@avostryakov
Copy link

Theano support: tensor.dimshuffle('x', 0, ...) together with tensor.dimshuffle(['x', 0, ...]). I think it is a good idea to support both syntacsis in cgt because theano-people use both.

@bstadie
Copy link
Contributor

bstadie commented Sep 15, 2015

We will add this functionality in the next little while.

If you can't wait, dimshuffle is entirely contained in cgt.api. Adding this feature would amount to adding a check for a tuple and converting it to a list at the beginning of the function.

@f0k
Copy link

f0k commented Sep 15, 2015

Adding this feature would amount to adding a check for a tuple and converting it to a list at the beginning of the function.

Not quite. It would need changing dimshuffle in core.py from:

    def dimshuffle(self, pattern):
        "see cgt.dimshuffle"
        return cgt.dimshuffle(self, pattern)

to

    def dimshuffle(self, *pattern):
        "see cgt.dimshuffle"
        if len(pattern) == 1 and isinstance(pattern[0], list):
            pattern = pattern[0]
        return cgt.dimshuffle(self, pattern)

Alternatively, you could have Node.dimshuffle pass on *pattern unchanged and modify cgt.dimshuffle to take an argument list and check whether it's a single argument of type list as above. Note that you won't be able to add any positional arguments to dimshuffle in future if you go that route.

@bstadie
Copy link
Contributor

bstadie commented Sep 15, 2015

Ah right. Forgot about modifying the shortcut in core.py. In any case this is a trivial thing to implement.

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

3 participants