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

Nnls solvers fail when weights=True #1019

Closed
tcstewar opened this issue Apr 21, 2016 · 0 comments
Closed

Nnls solvers fail when weights=True #1019

tcstewar opened this issue Apr 21, 2016 · 0 comments
Labels

Comments

@tcstewar
Copy link
Contributor

The non-negative solvers don't seem to work on full weight matrices. Here's a quick example:

model = nengo.Network()
with model:
    a = nengo.Ensemble(100, 1)
    b = nengo.Ensemble(100, 1)
    nengo.Connection(a, b, solver=nengo.solvers.Nnls(weights=True))
sim = nengo.Simulator(model)

The error is:

---------------------------------------------------------------------------
BuildError                                Traceback (most recent call last)
<ipython-input-22-b1fdc30f942d> in <module>()
----> 1 sim = nengo.Simulator(model)
      2 sim.run(2)

/home/tcstewar/github/nengo/nengo/simulator.pyc in __init__(self, network, dt, seed, model)
    115         if network is not None:
    116             # Build the network into the model
--> 117             self.model.build(network)
    118 
    119         self.model.decoder_cache.shrink()

/home/tcstewar/github/nengo/nengo/builder/builder.pyc in build(self, obj, *args, **kwargs)
     83 
     84     def build(self, obj, *args, **kwargs):
---> 85         return Builder.build(self, obj, *args, **kwargs)
     86 
     87     def add_op(self, op):

/home/tcstewar/github/nengo/nengo/builder/builder.pyc in build(cls, model, obj, *args, **kwargs)
    128                 "Cannot build object of type %r" % obj.__class__.__name__)
    129 
--> 130         return cls.builders[obj_cls](model, obj, *args, **kwargs)

/home/tcstewar/github/nengo/nengo/builder/network.pyc in build_network(model, network)
     68         # TODO: Except perhaps if the connection being learned
     69         # is in a subnetwork?
---> 70         model.build(conn)
     71 
     72     logger.debug("Network step 4: Building probes")

/home/tcstewar/github/nengo/nengo/builder/builder.pyc in build(self, obj, *args, **kwargs)
     83 
     84     def build(self, obj, *args, **kwargs):
---> 85         return Builder.build(self, obj, *args, **kwargs)
     86 
     87     def add_op(self, op):

/home/tcstewar/github/nengo/nengo/builder/builder.pyc in build(cls, model, obj, *args, **kwargs)
    128                 "Cannot build object of type %r" % obj.__class__.__name__)
    129 
--> 130         return cls.builders[obj_cls](model, obj, *args, **kwargs)

/home/tcstewar/github/nengo/nengo/builder/connection.pyc in build_connection(model, conn)
    206                     in_signal,
    207                     signal,
--> 208                     tag="%s.weights_elementwiseinc" % conn))
    209 
    210     # Add operator for filtering

/home/tcstewar/github/nengo/nengo/builder/builder.pyc in add_op(self, op)
     90         signals = SignalDict()
     91         op.init_signals(signals)
---> 92         op.make_step(signals, self.dt, np.random)
     93 
     94     def has_built(self, obj):

/home/tcstewar/github/nengo/nengo/builder/operator.pyc in make_step(self, signals, dt, rng)
    386         A = signals[self.A]
    387         Y = signals[self.Y]
--> 388         reshape = reshape_dot(A, X, Y, self.tag)
    389 
    390         def step_dotinc():

/home/tcstewar/github/nengo/nengo/builder/operator.pyc in reshape_dot(A, X, Y, tag)
    350     if (badshape or incshape != Y.shape) and incshape != ():
    351         raise BuildError("shape mismatch in %s: %s x %s -> %s"
--> 352                          % (tag, A.shape, X.shape, Y.shape))
    353 
    354     # Reshape to handle case when np.dot(A, X) and Y are both scalars

BuildError: shape mismatch in <Connection from <Ensemble (unlabeled) at 0x7fda44dc74d0> to <Ensemble (unlabeled) at 0x7fda44edd610>>.weights_elementwiseinc: (1, 100) x (100,) -> (100,)

If I try it with the standard solvers, it runs fine.

@tcstewar tcstewar added the bug label Apr 21, 2016
hunse added a commit that referenced this issue Apr 22, 2016
- Fixes a bug where Nnls was returning weights of the wrong
  dimensionality when `weights=True` (fixes #1019).
- Also fixes some solvers to be safer and faster in flattening
  the weights they return.
hunse added a commit that referenced this issue Apr 25, 2016
- Fixes a bug where Nnls was returning weights of the wrong
  dimensionality when `weights=True` (fixes #1019).
- Also fixes some solvers to be safer and faster in flattening
  the weights they return.
hunse added a commit that referenced this issue May 30, 2016
- Fixes a bug where Nnls was returning weights of the wrong
  dimensionality when `weights=True` (fixes #1019).
- Also fixes some solvers to be safer and faster in flattening
  the weights they return.
hunse added a commit that referenced this issue May 30, 2016
- Fixes a bug where Nnls was returning weights of the wrong
  dimensionality when `weights=True` (fixes #1019).
- Also fixes some solvers to be safer and faster in flattening
  the weights they return.
hunse added a commit that referenced this issue Jun 10, 2016
- Fixes a bug where Nnls was returning weights of the wrong
  dimensionality when `weights=True` (fixes #1019).
- Also fixes some solvers to be safer and faster in flattening
  the weights they return.
tbekolay pushed a commit that referenced this issue Jun 10, 2016
- Fixes a bug where Nnls was returning weights of the wrong
  dimensionality when `weights=True` (fixes #1019).
- Also fixes some solvers to be safer and faster in flattening
  the weights they return.
tbekolay pushed a commit that referenced this issue Jun 11, 2016
- Fixes a bug where Nnls was returning weights of the wrong
  dimensionality when `weights=True` (fixes #1019).
- Also fixes some solvers to be safer and faster in flattening
  the weights they return.
tbekolay pushed a commit that referenced this issue Jun 11, 2016
- Fixes a bug where Nnls was returning weights of the wrong
  dimensionality when `weights=True` (fixes #1019).
- Also fixes some solvers to be safer and faster in flattening
  the weights they return.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant