Skip to content

Commit 4557314

Browse files
author
Mofan Zhou
committedSep 20, 2016
tf RNN example2
1 parent d191c71 commit 4557314

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed
 

‎tensorflowTUT/tf20_RNN2.2/for_practicing.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
OUTPUT_SIZE = 1
2121
CELL_SIZE = 10
2222
LR = 0.006
23-
BATCH_START_TEST = 0
2423

2524

2625
def get_batch():
@@ -32,7 +31,7 @@ def get_batch():
3231
BATCH_START += TIME_STEPS
3332
# plt.plot(xs[0, :], res[0, :], 'r', xs[0, :], seq[0, :], 'b--')
3433
# plt.show()
35-
# returned seq, res and shape (batch, step, input)
34+
# returned seq, res and xs: shape (batch, step, input)
3635
return [seq[:, :, np.newaxis], res[:, :, np.newaxis], xs]
3736

3837

@@ -72,7 +71,7 @@ def compute_cost(self):
7271
[tf.reshape(self.ys, [-1], name='reshape_target')],
7372
[tf.ones([self.batch_size * self.n_steps], dtype=tf.float32)],
7473
average_across_timesteps=True,
75-
softmax_loss_function=self.msr_error,
74+
softmax_loss_function=self.ms_error,
7675
name='losses'
7776
)
7877
with tf.name_scope('average_cost'):
@@ -82,7 +81,7 @@ def compute_cost(self):
8281
name='average_cost')
8382
tf.scalar_summary('cost', self.cost)
8483

85-
def msr_error(self, y_pre, y_target):
84+
def ms_error(self, y_pre, y_target):
8685
return tf.square(tf.sub(y_pre, y_target))
8786

8887
def _weight_variable(self, shape, name='weights'):

‎tensorflowTUT/tf20_RNN2.2/full_code.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
OUTPUT_SIZE = 1
2121
CELL_SIZE = 10
2222
LR = 0.006
23-
BATCH_START_TEST = 0
2423

2524

2625
def get_batch():
@@ -32,7 +31,7 @@ def get_batch():
3231
BATCH_START += TIME_STEPS
3332
# plt.plot(xs[0, :], res[0, :], 'r', xs[0, :], seq[0, :], 'b--')
3433
# plt.show()
35-
# returned seq, res and shape (batch, step, input)
34+
# returned seq, res and xs: shape (batch, step, input)
3635
return [seq[:, :, np.newaxis], res[:, :, np.newaxis], xs]
3736

3837

@@ -91,7 +90,7 @@ def compute_cost(self):
9190
[tf.reshape(self.ys, [-1], name='reshape_target')],
9291
[tf.ones([self.batch_size * self.n_steps], dtype=tf.float32)],
9392
average_across_timesteps=True,
94-
softmax_loss_function=self.msr_error,
93+
softmax_loss_function=self.ms_error,
9594
name='losses'
9695
)
9796
with tf.name_scope('average_cost'):
@@ -101,7 +100,7 @@ def compute_cost(self):
101100
name='average_cost')
102101
tf.scalar_summary('cost', self.cost)
103102

104-
def msr_error(self, y_pre, y_target):
103+
def ms_error(self, y_pre, y_target):
105104
return tf.square(tf.sub(y_pre, y_target))
106105

107106
def _weight_variable(self, shape, name='weights'):

‎tensorflowTUT/tf20_RNN2/for_you_to_practice.py

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
lr = 0.001
2020
training_iters = 100000
2121
batch_size = 128
22-
display_step = 10
2322

2423
n_inputs = 28 # MNIST data input (img shape: 28*28)
2524
n_steps = 28 # time steps

‎tensorflowTUT/tf20_RNN2/full_code.py

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
lr = 0.001
2323
training_iters = 100000
2424
batch_size = 128
25-
display_step = 10
2625

2726
n_inputs = 28 # MNIST data input (img shape: 28*28)
2827
n_steps = 28 # time steps

0 commit comments

Comments
 (0)
Please sign in to comment.