예제 #1
0
def learn_step(conn):
    """Update connection matrices

    Args:
        conn (:class:`.Connection`): connection object

    Returns:
        :class:`np.ndarray`: derivative of connections (to use in
            connection update rule)

    ToDo:
        Revise (learning needs to be updated)

    """
    # TODO: test
    e = conn.destination.zparams.e
    zi = conn.source.z
    zj_conj = np.conj(conn.destination.z)  # verify which one should
                                           # be conjugated
    active = np.outer(zi*nl(zi, np.sqrt(e)),
                      zj_conj*nl(zj_conj, np.sqrt(e)))
    return -conn.d*conn.matrix + conn.k*active
예제 #2
0
 def test_nl(self):
     """Test nl(x, gamma) nonlinearity"""
     self.assertEqual(utils.nl(0, 0), 1)
     gamma = 0.5
     self.assertEqual(utils.nl(1, gamma), 1/(1-gamma))
     self.assertRaises(ZeroDivisionError, utils.nl, 1, 1)