altavir
10/21/2020, 8:56 AMSymbol
and Expression
. The symbol is just a symbol - some object with a string identity. Two symbols with the same identity are considered to be the same even if they are two different instances. The symbol in general does not store any value. When we need to use a Symbol inside some kmath context (for example different flavors of autodiff), we need to bind this symbol to the context (in autodiff it is done via bind
method). Some symbold could not be bound to a context and binding will throw a runtime exception (in theory it could be done in a type-safe way, but I am not sure I want to do it now). The binding is unavoidable since many operations (like autodiffs) require forward variable declaration.
The second part of the API is the Expression
. Basically it is just a function that takes bindings (Map<Symbol, T>
) and produces a result. In case of Autodiff, Expression solves the problem of forward variable declaration since it allows to do late-binding of Symbols (binding is done when the expression is called, not when it is created). I expect to use the same symbols for fitting API.