当前位置:网站首页>Jax calculation Selu function
Jax calculation Selu function
2022-07-21 16:55:00 【Albert·Darren】
1.SeLU(scaled exponential linear units) Activate function calculation formula
selu ( x ) = λ { x if x > 0 α e x − α if x ⩽ 0. \text{selu}(x)= \lambda \begin{cases} x& \text{ if } x>0 \\ \alpha e^x-\alpha & \text{ if } x\leqslant 0. \end{cases} selu(x)=λ{ xαex−α if x>0 if x⩽0.
among λ = 1.0507009873554804934193349852946 \lambda=1.0507009873554804934193349852946 λ=1.0507009873554804934193349852946, α = 1.6732632423543772848170429916717. \alpha=1.6732632423543772848170429916717. α=1.6732632423543772848170429916717.
2.JAX Code implementation
#!/usr/bin/python3
# -*- coding: utf-8 -*-
""" @Time : 2022/7/20 13:51 @Author : Albert Darren @Contact : [email protected] @File : Program1.1.py @Version : Version 1.0.0 @Description : TODO utilize jax Calculation selu function , See P12 @Created By : PyCharm """
import jax.numpy as jnp # Import numpy Calculation package
from jax import random # Import random Random number packets
def selu(x, alpha=1.6732632423543772848170429916717, lmbda=1.0507009873554804934193349852946):
""" Realization selu Activation function :param x: Input tensor :param alpha: Predefined parameters alpha :param lmbda: Predefined parameters lambda, The variable name here is intentionally misspelled , Avoid with keywords lambda name conflict :return: selu Function value """
return lmbda * jnp.where(x > 0, x, alpha * (jnp.exp(x) - 1))
# Generate a fixed number 17 As key
key = random.PRNGKey(17)
# Randomly generate a size of [1,5] Matrix
x = random.normal(key, (5,))
print(selu(x))
# [-1.2497659 0.4546819 1.5760192 -0.81573856 0.27510932]
3. reference
边栏推荐
猜你喜欢
随机推荐
7.2-cm46 legal bracket sequence judgment
安装C3D v1.0
Scala 练习题 学生分数案例
100页幻灯片图解《数据出境安全评估办法》及修订对照(附下载)
盛邦安全冲刺科创板:奇安信是其第一大客户(5587 万);其三年收入 4.6 亿、净利润 9504 万,研发投入 7846 万
网络水军为何如此猖獗:揭秘背后灰色利益链
[leetcode] find an integer by dichotomy in the range
js的可选链
Jz24 reverse linked list
9、 Elk installs elastalert 2 plug-in nailing robot alarm
Practice of data storage scheme in distributed system
【方法】判断exe或dll是32位还是64位
百度工程师眼中的云原生可观测性追踪技术
Large language models teach agents to evolve, and openai reveals the complementary relationship between the two
Parsing ansible configuration management file
39 year old layoff + mortgage (no way to live)
北森招股书:赛道优势凸显,一体化+中大客户是加分项
按Ctrl键会引发几次按键消息
打通了!Jira + Zadig 實現需求與研發過程追踪
三丰智能唐海芹:为「三农」插上智慧翅膀,做智慧农业「引领者」| 镁客·请讲