Skip to content

semantics of mem is questionable #896

Description

@ngoodman

i think there may be a bug, or at least questionable choice in the semantics of mem. consider:

Infer({method: 'rejection', samples: 100}, function() {
  var memfn = mem(function(buttons) {return uniform(0,1)})
//   memfn('a');
  
  var inner = Infer({method: 'rejection', samples: 100}, function() {
    var p = memfn('a')
    condition(flip(p))
    return flip(p)
  })
  
  return sample(inner)
})

different results are obtained if the memfn('a'); line is uncommented. it does not seem to me like this should happen.

the semantics we converged on for mem in Church was that all of the random sampling (for all inputs to the function) was to be considered as happening where the memoized function was created, even if the sampling was deferred in practice. in webppl it seems that we are breaking this convention, at least when a memoized function crosses an Infer boundary.

(this bug came to light in probmods/probmods2#56)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions