def neuron_activation(u, previous_state, Vin, Wres):
    """
    Get reservoir response for a signal.
    :param u: input signal. Scalar or vector.
    :param previous_state: previous reservoir state.
    :param Vin: matrix of input reservoir weights.
    :param Wres: matrix of reservoir weights.
    :return: reservoir response.
    """
    input_activation = Vin.dot(u)
    assert input_activation.shape == Vin.shape, 'input activation wrong shape'
    recurrent_activation = previous_state.dot(Wres)  # activation from neurons
    X = sigmoid_af(input_activation + recurrent_activation)  # K x N
    return X
Ejemplo n.º 2
0
def harvest_state(data, Vin, Wres, N, P):
    """
    Harvest reservoir states for input data.
    """
    X = np.zeros((P + 1, N))  # reservoir node's states per input
    # Harvest reservoir states
    for i in xrange(1, P):
        for j in xrange(N):
            input_activation = data[0][i - 1].dot(
                Vin[:, j])  # activation from input
            recurrent_activation = X[i - 1].dot(
                Wres[:, j])  # activation from neurons
            X[i][j] = sigmoid_af(input_activation + recurrent_activation)
    X = np.delete(X, 0, axis=0)  # delete zero state initial vector; P x N
    return X
Ejemplo n.º 3
0
 def __harvest_states(self, data, P, label):
     """
     Harvest reservoir states for input data.
     """
     X = np.zeros((P + 1, self.N))  # reservoir node's states per input
     label = '{0: <13}'.format(label)
     # Harvest reservoir states
     bar = pb.ProgressBar(
         maxval=P,
         widgets=[label, pb.Bar('=', '[', ']'), ' ',
                  pb.Percentage()]).start()
     for i in xrange(1, P):
         for j in xrange(self.N):
             input_activation = data[0][i - 1].dot(
                 self.Vin[:, j])  # activation from input
             recurrent_activation = X[i - 1].dot(
                 self.Wres[:, j])  # activation from neurons
             X[i][j] = sigmoid_af(input_activation + recurrent_activation)
         bar.update(i)
     bar.finish()
     X = np.delete(X, 0, axis=0)  # delete zero state initial vector; P x N
     return X
def __harvest_state(u, previous_state, Vin, Wres):
    input_activation = Vin.dot(u)  # activation from input
    recurrent_activation = previous_state.dot(Wres)  # activation from neurons
    X = sigmoid_af(input_activation + recurrent_activation)
    return X
Ejemplo n.º 5
0
 def __harvest_state(self, u, previous_state):
     input_activation = self.Vin.dot(u)  # activation from input
     recurrent_activation = previous_state.dot(
         self.Wres)  # activation from neurons
     X = sigmoid_af(input_activation + recurrent_activation)
     return X