stan-dev / stan-dev/rstan

Get "infinite gradient" error for code with finite gradient

Open
#275 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
1.1k
Forks
266
Avg merge
2h 56m
Merged PRs (30d)
1

Description

Summary:

I have a small example program that dies with "Rejecting initial value: Gradient evaluated at the initial value is not finite" even though the log probability has a finite gradient everywhere.

Description:

This is illustrated in the same example program as given in issue #274. Referencing the model code given there, I get the error if I keep the assignment to z_lo, but not if I remove the assignment to z_lo. But z_lo never enters into the log probability in any way!

The example may seem contrived, but it is boiled down from a more reasonable example in which z_lo is always computed, but never used in the cases for which lo is infinite.

Reproducible Steps:

See issue #274.

RStan Version:

2.9.0

R Version:

3.2.1

Operating System:

Mac OS X El Capitan

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the example program and model code referenced in issue #274, then reproduce the difference between keeping and removing the z_lo assignment. Trace why the finite-gradient check rejects the initial value despite z_lo not entering the log probability; done means the cause and affected behavior are understood and the error no longer occurs for this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.