// The log_prob of samples are zero for regular importance sampling (no learned proposals) as it cancels out
current_sample = Sample(address, distribution, value, log_prob=0, controlled=True)
else:
current_sample = Sample(address, distribution, value, log_prob=distribution.log_prob(value), controlled=True)
if _trace_state == TraceState.RECORD_USE_INFERENCE_NETWORK:
previous_sample = None
if _current_trace.length > 0:
After Change
if replace:
if address not in _current_trace_replaced_sample_proposal_distributions:
_current_trace_replaced_sample_proposal_distributions[address] = _current_trace_inference_network.forward_one_time_step(_current_trace_previous_sample, current_sample)
proposal_distribution = _current_trace_replaced_sample_proposal_distributions[address]
else:
proposal_distribution = _current_trace_inference_network.forward_one_time_step(_current_trace_previous_sample, current_sample)
value = proposal_distribution.sample()[0]
current_sample = Sample(address, distribution, value, log_prob=distribution.log_prob(value) - proposal_distribution.log_prob(value), controlled=True)