'Testing whether a LIF() neuron has a recurrent synaptic connection with weight +2 in Intel Lava-nc?

Question

How could one test whether an arbitrary incoming LIF() neuron has a recurrent synaptic connection with weight +2 in the Lava neuromorphic computing platform provided by Intel?

MWE

def two_lif_neurons():
    # Instantiate Lava processes to build network
    from lava.proc.dense.process import Dense
    from lava.proc.lif.process import LIF

    lif1 = LIF(u=0, du=3, dv=0, bias=2)
    dense = create_weighted_synapse(w=+2)
    lif2 = LIF()

    # Connect processes via their directional input and output ports
    lif1.out_ports.s_out.connect(dense.in_ports.s_in)
    dense.out_ports.a_out.connect(lif2.in_ports.a_in)

    # Create recurrent synaptic connection for lif2 neuron.
    lif2.out_ports.s_out.connect(dense.in_ports.s_in)
    dense.out_ports.a_out.connect(lif2.in_ports.a_in)

    return lif1,lif2

def create_weighted_synapse(w):
    """
    Creates a weighted synapse between neuron a and neuron b.
    """
    shape = (1, 1)
    # weights = np.random.randint(100, size=shape)
    weights = [[w]]  # Needs to be this shape for a 1-1 neuron connection.
    weight_exp = 2
    num_weight_bits = 7
    sign_mode = 1

    dense = Dense(
        shape=shape,
        weights=weights,
        weight_exp=weight_exp,
        num_weight_bits=num_weight_bits,
        sign_mode=sign_mode,
    )
    return dense

In this MWE one would expect the lif2 neuron to have a recurrent synaptic connection (to itself, meaning it self-inhibits). I have not yet determined how to test this when one retrieves an arbitrary incoming neuron in another function.

Related code.

I thought the following code that actually generates the synaptic connection could perhaps be used. For example by walking through the in- and output ports of the neuron. Followed by verification of whether the neuron on the other end of the outgoing synaptic connection is indeed the same neuron from which the outgoing port comes:

lif2.out_ports.s_out.connect(dense.in_ports.s_in)
dense.out_ports.a_out.connect(lif2.in_ports.a_in)

However, I did not yet determine how to do this.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source