is there an issue with having a string input?

32 views
Skip to first unread message

Alp Kucukelbir

unread,
Nov 16, 2015, 7:55:23 PM11/16/15
to stan development mailing list
hi stan-dev, (especially pystan/rstan folks)

i'm moving forward with the "eta autotuning" stuff for ADVI.

we changed eta to be a string input, so that it would say "automatically tuned" in the header of `output.csv`. (if the user provides a double value for eta, then ADVI checks whether it is valid and skips the autotuning.)

i have some faint recollection of this not being okay for either rstan or pystan.

if it is a problem, what should i default it to? 0 (double)?

cheers
alp

Ben Goodrich

unread,
Nov 16, 2015, 8:11:43 PM11/16/15
to stan development mailing list

I think you can do whatever you want. To date, we don't pass strings from rstan to Stan but that is set to change after N more refactors. Back when I had adaptive ADVI enabled in a branch of rstan, I was passing 0 from rstan but doing an if else on that when calling cmd_advi.run() with a string. You can see the diff here

https://github.com/stan-dev/rstan/commit/5b9c0d242721345e5844cdbb098ef86913dde832

Ben

Alp Kucukelbir

unread,
Nov 17, 2015, 9:17:31 AM11/17/15
to stan...@googlegroups.com
thanks ben!
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "stan development mailing list" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/stan-dev/k432c-ljd5w/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> stan-dev+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Allen B. Riddell

unread,
Nov 17, 2015, 12:45:30 PM11/17/15
to stan...@googlegroups.com
Hi Alp,

With an eye to supporting the widest range of interfaces as possible,
it's probably a good idea to have a fixed type for a parameter. Is eta
going to be a string *or* a double?

Best,

Allen
> --
> You received this message because you are subscribed to the Google Groups "stan development mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-dev+u...@googlegroups.com.

Alp Kucukelbir

unread,
Nov 17, 2015, 1:32:50 PM11/17/15
to stan...@googlegroups.com
hi allen,

i'm open to feedback on this point.

eta used to be a double. it was a parameter that the user provided. we
defaulted to some arbitrary number.

then we discovered that tuning eta has a big effect on convergence
time. so we wrote a heuristic tuning procedure for it.

now, we'd like to default to the automatic tuning procedure. if the
user provides a value for eta, we'd like to check for some conditions
(e.g. is it a positive real value?) and bypass the automatic tuning
procedure.

the way i implemented this was by making eta a string that defaults to
"automatically tuned". this shows up in `output.csv` and it looks
fine. if the user provides a value, i read it in as a string and try
casting it to a double. if this fails, i exit with an appropriate
error.

the alternative is to have eta a double, where some special value
(like eta=0) means that we automatically tune it. this is less obvious
to understand by looking at `output.csv`. but the rest of the code is
cleaner.

what say you?

cheers
alp
> You received this message because you are subscribed to a topic in the Google Groups "stan development mailing list" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-dev/k432c-ljd5w/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to stan-dev+u...@googlegroups.com.

Michael Betancourt

unread,
Nov 17, 2015, 1:47:05 PM11/17/15
to stan...@googlegroups.com
You really need a second argument that engages adaptation.
You can use the is_default() method of the valued arguments
to select out a “special” value, but then you lose that value from
setting eta by hand. Following how the MCMC algorithms are
implemented, treat eta as an _inital_ value and then have a
separate argument that engages adaptation.

Allen B. Riddell

unread,
Nov 17, 2015, 1:51:27 PM11/17/15
to stan...@googlegroups.com
There's another option which is currently in use in RStan and PyStan
(probably Stan too) with some params: you can have eta be a double and
then have a boolean flag, `eta_heuristic` which can default to be True
(in which case eta is ignored).

Bob Carpenter

unread,
Nov 17, 2015, 2:57:15 PM11/17/15
to stan...@googlegroups.com
I'm with Michael on this one --- it follows Allen's intent
to have each variable have a single type and a single default
value and Michael's intent to have them not interact:

eta: initial value
type: positive double
default: some positive double you're using

adapt_eta: whether to adapt eta or not
type: boolean
default: true

Now you can specify one or the other or both and they
don't interfere with each other.

RStan's a little funny on what it allows for inits,
taking either a number, a string representing a number,
a function that maps chain ID to list of inits, or a list of
list of inits.

- Bob

Alp Kucukelbir

unread,
Nov 18, 2015, 9:31:21 AM11/18/15
to stan...@googlegroups.com
ok thanks guys. i implement that.

i should be ready to submit another pull request shortly after we
merge https://github.com/stan-dev/stan/pull/1693
Reply all
Reply to author
Forward
0 new messages