About Me



My photo

I helped create Google Cardboard and Google Earth VR. Current interests include virtual reality, machine learning, and Bitcoin.
TwitterFacebookLinkedinGithub


2017-04-19

Tensorflow tidbit: incompatible with expected float_ref

'x' was passed float from 'y:0' incompatible with expected float_ref

This means that a node in your graph expected to get a variable, but was given a constant instead. This is a message you might see when trying to freeze a graph using graph_util.convert_variables_to_constants. You probably need to add 'y' to the variable_names_blacklist parameter when calling graph_util.convert_variables_to_constants so that it doesn't get converted into a constant. Or, if you're sure you want 'y' to be a constant then you'll need to figure out why your graph contains 'x' that expects it to be a variable; perhaps 'x' can be removed.

Tensorflow tidbit: What's up with :0 in the names of my variables?

tl;dr replace t.name with t.op.name to get rid of the :0

When getting the names of things in Tensorflow I've sometimes been confused by the difference between "x" and "x:0". It turns out that "x:0" is the name of a Tensor object, while "x" is the name of the op that generates it (such as Add or MatMul).

If you have a Tensor object t and you say t.name, you will get a name with ":0" at the end. If you want the name without ":0", don't just try to use string processing to remove the ":0"! Instead, you can access the op related to the Tensor with the "op" member variable, so you can get the name you want with t.op.name.

If instead you have an operation my_op and you want the name of its output tensor, you can say my_op.outputs[0].name.