psycharo-zz / tf-densecrf

DenseCRF in TensorFlow
15 stars 2 forks source link

parameter missing example: op_test_vs_pydensecrf #2

Open JulienFleuret opened 6 years ago

JulienFleuret commented 6 years ago

Hello

When I try to execute the python code from the file "op_test_vs_pydensecrf" I receive an error because an argument in not set in the call of the method:

    q = tf.foldl(lambda prev, it: meanfield_iteration(prev, unaries, 
                 tf.range(0, num_iters), 
                 initializer=q_init,
                 parallel_iterations=32)  )

in the function meanfield_op.

qchenclaire commented 5 years ago

Hello

When I try to execute the python code from the file "op_test_vs_pydensecrf" I receive an error because an argument in not set in the call of the method:

    q = tf.foldl(lambda prev, it: meanfield_iteration(prev, unaries, 
                 tf.range(0, num_iters), 
                 initializer=q_init,
                 parallel_iterations=32)  )

in the function meanfield_op.

I changed the code to `def meanfield_op(unaries, lattice, compat, num_iters): q_init = softmax(-unaries, axis=-1)

def _iter(prev, it):
    return meanfield_iteration(prev, unaries, lattice, compat)

q = tf.foldl(lambda prev, it: _iter(prev, it), 
             tf.range(0, num_iters), 
             initializer=q_init,
             parallel_iterations=32)
return q

And it works. Also you need to add this line inputs = tf.nn.softmax(-unaries, axis = 1) before running the session. Finally you will see the output like "max error tf vs numpy: 1.448670751136305e-07"

JulienFleuret commented 5 years ago

Thank you very much for your help :)