Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parameter missing example: op_test_vs_pydensecrf #2

Open
JulienFleuret opened this issue Dec 5, 2018 · 2 comments
Open

parameter missing example: op_test_vs_pydensecrf #2

JulienFleuret opened this issue Dec 5, 2018 · 2 comments

Comments

@JulienFleuret
Copy link

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
Copy link

qchenclaire commented Jan 28, 2019

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
Copy link
Author

Thank you very much for your help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants