Discussion:
[theano-users] theano.tensor.grad produces float64 values for some reason
Nima Mousavi
2015-07-14 17:12:57 UTC
Permalink
Hey there,

I have installed Theano on a mac and added

[global]
floatX = float32

to my .theanorc.

For some reason the grad function produces float64 values though. I'm 100%
sure
that the float64 values are produced by the grad function. After manually
casting
them to float32 my program works again. But, if possible, I'd like to know
the reason.

Thanks your help is appreciated
--
---
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.
Bhavishya
2015-07-14 21:29:54 UTC
Permalink
Take a look at the warn_float64
<http://deeplearning.net/software/theano/library/config.html> flag.
Post by Nima Mousavi
Hey there,
I have installed Theano on a mac and added
[global]
floatX = float32
to my .theanorc.
For some reason the grad function produces float64 values though. I'm 100%
sure
that the float64 values are produced by the grad function. After manually
casting
them to float32 my program works again. But, if possible, I'd like to know
the reason.
Thanks your help is appreciated
--
---
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
2015-07-14 22:20:21 UTC
Permalink
What you describe should not happen. Update to Theano development version
and try again. Maybe it is already fixed.

If not, use the Theano flag warn_float64=True to find where float 64 are
created.

Fred
Post by Nima Mousavi
Hey there,
I have installed Theano on a mac and added
[global]
floatX = float32
to my .theanorc.
For some reason the grad function produces float64 values though. I'm 100%
sure
that the float64 values are produced by the grad function. After manually
casting
them to float32 my program works again. But, if possible, I'd like to know
the reason.
Thanks your help is appreciated
--
---
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.
Daniel Renshaw
2015-07-15 06:53:27 UTC
Permalink
I've encountered similar situations in the past but I think in every case
it could always be tracked down to an unexpected introduction of a
precision hike in my own code which I only noticed via the gradient.

For example, check for operations that involve functions of shapes. Shape
values are always int64s and a binary operation involving a float32 and an
int64 produces a float64.

As already noted, warn_float64 is useful to find cases like this.

Daniel
Post by Frédéric Bastien
What you describe should not happen. Update to Theano development version
and try again. Maybe it is already fixed.
If not, use the Theano flag warn_float64=True to find where float 64 are
created.
Fred
Post by Nima Mousavi
Hey there,
I have installed Theano on a mac and added
[global]
floatX = float32
to my .theanorc.
For some reason the grad function produces float64 values though. I'm
100% sure
that the float64 values are produced by the grad function. After manually
casting
them to float32 my program works again. But, if possible, I'd like to
know the reason.
Thanks your help is appreciated
--
---
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
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.
刘秋志
2017-08-13 06:34:47 UTC
Permalink
Your advice is really helpful.

I mixed int64 and float32 in my code and didn't notice it until reading
your post here.

Thanks a lot.

圚 2015幎7月15日星期䞉 UTC+8䞋午2:54:10Daniel Renshaw写道
Post by Daniel Renshaw
I've encountered similar situations in the past but I think in every case
it could always be tracked down to an unexpected introduction of a
precision hike in my own code which I only noticed via the gradient.
For example, check for operations that involve functions of shapes. Shape
values are always int64s and a binary operation involving a float32 and an
int64 produces a float64.
As already noted, warn_float64 is useful to find cases like this.
Daniel
Post by Frédéric Bastien
What you describe should not happen. Update to Theano development version
and try again. Maybe it is already fixed.
If not, use the Theano flag warn_float64=True to find where float 64 are
created.
Fred
Post by Nima Mousavi
Hey there,
I have installed Theano on a mac and added
[global]
floatX = float32
to my .theanorc.
For some reason the grad function produces float64 values though. I'm
100% sure
that the float64 values are produced by the grad function. After
manually casting
them to float32 my program works again. But, if possible, I'd like to
know the reason.
Thanks your help is appreciated
--
---
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.
--
---
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...