Let me piggyback on this: I have what looks like the same problem when setting floatX=float16 - only in my case a tensor of type float32 seems to be created somewhere along the way, which causes similar conversion issues. Is there a flag equivalent to 'warn_float64=pdb' that will raise warnings for float32 tensors?
Thanks. On Wednesday, April 19, 2017 at 8:07:16 PM UTC+2, nouiz wrote: > > This error probably come from using the updates parameter of > theano.function(). > > In it, you probably tell Theano that you want the new value of a shared > variable will be of dtype float64, while the original value is float32. > > Adam comment is responsible most of the type for this type of problems. > > You can use the Theano flag warn_float64=pdb to find where the upcast > happen in your code. > > Fred > > On Tue, Apr 18, 2017 at 3:50 AM Adam Becker <[email protected] > <javascript:>> wrote: > >> I encountered something similar a few days ago. Turned out float32 >> divided by int32 gave float64. This is consistent with numpy behavior, a >> bit weird, but true. No sure if related. >> >> In general, traversing the graph (prior to compilation) to find the >> problematic nodes can be helpful. >> >> >> On Sunday, April 16, 2017 at 10:44:49 PM UTC+8, Justin Wilson wrote: >>> >>> I've set THEANO_FLAGS such that floatX=float32 and type casted to float32 >>> throughout the code. Is there a way to set allow_convert = True so that can >>> convert from float64 to float32 for Variable Elemwise{add,no_inplace}.0). >>> I'm new to group and first post so let me know if any additional info would >>> be helpful. >>> >>> >>> ---------------------------------------------------------------------------TypeError >>> Traceback (most recent call >>> last)/home/wilson/anaconda3/lib/python3.5/site-packages/theano/compile/pfunc.py >>> in rebuild_collect_shared(outputs, inputs, replace, updates, >>> rebuild_strict, copy_inputs_over, no_default_updates) 192 >>> update_val = store_into.type.filter_variable(update_val,--> 193 >>> allow_convert=False) 194 >>> except TypeError: >>> /home/wilson/anaconda3/lib/python3.5/site-packages/theano/tensor/type.py in >>> filter_variable(self, other, allow_convert) 234 >>> other=other,--> 235 self=self)) 236 >>> TypeError: Cannot convert Type TensorType(float64, matrix) (of Variable >>> Elemwise{add,no_inplace}.0) into Type TensorType(float32, matrix). You can >>> try to manually convert Elemwise{add,no_inplace}.0 into a >>> TensorType(float32, matrix). >>> >>> During handling of the above exception, another exception occurred: >>> TypeError Traceback (most recent call >>> last)<ipython-input-137-40e9aa6eac9d> in <module>() 78 79 t = >>> time()---> 80 train_g = theano.function([X, Z], cost, updates=g_updates) >>> 81 train_d = theano.function([X, Z], cost, updates=d_updates) 82 gen = >>> theano.function([Z], gX) >>> /home/wilson/anaconda3/lib/python3.5/site-packages/theano/compile/function.py >>> in function(inputs, outputs, mode, updates, givens, no_default_updates, >>> accept_inplace, name, rebuild_strict, allow_input_downcast, profile, >>> on_unused_input) 324 on_unused_input=on_unused_input, >>> 325 profile=profile,--> 326 >>> output_keys=output_keys) 327 # We need to add the flag check_aliased >>> inputs if we have any mutable or 328 # borrowed used defined inputs >>> /home/wilson/anaconda3/lib/python3.5/site-packages/theano/compile/pfunc.py >>> in pfunc(params, outputs, mode, updates, givens, no_default_updates, >>> accept_inplace, name, rebuild_strict, allow_input_downcast, profile, >>> on_unused_input, output_keys) 447 >>> rebuild_strict=rebuild_strict, 448 >>> copy_inputs_over=True,--> 449 >>> no_default_updates=no_default_updates) 450 # extracting the >>> arguments 451 input_variables, cloned_extended_outputs, other_stuff >>> = output_vars >>> /home/wilson/anaconda3/lib/python3.5/site-packages/theano/compile/pfunc.py >>> in rebuild_collect_shared(outputs, inputs, replace, updates, >>> rebuild_strict, copy_inputs_over, no_default_updates) 206 >>> ' function to remove broadcastable dimensions.') 207 --> 208 >>> raise TypeError(err_msg, err_sug) 209 assert >>> update_val.type == store_into.type 210 >>> TypeError: ('An update must have the same type as the original shared >>> variable (shared_var=<TensorType(float32, matrix)>, >>> shared_var.type=TensorType(float32, matrix), >>> update_val=Elemwise{add,no_inplace}.0, update_val.type=TensorType(float64, >>> matrix)).', 'If the difference is related to the broadcast pattern, you can >>> call the tensor.unbroadcast(var, axis_to_unbroadcast[, ...]) function to >>> remove broadcastable dimensions.') >>> >>> -- >> >> --- >> 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 [email protected] <javascript:>. >> 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
