RxInfer.jl icon indicating copy to clipboard operation
RxInfer.jl copied to clipboard

`PointMass` constraint combined with BP breaks BFE computation

Open bartvanerp opened this issue 1 year ago • 0 comments

The PointMass constraint without a mean-field factorization breaks the BFE computation. I think this issue is related to #32.

Minimal working examples:

Works fine

@model function test_model()

	# controls
	y = datavar(Float64)

	# prior on state
	u ~ NormalMeanVariance(0, 1)
	z ~ NormalMeanVariance(u, 1)
	y ~ NormalMeanVariance(z, 1)
	
end;
@constraints function test_constraints() 
	q(u, z) = q(u)q(z)
	q(u) :: PointMass
end;
test_results = inference(
	model 			= test_model(),
	data  			= ( y = 1.0, ),
	constraints 	= test_constraints(),
	free_energy     = true,
	initmarginals = (u = PointMass(0), z = Normal(0,1)),
)

Error: Failed to compute the final Bethe Free Energy value. The result is Inf after subtracting PointMass entropies.

@model function test_model()

	# controls
	y = datavar(Float64)

	# prior on state
	u ~ NormalMeanVariance(0, 1)
	z ~ NormalMeanVariance(u, 1)
	y ~ NormalMeanVariance(z, 1)
	
end;
@constraints function test_constraints() 
	q(u) :: PointMass
end;
test_results = inference(
	model 			= test_model(),
	data  			= ( y = 1.0, ),
	constraints 	= test_constraints(),
	free_energy     = true,
)

Returns NaN (Invalid release! call on ScoreActor. The current frame has not been fully specified)

@model function test_model()

	# controls
	y = datavar(Float64)

	# prior on state
	u ~ NormalMeanVariance(0, 1)
	y ~ NormalMeanVariance(u, 1)
	
end;
@constraints function test_constraints() 
	q(u) :: PointMass
end;
test_results = inference(
	model 			= test_model(),
	data  			= ( y = 1.0, ),
	constraints 	= test_constraints(),
	free_energy     = true,
)

bartvanerp avatar Jul 26 '23 09:07 bartvanerp