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

ImportError: cannot import name expand #1

Open
symphea opened this issue Jul 15, 2013 · 1 comment
Open

ImportError: cannot import name expand #1

symphea opened this issue Jul 15, 2013 · 1 comment

Comments

@symphea
Copy link

symphea commented Jul 15, 2013

Hi! I'm on a problem to create bilingual probabilistic language model from learning a big amounts of text with MRNN+HF. Your code seems to be a great fit to the problem. Demo training from the repo is passing fine, but when I tried ContiguousText class as data_object, I get following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "opt/hf.py", line 878, in optimize
    grad, train_losses = self.grad(self.grad_batches, self.X)
  File "opt/hf.py", line 470, in grad
    return self._op(batches, func)
  File "opt/hf.py", line 442, in _op
    d = self.data_object(b)
  File "opt/d/lang/__init__.py", line 201, in __call__
    V_np, O_np, M_np = self.make_V_O_M_expand(seed)
  File "opt/d/lang/__init__.py", line 155, in make_V_O_M_expand
    from pylab import expand
ImportError: cannot import name expand

I have matplotlib1.2.1 installed, but also cannot find pylab.expand in any previous versions nor in release candidate.

Did you use custom version of pylab?

@symphea
Copy link
Author

symphea commented Jul 16, 2013

Well, I get it to work with following 2 fixes.

  1. In opt.d.lang.ContiguousText.make_V_O_M_expand(...):
    changed
    from pylab import expand
    to
    from opt.d.seq.utils import expand
  2. In opt.d.lang.ContiguousText.__init__(...) added 2 lines at the end of the constructor:
from opt.d.seq.utils import zero_one_loss_softmax
self.zero_one_loss = zero_one_loss_softmax

Not sure is it lead to correct training behavior though.

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

1 participant