From bebdad9c403293d5384fdc03cd23ca5ff869f557 Mon Sep 17 00:00:00 2001
From: Travis CI A 2-D tensor with shape [N x 1], the cross entropy loss. ValueError – 1) the 1st dimension of input and label are not equal; 2) when soft_label == True, and the 2nd dimension of input and label are not equal; 3) when soft_label == False, and the 2nd dimension of label is not 1. ValueError – 1) the 1st dimension of input and label are not equal; 2) when soft_label == True, and the 2nd dimension of input and label are not equal; 3) when soft_label == False, and the 2nd dimension of label is not 1.
-Returns: Raises:
@@ -2020,16 +2020,17 @@ explain how sequence_expand works:Raises:
Lstm unit layer. The equation of a lstm step is:
--\[ \begin{align}\begin{aligned}i_t & = \sigma(W_{x_i}x_{t} + W_{h_i}h_{t-1} + W_{c_i}c_{t-1} + b_i)\\f_t & = \sigma(W_{x_f}x_{t} + W_{h_f}h_{t-1} + W_{c_f}c_{t-1} + b_f)\\c_t & = f_tc_{t-1} + i_t tanh (W_{x_c}x_t+W_{h_c}h_{t-1} + b_c)\\o_t & = \sigma(W_{x_o}x_{t} + W_{h_o}h_{t-1} + W_{c_o}c_t + b_o)\\h_t & = o_t tanh(c_t)\end{aligned}\end{align} \]+\[ \begin{align}\begin{aligned}i_t & = \sigma(W_{x_i}x_{t} + W_{h_i}h_{t-1} + b_i)\\f_t & = \sigma(W_{x_f}x_{t} + W_{h_f}h_{t-1} + b_f)\\c_t & = f_tc_{t-1} + i_t tanh (W_{x_c}x_t + W_{h_c}h_{t-1} + b_c)\\o_t & = \sigma(W_{x_o}x_{t} + W_{h_o}h_{t-1} + b_o)\\h_t & = o_t tanh(c_t)\end{aligned}\end{align} \]
The inputs of lstm unit includes \(x_t\), \(h_{t-1}\) and -\(c_{t-1}\). The implementation separates the linear transformation -and non-linear transformation apart. Here, we take \(i_t\) as an -example. The linear transformation is applied by calling a fc layer and -the equation is:
+The inputs of lstm unit include \(x_t\), \(h_{t-1}\) and +\(c_{t-1}\). The 2nd dimensions of \(h_{t-1}\) and \(c_{t-1}\) +should be same. The implementation separates the linear transformation and +non-linear transformation apart. Here, we take \(i_t\) as an example. +The linear transformation is applied by calling a fc layer and the +equation is:
-\[L_{i_t} = W_{x_i}x_{t} + W_{h_i}h_{t-1} + W_{c_i}c_{t-1} + b_i\]+\[L_{i_t} = W_{x_i}x_{t} + W_{h_i}h_{t-1} + b_i\]
The non-linear transformation is applied by calling lstm_unit_op and the equation is:
@@ -2043,9 +2044,12 @@ equation is:tuple
ValueError
– The ranks of x_t, hidden_t_prev and cell_t_prev not be 2 or the 1st dimensions of x_t, hidden_t_prev and cell_t_prev not be the same.
ValueError
– The ranks of x_t, hidden_t_prev and cell_t_prev not be 2 or the 1st dimensions of x_t, hidden_t_prev and cell_t_prev not be the same or the 2nd dimensions of hidden_t_prev and cell_t_prev not be the same.
Examples
x_t = fluid.layers.fc(input=x_t_data, size=10)
-prev_hidden = fluid.layers.fc(input=prev_hidden_data, size=20)
+prev_hidden = fluid.layers.fc(input=prev_hidden_data, size=30)
prev_cell = fluid.layers.fc(input=prev_cell_data, size=30)
hidden_value, cell_value = fluid.layers.lstm_unit(x_t=x_t,
hidden_t_prev=prev_hidden,
diff --git a/develop/doc_cn/api/v2/fluid/layers.html b/develop/doc_cn/api/v2/fluid/layers.html
index 3b0cbc424e..2d4884ed45 100644
--- a/develop/doc_cn/api/v2/fluid/layers.html
+++ b/develop/doc_cn/api/v2/fluid/layers.html
@@ -1020,7 +1020,7 @@ the given labels as soft labels, default False.
返回: A 2-D tensor with shape [N x 1], the cross entropy loss.
-Raises: ValueError – 1) the 1st dimension of input and label are not equal; 2) when soft_label == True, and the 2nd dimension of input and label are not equal; 3) when soft_label == False, and the 2nd dimension of label is not 1.
+Raises: ValueError – 1) the 1st dimension of input and label are not equal; 2) when soft_label == True, and the 2nd dimension of input and label are not equal; 3) when soft_label == False, and the 2nd dimension of label is not 1.
@@ -2033,16 +2033,17 @@ explain how sequence_expand works:
Lstm unit layer. The equation of a lstm step is:
-\[ \begin{align}\begin{aligned}i_t & = \sigma(W_{x_i}x_{t} + W_{h_i}h_{t-1} + W_{c_i}c_{t-1} + b_i)\\f_t & = \sigma(W_{x_f}x_{t} + W_{h_f}h_{t-1} + W_{c_f}c_{t-1} + b_f)\\c_t & = f_tc_{t-1} + i_t tanh (W_{x_c}x_t+W_{h_c}h_{t-1} + b_c)\\o_t & = \sigma(W_{x_o}x_{t} + W_{h_o}h_{t-1} + W_{c_o}c_t + b_o)\\h_t & = o_t tanh(c_t)\end{aligned}\end{align} \]+\[ \begin{align}\begin{aligned}i_t & = \sigma(W_{x_i}x_{t} + W_{h_i}h_{t-1} + b_i)\\f_t & = \sigma(W_{x_f}x_{t} + W_{h_f}h_{t-1} + b_f)\\c_t & = f_tc_{t-1} + i_t tanh (W_{x_c}x_t + W_{h_c}h_{t-1} + b_c)\\o_t & = \sigma(W_{x_o}x_{t} + W_{h_o}h_{t-1} + b_o)\\h_t & = o_t tanh(c_t)\end{aligned}\end{align} \]
The inputs of lstm unit includes \(x_t\), \(h_{t-1}\) and -\(c_{t-1}\). The implementation separates the linear transformation -and non-linear transformation apart. Here, we take \(i_t\) as an -example. The linear transformation is applied by calling a fc layer and -the equation is:
+The inputs of lstm unit include \(x_t\), \(h_{t-1}\) and +\(c_{t-1}\). The 2nd dimensions of \(h_{t-1}\) and \(c_{t-1}\) +should be same. The implementation separates the linear transformation and +non-linear transformation apart. Here, we take \(i_t\) as an example. +The linear transformation is applied by calling a fc layer and the +equation is:
-\[L_{i_t} = W_{x_i}x_{t} + W_{h_i}h_{t-1} + W_{c_i}c_{t-1} + b_i\]
+\[L_{i_t} = W_{x_i}x_{t} + W_{h_i}h_{t-1} + b_i\]
The non-linear transformation is applied by calling lstm_unit_op and the equation is:
@@ -2056,9 +2057,12 @@ equation is:tuple
ValueError
– The ranks of x_t, hidden_t_prev and cell_t_prev not be 2 or the 1st dimensions of x_t, hidden_t_prev and cell_t_prev not be the same.
ValueError
– The ranks of x_t, hidden_t_prev and cell_t_prev not be 2 or the 1st dimensions of x_t, hidden_t_prev and cell_t_prev not be the same or the 2nd dimensions of hidden_t_prev and cell_t_prev not be the same.
Examples
x_t = fluid.layers.fc(input=x_t_data, size=10)
-prev_hidden = fluid.layers.fc(input=prev_hidden_data, size=20)
+prev_hidden = fluid.layers.fc(input=prev_hidden_data, size=30)
prev_cell = fluid.layers.fc(input=prev_cell_data, size=30)
hidden_value, cell_value = fluid.layers.lstm_unit(x_t=x_t,
hidden_t_prev=prev_hidden,
--
GitLab