From 3bf0f7706ace5a8caa9d91a65a8967c2cedbc00f Mon Sep 17 00:00:00 2001 From: zhlicen Date: Wed, 7 Mar 2018 14:28:06 +0800 Subject: [PATCH 1/3] fix the group_index issue --- models/clockwork_rnn.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/models/clockwork_rnn.py b/models/clockwork_rnn.py index b72e53a..5ddaef2 100644 --- a/models/clockwork_rnn.py +++ b/models/clockwork_rnn.py @@ -12,7 +12,7 @@ class ClockworkRNN(object): each processing inputs at its own temporal granularity, making computations only at its prescribed clock rate. Rather than making the standard RNN models more complex, CW-RNN reduces the number of RNN parameters, improves the performance significantly in the tasks tested, and speeds up the network evaluation - + ''' @@ -26,6 +26,9 @@ def __init__(self, config): # divided over the higher frequency groups. assert self.config.num_hidden % len(self.config.periods) == 0 + # The size of each group(number of neuron of each Group) + self.group_size = self.config.num_hidden / len(self.config.periods) + # Global training step self.global_step = tf.Variable(0, name='global_step', trainable=False) @@ -102,6 +105,9 @@ def _build_model(self): if time_step % self.clockwork_periods[i] == 0: group_index = i+1 # note the +1 + # the real index of group in matrix + group_index = self.group_size * group_index + # Compute (W_I*x_t + b_I) WI_x = tf.matmul(x_list[time_step], tf.slice(self.input_W, [0, 0], [-1, group_index])) WI_x = tf.nn.bias_add(WI_x, tf.slice(self.input_b, [0], [group_index]), name="WI_x") From eab4a02dca9bbac40933527427c347949adb8ddb Mon Sep 17 00:00:00 2001 From: HANG ZHOU Date: Wed, 7 Mar 2018 15:36:32 +0800 Subject: [PATCH 2/3] Update clockwork_rnn.py --- models/clockwork_rnn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/clockwork_rnn.py b/models/clockwork_rnn.py index 5ddaef2..99857c2 100644 --- a/models/clockwork_rnn.py +++ b/models/clockwork_rnn.py @@ -27,7 +27,7 @@ def __init__(self, config): assert self.config.num_hidden % len(self.config.periods) == 0 # The size of each group(number of neuron of each Group) - self.group_size = self.config.num_hidden / len(self.config.periods) + self.group_size = self.config.num_hidden // len(self.config.periods) # Global training step self.global_step = tf.Variable(0, name='global_step', trainable=False) @@ -209,4 +209,4 @@ def _build_summary_ops(self): # Combine the training summaries with the gradient summaries self.train_summary_op = tf.summary.merge( - [training_summaries, self.gradient_summaries_merged]) \ No newline at end of file + [training_summaries, self.gradient_summaries_merged]) From 9c06968a15cf9f4ba23054a0ebbd040c058f43e7 Mon Sep 17 00:00:00 2001 From: HANG ZHOU Date: Wed, 7 Mar 2018 15:39:32 +0800 Subject: [PATCH 3/3] Update clockwork_rnn.py --- models/clockwork_rnn.py | 1 - 1 file changed, 1 deletion(-) diff --git a/models/clockwork_rnn.py b/models/clockwork_rnn.py index 99857c2..8bb08d5 100644 --- a/models/clockwork_rnn.py +++ b/models/clockwork_rnn.py @@ -12,7 +12,6 @@ class ClockworkRNN(object): each processing inputs at its own temporal granularity, making computations only at its prescribed clock rate. Rather than making the standard RNN models more complex, CW-RNN reduces the number of RNN parameters, improves the performance significantly in the tasks tested, and speeds up the network evaluation - '''