def renet_layer_lr_noscan(X, rnn1, rnn2, w, h, wp, hp):
list_of_images = []
for i in xrange(h/hp):
# x = X[:,i*hp:(i*hp + hp),:].dimshuffle((2, 0, 1)).flatten().reshape((w/wp, X.shape[0]*wp*hp))
h_tm1 = rnn1.H0
hr_tm1 = rnn2.H0
h1 = []
h2 = []
for j in xrange(w/wp):
x = X[:,i*hp:(i*hp + hp),j*wp:(j*wp + wp)].flatten()
h_t = rnn1.recurrence(x, h_tm1)
h1.append(h_t)
h_tm1 = h_t
jr = w/wp - j - 1
xr = X[:,i*hp:(i*hp + hp),jr*wp:(jr*wp + wp)].flatten()
hr_t = rnn2.recurrence(x, hr_tm1)
h2.append(hr_t)
hr_tm1 = hr_t
img = T.concatenate([h1, h2])
list_of_images.append(img)
return T.stacklists(list_of_images).dimshuffle((1, 0, 2))
评论列表
文章目录