Code Duplication    Length = 12-15 lines in 2 locations

experiments/attention_models/first_glimpse_model.py 1 location

@@ 135-149 (lines=15) @@
132
        return sampled_l_t, h_t, a_t, wl_grad
133
134
135
    def _output_func(self):
136
        self.x = self.x.reshape((28, 28))
137
        first_l, wf_grad = self._first_glimpse_sensor(self.x)
138
139
        [l_ts, h_ts, a_ts, wl_grads], _ = theano.scan(fn=self._core_network,
140
                         outputs_info=[first_l, self.h0, None, None],
141
                         non_sequences=[self.x],
142
                         n_steps=5)
143
144
        self.positions = l_ts
145
        self.last_decision = T.argmax(a_ts[-1])
146
        wl_grad = T.sum(wl_grads, axis=0) / wl_grads.shape[0]
147
        self.wl_grad = wl_grad
148
        self.wf_grad = wf_grad
149
        return a_ts[-1].reshape((1,10))
150
151
    def _setup_functions(self):
152
        self._relu = build_activation("tanh")

experiments/attention_models/baseline_model.py 1 location

@@ 150-161 (lines=12) @@
147
        return sampled_l_t, h_t, a_t, wl_grad
148
149
150
    def _output_func(self):
151
        self.x = self.x.reshape((28, 28))
152
        [l_ts, h_ts, a_ts, wl_grads], _ = theano.scan(fn=self._core_network,
153
                         outputs_info=[self.l0, self.h0, None, None],
154
                         non_sequences=[self.x],
155
                         n_steps=5)
156
157
        self.positions = l_ts
158
        self.last_decision = T.argmax(a_ts[-1])
159
        wl_grad = T.sum(wl_grads, axis=0) / wl_grads.shape[0]
160
        self.wl_grad = wl_grad
161
        return a_ts[-1].reshape((1,10))
162
163
    def _setup_functions(self):
164
        self._assistive_params = []