Skip to content
This repository has been archived by the owner on Oct 27, 2022. It is now read-only.

ImportError: cannot import name 'toposort' #1

Open
kayhan-batmanghelich opened this issue Dec 2, 2018 · 4 comments
Open

ImportError: cannot import name 'toposort' #1

kayhan-batmanghelich opened this issue Dec 2, 2018 · 4 comments

Comments

@kayhan-batmanghelich
Copy link

Hey guys,

Very nice work!

It seems some of the functions are missing. Here is an example:

     44 from autograd.tracer import Node
---> 45 from autograd.util import toposort
     46 from autograd.util import subvals
     47 from autograd import core

ImportError: cannot import name 'toposort'

@dwrtz
Copy link

dwrtz commented Dec 2, 2018

I was able to make some progress by using the latest from autograd (https://github.com/HIPS/autograd), which now has the toposort function. Unfortunately I still have a problem when trying to run one of the examples:

Traceback (most recent call last):
File ".\kalman_filter.py", line 97, in
app.run(main)
File "C:\ProgramData\Anaconda3\lib\site-packages\absl\app.py", line 300, in run
_run_main(main, args)
File "C:\ProgramData\Anaconda3\lib\site-packages\absl\app.py", line 251, in _run_main
sys.exit(main(argv))
File ".\kalman_filter.py", line 79, in main
marginal = make_marginal_fn()
File ".\kalman_filter.py", line 46, in make_marginal_fn
log_p_x1_y1, 0, SupportTypes.REAL, *([1.] * 4))
File "C:\autoconj\autoconj\conjugacy.py", line 213, in complete_conditional
_trace_and_analyze(log_joint_fun, argnum, *args))
File "C:\autoconj\autoconj\conjugacy.py", line 157, in _trace_and_analyze
graph = make_expr(log_joint_fun, *args)
File "C:\autoconj\autoconj\tracers.py", line 88, in make_expr
used_start_nodes = {n for n in toposort(end_node, lambda n: n.parents)
File "C:\autoconj\autoconj\tracers.py", line 88, in
used_start_nodes = {n for n in toposort(end_node, lambda n: n.parents)
File "C:\autograd\autograd\util.py", line 25, in toposort
if node in child_counts:
TypeError: unhashable type: 'ExprNode'

@dwrtz
Copy link

dwrtz commented Dec 2, 2018

Switching to python 2.7 resolved this for me.

@kayhan-batmanghelich
Copy link
Author

@dwrtz I agree. It resolves some but not all problems. For example, this:

    20 from autograd import grad
     21 from autograd import value_and_grad
---> 22 from autograd import fmap_util
     23
     24 from . import conjugacy

ImportError: cannot import name fmap_util

@mattjj
Copy link
Contributor

mattjj commented Dec 4, 2018

Thanks so much for digging in! Kayhan, good to hear from you!

Looks like you’ve already found this code is currently only Python 2.7 compatible.

The fmap stuff is vestigial (from the fmap-everywhere branch of Autograd, which I meant to remove). I’ll take a look at that when I can.

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

No branches or pull requests

3 participants