pymc-devs / pymc-devs/pytensor
Softmax fails with integer dtypes only at runtime
Open
Nobody has claimed this yet.
bug
Op implementation
- Dominant language
- Python
- Stars
- 644
- Forks
- 208
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 16
Description
Description
Brought up in #846
import pytensor
import pytensor.tensor as pt
x = pt.vector("x", dtype="int64")
out = pt.special.softmax(x)
# Doesn't seem right
out.dprint(print_type=True)
# Softmax{axis=None} [id A] <Vector(int64, shape=(?,))>
# └─ x [id B] <Vector(int64, shape=(?,))>
# No complaints
fn = pytensor.function([x], out)
fn([1, 2, 3]) # TypeError: not a float
We should either raise at graph definition time, or cast the input to float. Scipy is happy to take integers (and return floats), so we could try to do the same.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at pt.special.softmax and reproduce the integer-input example through graph construction and function execution. Decide whether integer inputs should be rejected when the graph is defined or produce floating-point outputs, then add regression coverage demonstrating the chosen behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100