Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc] update docs #488

Merged
merged 2 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
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
74 changes: 74 additions & 0 deletions brainpy/_src/math/surrogate/_one_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@


class Sigmoid(Surrogate):
"""Spike function with the sigmoid-shaped surrogate gradient.

Also see :py:class:`~.sigmoid`.

"""
def __init__(self, alpha=4., origin=False):
self.alpha = alpha
self.origin = origin
Expand Down Expand Up @@ -118,6 +123,11 @@ def grad(dz):


class PiecewiseQuadratic(Surrogate):
"""Judge spiking state with a piecewise quadratic function.

Also see :py:class:`~.piecewise_quadratic`.

"""
def __init__(self, alpha=1., origin=False):
self.alpha = alpha
self.origin = origin
Expand Down Expand Up @@ -220,6 +230,10 @@ def grad(dz):


class PiecewiseExp(Surrogate):
"""Judge spiking state with a piecewise exponential function.

Also see :py:class:`~.piecewise_exp`.
"""
def __init__(self, alpha=1., origin=False):
self.alpha = alpha
self.origin = origin
Expand Down Expand Up @@ -308,6 +322,10 @@ def grad(dz):


class SoftSign(Surrogate):
"""Judge spiking state with a soft sign function.

Also see :py:class:`~.soft_sign`.
"""
def __init__(self, alpha=1., origin=False):
self.alpha = alpha
self.origin = origin
Expand Down Expand Up @@ -391,6 +409,10 @@ def grad(dz):


class Arctan(Surrogate):
"""Judge spiking state with an arctan function.

Also see :py:class:`~.arctan`.
"""
def __init__(self, alpha=1., origin=False):
self.alpha = alpha
self.origin = origin
Expand Down Expand Up @@ -473,6 +495,10 @@ def grad(dz):


class NonzeroSignLog(Surrogate):
"""Judge spiking state with a nonzero sign log function.

Also see :py:class:`~.nonzero_sign_log`.
"""
def __init__(self, alpha=1., origin=False):
self.alpha = alpha
self.origin = origin
Expand Down Expand Up @@ -568,6 +594,10 @@ def grad(dz):


class ERF(Surrogate):
"""Judge spiking state with an erf function.

Also see :py:class:`~.erf`.
"""
def __init__(self, alpha=1., origin=False):
self.alpha = alpha
self.origin = origin
Expand Down Expand Up @@ -660,6 +690,10 @@ def grad(dz):


class PiecewiseLeakyRelu(Surrogate):
"""Judge spiking state with a piecewise leaky relu function.

Also see :py:class:`~.piecewise_leaky_relu`.
"""
def __init__(self, c=0.01, w=1., origin=False):
self.c = c
self.w = w
Expand Down Expand Up @@ -771,6 +805,10 @@ def grad(dz):


class SquarewaveFourierSeries(Surrogate):
"""Judge spiking state with a squarewave fourier series.

Also see :py:class:`~.squarewave_fourier_series`.
"""
def __init__(self, n=2, t_period=8., origin=False):
self.n = n
self.t_period = t_period
Expand Down Expand Up @@ -863,6 +901,10 @@ def grad(dz):


class S2NN(Surrogate):
"""Judge spiking state with the S2NN surrogate spiking function.

Also see :py:class:`~.s2nn`.
"""
def __init__(self, alpha=4., beta=1., epsilon=1e-8, origin=False):
self.alpha = alpha
self.beta = beta
Expand Down Expand Up @@ -969,6 +1011,10 @@ def grad(dz):


class QPseudoSpike(Surrogate):
"""Judge spiking state with the q-PseudoSpike surrogate function.

Also see :py:class:`~.q_pseudo_spike`.
"""
def __init__(self, alpha=2., origin=False):
self.alpha = alpha
self.origin = origin
Expand Down Expand Up @@ -1062,6 +1108,10 @@ def grad(dz):


class LeakyRelu(Surrogate):
"""Judge spiking state with the Leaky ReLU function.

Also see :py:class:`~.leaky_relu`.
"""
def __init__(self, alpha=0.1, beta=1., origin=False):
self.alpha = alpha
self.beta = beta
Expand Down Expand Up @@ -1156,6 +1206,10 @@ def grad(dz):


class LogTailedRelu(Surrogate):
"""Judge spiking state with the Log-tailed ReLU function.

Also see :py:class:`~.log_tailed_relu`.
"""
def __init__(self, alpha=0., origin=False):
self.alpha = alpha
self.origin = origin
Expand Down Expand Up @@ -1260,6 +1314,10 @@ def grad(dz):


class ReluGrad(Surrogate):
"""Judge spiking state with the ReLU gradient function.

Also see :py:class:`~.relu_grad`.
"""
def __init__(self, alpha=0.3, width=1.):
self.alpha = alpha
self.width = width
Expand Down Expand Up @@ -1337,6 +1395,10 @@ def grad(dz):


class GaussianGrad(Surrogate):
"""Judge spiking state with the Gaussian gradient function.

Also see :py:class:`~.gaussian_grad`.
"""
def __init__(self, sigma=0.5, alpha=0.5):
self.sigma = sigma
self.alpha = alpha
Expand Down Expand Up @@ -1413,6 +1475,10 @@ def grad(dz):


class MultiGaussianGrad(Surrogate):
"""Judge spiking state with the multi-Gaussian gradient function.

Also see :py:class:`~.multi_gaussian_grad`.
"""
def __init__(self, h=0.15, s=6.0, sigma=0.5, scale=0.5):
self.h = h
self.s = s
Expand Down Expand Up @@ -1503,6 +1569,10 @@ def grad(dz):


class InvSquareGrad(Surrogate):
"""Judge spiking state with the inverse-square surrogate gradient function.

Also see :py:class:`~.inv_square_grad`.
"""
def __init__(self, alpha=100.):
self.alpha = alpha

Expand Down Expand Up @@ -1571,6 +1641,10 @@ def grad(dz):


class SlayerGrad(Surrogate):
"""Judge spiking state with the slayer surrogate gradient function.

Also see :py:class:`~.slayer_grad`.
"""
def __init__(self, alpha=1.):
self.alpha = alpha

Expand Down
37 changes: 18 additions & 19 deletions docs/apis/math.rst
Original file line number Diff line number Diff line change
Expand Up @@ -294,50 +294,49 @@ Computing Modes

.. autosummary::
:toctree: generated/
:nosignatures:
:template: classtemplate.rst

Surrogate
Sigmoid
PiecewiseQuadratic
PiecewiseExp
SoftSign
Arctan
NonzeroSignLog
ERF
PiecewiseLeakyRelu
SquarewaveFourierSeries
S2NN
QPseudoSpike
LeakyRelu
LogTailedRelu
ReluGrad
GaussianGrad
InvSquareGrad
MultiGaussianGrad
SlayerGrad
sigmoid
PiecewiseQuadratic
piecewise_quadratic
PiecewiseExp
piecewise_exp
SoftSign
soft_sign
Arctan
arctan
NonzeroSignLog
nonzero_sign_log
ERF
erf
PiecewiseLeakyRelu
piecewise_leaky_relu
SquarewaveFourierSeries
squarewave_fourier_series
S2NN
s2nn
QPseudoSpike
q_pseudo_spike
LeakyRelu
leaky_relu
LogTailedRelu
log_tailed_relu
ReluGrad
relu_grad
GaussianGrad
gaussian_grad
InvSquareGrad
inv_square_grad
MultiGaussianGrad
multi_gaussian_grad
SlayerGrad
slayer_grad
inv_square_grad2
relu_grad2



``brainpy.math.random`` module: Random Number Generations
---------------------------------------------------------

Expand Down
Loading