Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions e3nn_jax/_src/activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,12 @@ def normalize_function(phi: Callable[[float], float]) -> Callable[[float], float
# x = jax.random.normal(k, (1_000_000,))
x = normalspace(1_000_001)
c = jnp.mean(phi(x) ** 2) ** 0.5
c = c.item()
scale = jnp.where(jnp.allclose(c, 1.0), 1.0, 1.0 / c)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also be handling the case where c is close to 0?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would only be the case if the activation function was lambda x: 0 or close... figured it wasn't an issue since it wasn't in the original code either


if jnp.allclose(c, 1.0):
return phi
else:

def rho(x):
return phi(x) / c
def rho(x):
return phi(x) * scale

return rho
return rho


def parity_function(phi: Callable[[float], float]) -> int:
Expand Down
Loading