当前位置:网站首页>机器学习笔记 temperature+Softmax
机器学习笔记 temperature+Softmax
2022-06-28 19:04:00 【UQI-LIUWJ】
1 介绍
带temperature的Softmax,用公式描述,可以表示为
![S_\tau(x,y)=[\frac{exp(a_1/\tau)}{\sum exp(a_i/\tau)},\frac{exp(a_2/\tau)}{\sum exp(a_i/\tau)},\cdots,\frac{exp(a_i/\tau)}{\sum exp(a_i/\tau)}]](http://img.inotgo.com/imagesLocal/202206/28/202206281904099085_1.gif)
直观感受一下
import numpy as np
def exp_tem(x,tau):
return np.exp(x/tau)/sum(np.exp(x/tau))
print(exp_tem(np.array([1,2,3]),2))
#[0.18632372 0.30719589 0.50648039]
print(exp_tem(np.array([1,2,3]),1))
#[0.09003057 0.24472847 0.66524096]
print(exp_tem(np.array([1,2,3]),0.5))
#[0.01587624 0.11731043 0.86681333]不难发现,t越大,各个类之间的差距越小,结果越“平滑”;t越小,各个类之间的差距越大,结果越“尖锐”。
2 temperature的作用
个人觉得可以在一定程度上类比成强化学习的ε-greedy,如果temperature设置得比较大,那么各个类之间的差别不大,就有很大概率选到不同的类,获得了一定的exploration空间;如果temperature设置得比较小,那么概率最大的类 得到的结果数值会“鹤立鸡群”,那么基本上选择的就是这个类了。
所以我们可以设置 temperature
,随着模型的更新,temperature越来越小,也就逐渐从exploration转向exploitation了。
边栏推荐
- OpenHarmony—内核对象事件之源码详解
- C# 41. int与string互转
- Friends from Fujian, your old-age insurance is on the cloud!
- Find out the users who log in for 7 consecutive days and 30 consecutive days
- 原生实现.NET5.0+ 自定义日志
- Jenkins Pipeline 对Job参数的处理
- 泰山OFFICE技术讲座:WORD奇怪的字体高度
- 论文3 VScode&texlive&SumatraPDF打造完美书写论文工具
- Month on month SQL implementation
- C language file operation
猜你喜欢

SQL interview question: find the maximum number of consecutive login days

道路千万条,为什么这家创新存储公司会选这条?

C#连接数据库完成增删改查操作

In which industries did the fire virtual human start to make efforts?

try except 添加辅助新列

Understanding of closures

How to resolve kernel errors? Solution to kernel error of win11 system

Advanced - Introduction to business transaction design and development

数据基础设施升级窗口下,AI 新引擎的技术方法论

使用Karmada实现Helm应用的跨集群部署
随机推荐
19.2 container classification, array and vector container refinement
Shell script batch modify file directory permissions
列表加入计时器(正计时、倒计时)
智能计算系统3 Plugin 集成开发的demo
毕业设计-基于Unity的餐厅经营游戏的设计与开发(附源码、开题报告、论文、答辩PPT、演示视频,带数据库)
Installing the nodejs environment
leetcode 1689. Partitioning into minimum number of deci binary numbers
我是刚购买的adb mysql服务,我每做一个操作,比如建表,都会弹出这个问题,请问这是什么问题?
Show the actual work case of creating intermediate data table with SQL
《数字经济全景白皮书》消费金融数字化篇 重磅发布
i人事HR系统上架企业微信ISV,增强企微在服务连锁零售等行业深度应用
基于管线的混合渲染
几行代码就能实现复杂的 Excel 导入导出,这个工具类真心强大!
Upward and downward transformation
Servlet的使用手把手教学(一)
视频压缩处理之ffmpeg用法
3D可旋转粒子矩阵
Understanding of closures
Some error prone points of C language pointer
找出连续7天登陆,连续30天登陆的用户