greta-dev / greta-dev/greta

add types to greta arrays

Open
#156 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
607
Forks
67
Avg merge
3d 8h
Merged PRs (30d)
1

Description

currently greta arrays are all implicitly of the same type; reals. They are coerced to integers as and when necessary on the tensorflow side, but always remain reals on the greta side.

That's fine for integers and reals, though perhaps a little confusing to users. E.g. this is fine:
```r
p <- uniform(0, 1)
y <- rnorm(3)
distribution(y) <- bernoulli(p)
```

For complex numbers it's more tricky, since we can't just drop the imaginary part and expect calculations to work. E.g. for a greta implementation of `fft`, the result on the tensorflow side would would need to be complex, and would need coersion back to reals for some subsequent operations to work.

Ideally, all greta arrays would have have types: `real`, `integer`, `imaginary` or `complex`. greta versions of the functions `Re(`, `Im()`, `complex()`, and `to_integer()` (rather than `as.integer()` which refers to R's class system).
The *precision* of those types is a computational issue, so should be handled in `model` or similar.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.