예제 #1
0
 def update_lstm(input, hiddens, cells, forget_weights, change_weights,
                                        ingate_weights, outgate_weights):
     """One iteration of an LSTM layer."""
     change  = np.tanh(activations(change_weights, input, hiddens))
     forget  = sigmoid(activations(forget_weights, input, cells, hiddens))
     ingate  = sigmoid(activations(ingate_weights, input, cells, hiddens))
     cells   = cells * forget + ingate * change
     outgate = sigmoid(activations(outgate_weights, input, cells, hiddens))
     hiddens = outgate * np.tanh(cells)
     return hiddens, cells
예제 #2
0
def sigmoid(x):
    return 0.5*(np.tanh(x) + 1.0)   # Output ranges from 0 to 1.
def sigmoid(x):
    return 0.5*(np.tanh(x) + 1)
예제 #4
0
 def nonlinearity(self, x):
     return np.tanh(x)
예제 #5
0
 def update(input, hiddens, change_weights):
     return np.tanh(activations(change_weights, input, hiddens))
예제 #6
0
 def predictions(W_vect, inputs):
     for W, b in unpack_layers(W_vect):
         outputs = np.dot(inputs, W) + b
         inputs = np.tanh(outputs)
     return outputs - logsumexp(outputs, axis=1, keepdims=True)