Skip to content

Missing rewrite softplus(log(x)) -> log1p(x) #1451

Open
@lciti

Description

@lciti

Description

PyTensor is missing this simple rewrite:

import pytensor.tensor as pt
from pytensor.graph import rewrite_graph

x = pt.scalar("x")
out = pt.softplus(pt.log(x))
new_out = rewrite_graph(out, include=("canonicalize", "stabilize", "specialize"))
new_out.dprint()

I am ready to propose a PR that addresses this issue.

I could also extend it to cover the case softplus(-log(x)) -> log1p(1/x). However I have noticed that even the simple exp(-log(x)) -> 1/x is missing, so I wonder if there is an underlying reason to avoid such simplifications, that I am not aware of.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions