Reputation: 11
I am replacing the tensor flow Python code with boost Python C++ code.
The code that runs in Python does not run in Boost Python.
I am creating the mnist example, but the softmax_cross_entropy
function is strange.
In Python:
loss_op = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits_v2(labels=label, logits=logit))
In Boost Python:
py::object loss_op = py::eval("tf.nn.softmax_cross_entropy_with_logits_v2(labels='label_', logits='logit')", main_namespace);
The variables being used, label_
and logit
, are of type float32.
Tensor("Placeholder_1:0", shape=(?, 10), dtype=float32)
Tensor("add_3:0", shape=(?, 10), dtype=float32)
Boost Python shows this error:
File "<string>", line 1, in <module>
File "C:\ProgramData\Anaconda3\envs\tf35-gpu\lib\site-packages\tensorflow\python\ops\nn_ops.py", line 1872, in softmax_cross_entropy_with_logits_v2
precise_logits = _flatten_outer_dims(precise_logits)
File "C:\ProgramData\Anaconda3\envs\tf35-gpu\lib\site-packages\tensorflow\python\ops\nn_ops.py", line 1628, in _flatten_outer_dims
output_shape = [product, shape[-1]]
IndexError: list index out of range
How can I fix this?
Upvotes: 0
Views: 209
Reputation: 91
I don't think it is an error of boostpython, it is more like python index issue. Maybe you should check
output_shape = [product, shape[-1]]
to see if the -1 should be out side the bracket?
Upvotes: 1