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

nengo_spinnaker latest unable to find tps.full_transform #169

Open
Mohinta2892 opened this issue Oct 29, 2019 · 2 comments
Open

nengo_spinnaker latest unable to find tps.full_transform #169

Mohinta2892 opened this issue Oct 29, 2019 · 2 comments

Comments

@Mohinta2892
Copy link

Facing the below issue:

Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/nengo_gui-0.4.5.dev0-py2.7.egg/nengo_gui/page.py", line 488, in build
self.sim = backend.Simulator(self.model)
File "/home/samia/Documents/nengo_spinnaker-master/nengo_spinnaker/simulator.py", line 112, in init
self.model.build(network, **builder_kwargs)
File "/home/samia/Documents/nengo_spinnaker-master/nengo_spinnaker/builder/builder.py", line 211, in build
self.connection_map.insert_and_stack_interposers()
File "/home/samia/Documents/nengo_spinnaker-master/nengo_spinnaker/builder/model.py", line 174, in insert_and_stack_interposers
interposers, cm = self.insert_interposers()
File "/home/samia/Documents/nengo_spinnaker-master/nengo_spinnaker/builder/model.py", line 222, in insert_interposers
trans = tps.full_transform(False, False)
AttributeError: 'object' object has no attribute 'full_transform'

Nengo version being used is 2.8.0

Any help with resolving this issue is much appreciated.

Thanks!

@tcstewar
Copy link
Contributor

Can you post a small version of the model you're trying to run? Does this happen to any nengo model you try to run, or just this one?

@Mohinta2892
Copy link
Author

Mohinta2892 commented Oct 31, 2019

This is the git that I am using: https://github.com/bjkomer/spiking-ratslam/blob/master/ratslam/spinnaker_nengo_posecells_ci.py

It happens with any nengo model I am trying to run. It seems that tps is a EnsembleTransmissionParameters type object and this EnsembleTransmissionParameters in nengo_spinnaker.builder.transmission_parameter has not got any full_transform method.
I assume it calls Transform.full_transform()

However, there is some issue with it.

class EnsembleTransmissionParameters(TransmissionParameters):
"""Parameters describing information transmitted by an ensemble.
Attributes
----------
decoders : ndarray
A matrix describing a decoding of the ensemble (sized N x D).
learning_rule :
Learning rule associated with the decoding.
"""
slots = TransmissionParameters.slots + [
"decoders", "learning_rule"
]

def __init__(self, decoders, transform, learning_rule=None):
    super(EnsembleTransmissionParameters, self).__init__(transform)

    # Copy the decoders into a C-contiguous, read-only array
    self.decoders = np.array(decoders, order='C')
    self.decoders.flags["WRITEABLE"] = False

    # Store the learning rule
    self.learning_rule = learning_rule

def __eq__(self, other):
    # Two parameters are equal only if they are of the same type, both have
    # no learning rule and are equivalent in all other fields.
    return (super(EnsembleTransmissionParameters, self).__eq__(other) and
            np.array_equal(self.decoders, other.decoders) and
            self.learning_rule is None and
            other.learning_rule is None)

def __hash__(self):
    return hash((type(self), self.learning_rule, self._transform,
                 fasthash(self.decoders).hexdigest()))

def concat(self, other):
    """Create new connection parameters which are the result of
    concatenating this connection with others.
    Parameters
    ----------
    other : PassthroughNodeTransmissionParameters
        Connection parameters to add to the end of this connection.
    Returns
    -------
    EnsembleTransmissionParameters or None
        Either a new set of transmission parameters, or None if the
        resulting transform contained no non-zero values.
    """
    # Get the outgoing transformation
    new_transform = self._transform.concat(other._transform)

    # Create a new connection (unless the resulting transform is empty,
    # in which case don't)
    if new_transform is not None:
        return EnsembleTransmissionParameters(
            self.decoders, new_transform, self.learning_rule
        )
    else:
        # The transform consisted entirely of zeros so return None.
        return None

@property
def as_global_inhibition_connection(self):
    """Construct a copy of the connection with the optimisation for global
    inhibition applied.
    """
    assert self.supports_global_inhibition
    transform = self.full_transform(slice_out=False)[0, :]

    return EnsembleTransmissionParameters(
        self.decoders,
        Transform(size_in=self.decoders.shape[0], size_out=1,
                  transform=transform, slice_in=self._transform.slice_in)
    )

@property
def full_decoders(self):
    """Get the matrix corresponding to a combination of the decoders and
    the transform applied by the connection.
    """
    return np.dot(self.full_transform(slice_in=False, slice_out=False),
                  self.decoders)

Thanks.

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