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

Cannot supply array of eval_points to EnsembleArray #766

Closed
arvoelke opened this issue Jul 2, 2015 · 3 comments
Closed

Cannot supply array of eval_points to EnsembleArray #766

arvoelke opened this issue Jul 2, 2015 · 3 comments

Comments

@arvoelke
Copy link
Contributor

arvoelke commented Jul 2, 2015

...
  File "c:\users\aaron\ctn\nengo\nengo\networks\ensemblearray.py", line 55, in __init__
    self.config[nengo.Ensemble].update(ens_kwargs)
  File "c:\users\aaron\ctn\nengo\nengo\config.py", line 105, in update
    setattr(self, key, d[key])
  File "c:\users\aaron\ctn\nengo\nengo\config.py", line 56, in __setattr__
    param.validate(self, value)
  File "c:\users\aaron\ctn\nengo\nengo\dists.py", line 336, in validate
    dist = super(DistOrArrayParam, self).validate(instance, dist)
  File "c:\users\aaron\ctn\nengo\nengo\params.py", line 212, in validate
    "distribution instead." % attr)
ValueError: dimensions not yet initialized; cannot determine if shape is correct. Consider using a distribution instead.

Possible solutions?

  • Force people to only use distributions with EnsembleArrays. This seems like an unreasonable limitation to me.

  • Include the number of dimensions before the ensembles are configured, i.e.

    self.config[nengo.Ensemble].dimensions = ens_dimensions
    self.config[nengo.Ensemble].update(ens_kwargs)
    

    But this is hacky because this solution has to be repeated for all similar situations with other networks. Also, it's important to note that you can't just do ens_kwargs['dimensions'] = ens_dimensions otherwise you get undefined behaviour, because it relies on the order of dictionary iteration to update dimensions before eval_points, which may or may not happen depending on the alignment of the sun with Neptune.

  • Create a new StaticDistribution that always iterates through a fixed list, and then cast eval_points arrays to this distribution when the param is set (thus removing DistOrArrayParam)? I think this is a better long-term solution, assuming I'm not overlooking anything.

Note: Add a unit test for this.

@tbekolay tbekolay mentioned this issue Dec 12, 2016
9 tasks
tbekolay added a commit that referenced this issue Mar 29, 2017
This is essentially a no-op distribution that takes a set of
samples and provides them when the `samples` method is called.
It's intended to simplify situations in which a distribution or
samples could be provided by converting samples to a distribution.

The main place this happens is when passing `Ensemble` arguments
to the `EnsembleArray` constructor. Previously, a distribution had
to be provided, since the passed parameters are set as defaults
on the `EnsembleArray` network. Now, any samples passed in are
wrapped in the `Samples` distribution, which makes it possible to
pass in samples. Tests have been added to verify this.

Addresses #691 and #766.
adityagilra pushed a commit to adityagilra/nengo that referenced this issue Jun 21, 2017
This is essentially a no-op distribution that takes a set of
samples and provides them when the `samples` method is called.
It's intended to simplify situations in which a distribution or
samples could be provided by converting samples to a distribution.

The main place this happens is when passing `Ensemble` arguments
to the `EnsembleArray` constructor. Previously, a distribution had
to be provided, since the passed parameters are set as defaults
on the `EnsembleArray` network. Now, any samples passed in are
wrapped in the `Samples` distribution, which makes it possible to
pass in samples. Tests have been added to verify this.

Addresses nengo#691 and nengo#766.
@jgosmann
Copy link
Collaborator

Has this been resolved with the merge of #1233?

@jgosmann
Copy link
Collaborator

jgosmann commented Aug 8, 2017

ping @arvoelke

@arvoelke
Copy link
Contributor Author

arvoelke commented Aug 8, 2017

Yep!

import nengo
import numpy as np
with nengo.networks.EnsembleArray(3, 2, eval_points=np.zeros((3, 1))) as model:
    for ens in model.ensembles:
        print(ens.eval_points)
Samples(samples=array([[ 0.],
       [ 0.],
       [ 0.]]))
Samples(samples=array([[ 0.],
       [ 0.],
       [ 0.]]))

Thanks.

@arvoelke arvoelke closed this as completed Aug 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants