Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/brainpy/BrainPy
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoming0625 committed Jan 3, 2024
2 parents b8e56a8 + 786283d commit d4a2db7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/CI-models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install taichi-nightly -i https://pypi.taichi.graphics/simple/
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
pip uninstall brainpy -y
python setup.py install
Expand Down Expand Up @@ -80,7 +79,6 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install taichi-nightly -i https://pypi.taichi.graphics/simple/
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
pip uninstall brainpy -y
python setup.py install
Expand Down Expand Up @@ -130,7 +128,6 @@ jobs:
- name: Install dependencies
run: |
python -m pip install numpy>=1.21.0
pip install taichi-nightly -i https://pypi.taichi.graphics/simple/
python -m pip install -r requirements-dev.txt
python -m pip install tqdm brainpylib
pip uninstall brainpy -y
Expand Down
6 changes: 3 additions & 3 deletions brainpy/_src/dnn/activations.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,10 +840,10 @@ class Softplus(Layer):
>>> output = m(input)
"""
__constants__ = ['beta', 'threshold']
beta: int
threshold: int
beta: float
threshold: float

def __init__(self, beta: int = 1, threshold: int = 20) -> None:
def __init__(self, beta: float = 1, threshold: float = 20.) -> None:
super().__init__()
self.beta = beta
self.threshold = threshold
Expand Down
8 changes: 4 additions & 4 deletions brainpy/_src/math/activations.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def leaky_relu(x, negative_slope=1e-2):
return jnp.where(x >= 0, x, negative_slope * x)


def softplus(x, beta=1, threshold=20):
def softplus(x, beta: float = 1., threshold: float = 20.):
r"""Softplus activation function.
Computes the element-wise function
Expand All @@ -315,12 +315,12 @@ def softplus(x, beta=1, threshold=20):
Parameters
----------
x: The input array.
beta: the :math:`\beta` value for the Softplus formulation. Default: 1
threshold: values above this revert to a linear function. Default: 20
beta: the :math:`\beta` value for the Softplus formulation. Default: 1.
threshold: values above this revert to a linear function. Default: 20.
"""
x = x.value if isinstance(x, Array) else x
return jnp.where(x > threshold, x * beta, 1 / beta * jnp.logaddexp(beta * x, 0))
return jnp.where(x > threshold / beta, x, 1 / beta * jnp.logaddexp(beta * x, 0))


def log_sigmoid(x):
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ matplotlib
msgpack
tqdm
pathos
taichi
taichi==1.7.0

# test requirements
pytest
Expand Down
2 changes: 1 addition & 1 deletion requirements-doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ matplotlib
numpy
scipy
numba
taichi
taichi==1.7.0

# document requirements
pandoc
Expand Down

0 comments on commit d4a2db7

Please sign in to comment.