def test_broadcast_grad(): # rng = numpy.random.RandomState(utt.fetch_seed()) x1 = tensor4("x") # x1_data = rng.randn(1, 1, 300, 300) sigma = scalar("sigma") # sigma_data = 20 window_radius = 3 filter_1d = aet.arange(-window_radius, window_radius + 1) filter_1d = filter_1d.astype(aesara.config.floatX) filter_1d = exp(-0.5 * filter_1d ** 2 / sigma ** 2) filter_1d = filter_1d / filter_1d.sum() filter_W = filter_1d.dimshuffle(["x", "x", 0, "x"]) y = conv2d(x1, filter_W, border_mode="full", filter_shape=[1, 1, None, None]) aesara.grad(y.sum(), sigma)
def test_broadcast_grad(): x1 = tensor4("x") sigma = scalar("sigma") window_radius = 3 filter_1d = at.arange(-window_radius, window_radius + 1) filter_1d = filter_1d.astype(aesara.config.floatX) filter_1d = exp(-0.5 * filter_1d**2 / sigma**2) filter_1d = filter_1d / filter_1d.sum() filter_W = filter_1d.dimshuffle(["x", "x", 0, "x"]) y = conv2d(x1, filter_W, border_mode="full", filter_shape=[1, 1, None, None]) # TODO FIXME: Make this a real test and `assert` something aesara.grad(y.sum(), sigma)