Discussion:
[theano-users] Using theano.tensor.repeat with repeats.ndim == 1
Kristjan Arumae
2018-05-03 19:24:04 UTC
Permalink
An example of what I am doing:

Here m is an fmatrix, and v is an ivector

out = T.repeat(m, v, axis=0)

The forward pass works fine, but there is no gradient code implemented.

This works fine when both inputs are vectors but not as above.

I am not familiar with theano enough to fill in the missing code in grad()
for class RepeatOp(). Does anyone have suggestions as to a workaround? I
have not found anything even remotely helpful so far.
I've tried using tile with scan, but to no end.

Thanks.
--
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Pascal Lamblin
2018-05-03 20:03:13 UTC
Permalink
Does it work with two matrices?
If so, you can try to use dimshuffle to make v a "row" instead of a
"vector".
Post by Kristjan Arumae
Here m is an fmatrix, and v is an ivector
out = T.repeat(m, v, axis=0)
The forward pass works fine, but there is no gradient code implemented.
This works fine when both inputs are vectors but not as above.
I am not familiar with theano enough to fill in the missing code in
grad() for class RepeatOp().  Does anyone have suggestions as to a
workaround?  I have not found anything even remotely helpful so far.
I've tried using tile with scan, but to no end.
Thanks.
--
---
You received this message because you are subscribed to the Google
Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send
For more options, visit https://groups.google.com/d/optout.
--
Pascal Lamblin
--
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Kristjan Arumae
2018-05-03 22:01:35 UTC
Permalink
No, it only works with two vectors. 2 Matrixes is not supported in numpy
either I don't think, since it is likely to mess up the output shape.
Post by Pascal Lamblin
Does it work with two matrices?
If so, you can try to use dimshuffle to make v a "row" instead of a
"vector".
Post by Kristjan Arumae
Here m is an fmatrix, and v is an ivector
out = T.repeat(m, v, axis=0)
The forward pass works fine, but there is no gradient code implemented.
This works fine when both inputs are vectors but not as above.
I am not familiar with theano enough to fill in the missing code in
grad() for class RepeatOp(). Does anyone have suggestions as to a
workaround? I have not found anything even remotely helpful so far.
I've tried using tile with scan, but to no end.
Thanks.
--
---
You received this message because you are subscribed to the Google
Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send
For more options, visit https://groups.google.com/d/optout.
--
Pascal Lamblin
--
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Pascal Lamblin
2018-05-03 23:02:12 UTC
Permalink
Oh, right.

Then, I don't think it will be implemented.
And I don't think RepeatOp is optimized to use the GPU anyway.


Sorry about that
No, it only works with two vectors.  2 Matrixes is not supported in
numpy either I don't think, since it is likely to mess up the output shape.
Does it work with two matrices?
If so, you can try to use dimshuffle to make v a "row" instead of a
"vector".
Post by Kristjan Arumae
Here m is an fmatrix, and v is an ivector
out = T.repeat(m, v, axis=0)
The forward pass works fine, but there is no gradient code
implemented.
Post by Kristjan Arumae
This works fine when both inputs are vectors but not as above.
I am not familiar with theano enough to fill in the missing code in
grad() for class RepeatOp().  Does anyone have suggestions as to a
workaround?  I have not found anything even remotely helpful so far.
I've tried using tile with scan, but to no end.
Thanks.
--
---
You received this message because you are subscribed to the Google
Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it,
send
Post by Kristjan Arumae
For more options, visit https://groups.google.com/d/optout
<https://groups.google.com/d/optout>.
--
Pascal Lamblin
--
---
You received this message because you are subscribed to the Google
Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send
For more options, visit https://groups.google.com/d/optout.
--
Pascal Lamblin
--
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Frédéric Bastien
2018-05-04 12:45:06 UTC
Permalink
You can try to implement it with tensor.alloc() and set_subtensor with
broadcasting.

this will work with gradient and on the GPU.
Post by Pascal Lamblin
Oh, right.
Then, I don't think it will be implemented.
And I don't think RepeatOp is optimized to use the GPU anyway.
Sorry about that
Post by Kristjan Arumae
No, it only works with two vectors. 2 Matrixes is not supported in
numpy either I don't think, since it is likely to mess up the output
shape.
Post by Kristjan Arumae
Does it work with two matrices?
If so, you can try to use dimshuffle to make v a "row" instead of a
"vector".
Post by Kristjan Arumae
Here m is an fmatrix, and v is an ivector
out = T.repeat(m, v, axis=0)
The forward pass works fine, but there is no gradient code
implemented.
Post by Kristjan Arumae
This works fine when both inputs are vectors but not as above.
I am not familiar with theano enough to fill in the missing code
in
Post by Kristjan Arumae
Post by Kristjan Arumae
grad() for class RepeatOp(). Does anyone have suggestions as to a
workaround? I have not found anything even remotely helpful so
far.
Post by Kristjan Arumae
Post by Kristjan Arumae
I've tried using tile with scan, but to no end.
Thanks.
--
---
You received this message because you are subscribed to the Google
Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it,
send
Post by Kristjan Arumae
For more options, visit https://groups.google.com/d/optout
<https://groups.google.com/d/optout>.
--
Pascal Lamblin
--
---
You received this message because you are subscribed to the Google
Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send
For more options, visit https://groups.google.com/d/optout.
--
Pascal Lamblin
--
---
You received this message because you are subscribed to the Google Groups
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...