Search code examples
pythontheano

What does allow_input_downcast do in Theano?


I was going through the theano code available here

In line 71 & 73 I'm seeing allow_input_downcast. for example in line 71

train = theano.function(inputs=[X, Y], outputs=cost, updates=updates, allow_input_downcast=True)`

Can you please help me understand the purpose of this attribute?

Thanks in Advance


Solution

  • From the Theano documentation:

    allow_input_downcast (Boolean or None) – True means that the values passed as inputs when calling the function can be silently downcasted to fit the dtype of the corresponding Variable, which may lose precision. False means that it will only be cast to a more general, or precise, type. None (default) is almost like False, but allows downcasting of Python float scalars to floatX.

    For example (maybe not the most illustrative one), this seems to indicate that if your input is of dtype np.float64 and your variable is instantiated to have dtype np.float32, the input is converted to np.float32 when the flag is set to True.