示例#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))
 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)