Skip to content

Commit 30c09f7

Browse files
author
Mofan Zhou
committed
tf RNN2
1 parent 8c2a625 commit 30c09f7

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

tensorflowTUT/tf20_RNN2/for_you_to_practice.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
n_inputs = 28 # MNIST data input (img shape: 28*28)
2525
n_steps = 28 # time steps
26-
n_hidden_unis = 128 # neurons in hidden layer
26+
n_hidden_units = 128 # neurons in hidden layer
2727
n_classes = 10 # MNIST classes (0-9 digits)
2828

2929
# tf Graph input
@@ -33,13 +33,13 @@
3333
# Define weights
3434
weights = {
3535
# (28, 128)
36-
'in': tf.Variable(tf.random_normal([n_inputs, n_hidden_unis])),
36+
'in': tf.Variable(tf.random_normal([n_inputs, n_hidden_units])),
3737
# (128, 10)
38-
'out': tf.Variable(tf.random_normal([n_hidden_unis, n_classes]))
38+
'out': tf.Variable(tf.random_normal([n_hidden_units, n_classes]))
3939
}
4040
biases = {
4141
# (128, )
42-
'in': tf.Variable(tf.constant(0.1, shape=[n_hidden_unis, ])),
42+
'in': tf.Variable(tf.constant(0.1, shape=[n_hidden_units, ])),
4343
# (10, )
4444
'out': tf.Variable(tf.constant(0.1, shape=[n_classes, ]))
4545
}

tensorflowTUT/tf20_RNN2/full_code.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
n_inputs = 28 # MNIST data input (img shape: 28*28)
2525
n_steps = 28 # time steps
26-
n_hidden_unis = 128 # neurons in hidden layer
26+
n_hidden_units = 128 # neurons in hidden layer
2727
n_classes = 10 # MNIST classes (0-9 digits)
2828

2929
# tf Graph input
@@ -33,13 +33,13 @@
3333
# Define weights
3434
weights = {
3535
# (28, 128)
36-
'in': tf.Variable(tf.random_normal([n_inputs, n_hidden_unis])),
36+
'in': tf.Variable(tf.random_normal([n_inputs, n_hidden_units])),
3737
# (128, 10)
38-
'out': tf.Variable(tf.random_normal([n_hidden_unis, n_classes]))
38+
'out': tf.Variable(tf.random_normal([n_hidden_units, n_classes]))
3939
}
4040
biases = {
4141
# (128, )
42-
'in': tf.Variable(tf.constant(0.1, shape=[n_hidden_unis, ])),
42+
'in': tf.Variable(tf.constant(0.1, shape=[n_hidden_units, ])),
4343
# (10, )
4444
'out': tf.Variable(tf.constant(0.1, shape=[n_classes, ]))
4545
}
@@ -57,13 +57,13 @@ def RNN(X, weights, biases):
5757
# X_in = (128 batch * 28 steps, 128 hidden)
5858
X_in = tf.matmul(X, weights['in']) + biases['in']
5959
# X_in ==> (128 batch, 28 steps, 128 hidden)
60-
X_in = tf.reshape(X_in, [-1, n_steps, n_hidden_unis])
60+
X_in = tf.reshape(X_in, [-1, n_steps, n_hidden_units])
6161

6262
# cell
6363
##########################################
6464

6565
# basic LSTM Cell.
66-
lstm_cell = tf.nn.rnn_cell.BasicLSTMCell(n_hidden_unis, forget_bias=1.0, state_is_tuple=True)
66+
lstm_cell = tf.nn.rnn_cell.BasicLSTMCell(n_hidden_units, forget_bias=1.0, state_is_tuple=True)
6767
# lstm cell is divided into two parts (c_state, m_state)
6868
_init_state = lstm_cell.zero_state(batch_size, dtype=tf.float32)
6969

0 commit comments

Comments
 (0)