Updating DeepSpeech for 0.10 API
This commit is contained in:
parent
78c93711f1
commit
8592093ffc
@ -101,8 +101,7 @@
|
|||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import tensorflow as tf\n",
|
"import tensorflow as tf\n",
|
||||||
"from tensorflow.python.ops.constant_op import constant\n",
|
"from tensorflow.python.framework.constant_op import constant\n",
|
||||||
"from tensorflow.models.rnn import rnn, rnn_cell\n",
|
|
||||||
"import numpy as np"
|
"import numpy as np"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -513,19 +512,19 @@
|
|||||||
" \n",
|
" \n",
|
||||||
" # Define lstm cells with tensorflow\n",
|
" # Define lstm cells with tensorflow\n",
|
||||||
" # Forward direction cell\n",
|
" # Forward direction cell\n",
|
||||||
" lstm_fw_cell = rnn_cell.BasicLSTMCell(n_cell_dim, forget_bias=1.0)\n",
|
" lstm_fw_cell = tf.nn.rnn_cell.BasicLSTMCell(n_cell_dim, forget_bias=1.0)\n",
|
||||||
" # Backward direction cell\n",
|
" # Backward direction cell\n",
|
||||||
" lstm_bw_cell = rnn_cell.BasicLSTMCell(n_cell_dim, forget_bias=1.0)\n",
|
" lstm_bw_cell = tf.nn.rnn_cell.BasicLSTMCell(n_cell_dim, forget_bias=1.0)\n",
|
||||||
" \n",
|
" \n",
|
||||||
" # Split data because rnn cell needs a list of inputs for the BRNN inner loop\n",
|
" # Split data because rnn cell needs a list of inputs for the BRNN inner loop\n",
|
||||||
" layer_3 = tf.split(0, n_steps, layer_3)\n",
|
" layer_3 = tf.split(0, n_steps, layer_3)\n",
|
||||||
" \n",
|
" \n",
|
||||||
" # Get lstm cell output\n",
|
" # Get lstm cell output\n",
|
||||||
" outputs = rnn.bidirectional_rnn(lstm_fw_cell,\n",
|
" outputs = tf.nn.bidirectional_rnn(lstm_fw_cell,\n",
|
||||||
" lstm_bw_cell,\n",
|
" lstm_bw_cell,\n",
|
||||||
" layer_3,\n",
|
" layer_3,\n",
|
||||||
" initial_state_fw=_istate_fw,\n",
|
" initial_state_fw=_istate_fw,\n",
|
||||||
" initial_state_bw=_istate_bw)\n",
|
" initial_state_bw=_istate_bw)\n",
|
||||||
" \n",
|
" \n",
|
||||||
" # Reshape outputs from a list of n_steps tensors each of shape [batch_size, 2*n_cell_dim]\n",
|
" # Reshape outputs from a list of n_steps tensors each of shape [batch_size, 2*n_cell_dim]\n",
|
||||||
" # to a single tensor of shape [n_steps*batch_size, 2*n_cell_dim]\n",
|
" # to a single tensor of shape [n_steps*batch_size, 2*n_cell_dim]\n",
|
||||||
@ -585,9 +584,9 @@
|
|||||||
"```python\n",
|
"```python\n",
|
||||||
" # Define lstm cells with tensorflow\n",
|
" # Define lstm cells with tensorflow\n",
|
||||||
" # Forward direction cell\n",
|
" # Forward direction cell\n",
|
||||||
" lstm_fw_cell = rnn_cell.BasicLSTMCell(n_cell_dim, forget_bias=1.0)\n",
|
" lstm_fw_cell = tf.nn.rnn_cell.BasicLSTMCell(n_cell_dim, forget_bias=1.0)\n",
|
||||||
" # Backward direction cell\n",
|
" # Backward direction cell\n",
|
||||||
" lstm_bw_cell = rnn_cell.BasicLSTMCell(n_cell_dim, forget_bias=1.0)\n",
|
" lstm_bw_cell = tf.nn.rnn_cell.BasicLSTMCell(n_cell_dim, forget_bias=1.0)\n",
|
||||||
"```\n",
|
"```\n",
|
||||||
"both of which have inputs of length `n_cell_dim` and bias `1.0` for the forget gate of the LSTM.\n",
|
"both of which have inputs of length `n_cell_dim` and bias `1.0` for the forget gate of the LSTM.\n",
|
||||||
"\n",
|
"\n",
|
||||||
@ -601,11 +600,11 @@
|
|||||||
"The next line of `BiRNN`\n",
|
"The next line of `BiRNN`\n",
|
||||||
"```python\n",
|
"```python\n",
|
||||||
" # Get lstm cell output\n",
|
" # Get lstm cell output\n",
|
||||||
" outputs = rnn.bidirectional_rnn(lstm_fw_cell,\n",
|
" outputs = tf.nn.bidirectional_rnn(lstm_fw_cell,\n",
|
||||||
" lstm_bw_cell,\n",
|
" lstm_bw_cell,\n",
|
||||||
" layer_3,\n",
|
" layer_3,\n",
|
||||||
" initial_state_fw=_istate_fw,\n",
|
" initial_state_fw=_istate_fw,\n",
|
||||||
" initial_state_bw=_istate_bw)\n",
|
" initial_state_bw=_istate_bw)\n",
|
||||||
"```\n",
|
"```\n",
|
||||||
"feeds `layer_3` to the LSTM BRNN cell and obtains the LSTM BRNN output.\n",
|
"feeds `layer_3` to the LSTM BRNN cell and obtains the LSTM BRNN output.\n",
|
||||||
"\n",
|
"\n",
|
||||||
@ -1224,7 +1223,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 20,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": true
|
"collapsed": true
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user