tensorflow / tensorflow/probability

Enhance documentation for ScaleMatvecTriL bijector reg. "batch behavior"?

Open
#690 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
4.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Hi,

porting the new bijectors to R, I was a bit confused by ScaleMatvecTriLs behavior (as opposed to what I was expecting from the documentation,

https://github.com/tensorflow/probability/blob/557351a2b79e4bd5a9025e791c81b612ab17bf38/tensorflow_probability/python/bijectors/scale_matvec_tril.py#L42

My test case was like this

tril = np.array([[1., 0],[1, 1]])
x = np.array([[1., 2], [3, 4]])
tril @ x

#array([[1., 2.],
#          [4., 6.]])


bijector = tfp.bijectors.ScaleMatvecTriL(tril)
bijector.forward(x) 

#<tf.Tensor: shape=(2, 2), dtype=float64, numpy=
#array([[1., 3.],
#          [3., 7.]])> 

From looking at

https://www.tensorflow.org/api_docs/python/tf/linalg/LinearOperatorLowerTriangular

, I think what is going on is that the operator acts on every row separately (treating the first dimension as a batch dimension).

Do you think it makes sense to go into a bit more detail on this in the documentation, to make it easier on users to understand the behavior?

Thanks!

Contributor guide

Open the contributing guide

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 tensorflow_probability/python/bijectors/scale_matvec_tril.py at the documentation referenced near line 42, then compare its explanation with tf.linalg.LinearOperatorLowerTriangular and the reported ScaleMatvecTriL example. Clarify how matrix dimensions are interpreted and how batch behavior produces the shown result; done means the documentation explains this behavior unambiguously.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.