def nll_of_x_given_o(self, input, ordering):
""" Returns the theano graph that computes $-ln p(\bx|o)$.
Parameters
----------
input: 1D vector
One image with shape (nb_channels * images_height * images_width).
ordering: 1D vector of int
List of pixel indices representing the input ordering.
"""
D = int(np.prod(self.image_shape))
mask_o_d = T.zeros((D, D), dtype=theano.config.floatX)
mask_o_d = T.set_subtensor(mask_o_d[T.arange(D), ordering], 1.)
mask_o_lt_d = T.cumsum(mask_o_d, axis=0)
mask_o_lt_d = T.set_subtensor(mask_o_lt_d[1:], mask_o_lt_d[:-1])
mask_o_lt_d = T.set_subtensor(mask_o_lt_d[0, :], 0.)
input = T.tile(input[None, :], (D, 1))
nll = -T.sum(self.lnp_x_o_d_given_x_o_lt_d(input, mask_o_d, mask_o_lt_d))
return nll
评论列表
文章目录