当前位置:网站首页>tensorflow2.X实战系列softmax函数
tensorflow2.X实战系列softmax函数
2022-07-23 12:55:00 【TJMtaotao】
softmax 原理
斯坦福大学CS224n课程中softmax的解释:

代码知识点
1、NumPy数组是一个多维数组对象,称为ndarray。数组的下标从0开始,同一个NumPy数组中所有元素的类型必须是相同的。
2、数组
数组(Array)是有序的元素序列。
若将有限个类型相同的变量的集合命名,那么这个名称为数组名。组成数组的各个变量称为数组的分量,也称为数组的元素,有时也称为下标变量。用于区分数组的各个元素的数字编号称为下标。
数组是在程序设计中,为了处理方便, 把具有相同类型的若干元素按有序的形式组织起来的一种形式。
这些有序排列的同类数据元素的集合称为数组。
3、数组与矩阵
矩阵(Matrix)是一个按照长方阵列排列的复数或实数集合,最早来自于方程组的系数及常数所构成的方阵。
矩阵是二维数据组成的
4、数组与矩阵的区别
矩阵中的元素只能是数字,而数组中的元素可以是字符或者字符串
矩阵是二维的,数组可以是一维的、多维的
矩阵显示时,元素之间无逗号;数组显示时,元素之间用逗号隔开
代码实现
import numpy
import math
def softmax(inMatrix):
m,n = numpy.shape(inMatrix) #m行,n列
outMatrix = numpy.mat(numpy.zeros((m,n))) #创建输出矩阵 通过numpy.mat
soft_sum = 0 #分母
for idx in range(0,n):
outMatrix[0,idx] = math.exp(inMatrix[0,idx])
soft_sum += outMatrix[0,idx]
for idx in range(0,n): #分子
outMatrix[0,idx] = outMatrix[0,idx] / soft_sum
return outMatrix
a = numpy.array([[0.2,0.5,0.1,0.1,0.1]]) #1x5的数组
a_softmax_output = softmax(a)
print(a_softmax_output)
输出结果
[[0.19745789 0.26654027 0.17866728 0.17866728 0.17866728]]
代码参考 Tensorflow 2.0深度学习从零开始学 王晓华著
其他参考
https://blog.csdn.net/lz_peter/article/details/84574716
https://blog.csdn.net/github_36669230/article/details/78038756
https://blog.csdn.net/weixin_44515978/article/details/107889672
边栏推荐
- 三方支付公司有哪些?
- 20220722挨揍记录
- Sealing agent glycerol sealing neutral resin sealing dosage form
- 锁相环工作原理,比如我们8MHZ晶振如何让MCU工作在48MHZ或者72MHZ呢
- LeetCode之等式方程的可满足性
- pytest接口自动化测试框架 | 汇总
- Backup and restore of database
- 【Taro】小程序picker动态获取数据
- 2022-7-22 面经复习+简单题目整理
- Why is apple x charging slowly_ IPhone 12 supports 15W MagSafe wireless charging. What will happen to iPhone charging in the future_ Charger
猜你喜欢

動態規劃背包問題之完全背包詳解

【Redis】redis安装与客户端redis-cli的使用(批量操作)

阿里平头哥CPU技术生态负责人陈炜:平头哥的发展之路

FIO performance testing tool

Dynamic programming knapsack problem 01 knapsack explanation

机器狗背冲锋枪射击视频火了,网友瑟瑟发抖:stooooooooppppp!

Ali Er Mian: when does MySQL use table locks and row locks?

自定义一个对象

Talk about the memory layout of JVM

Esp8266 nodemcu flash file system (spiffs)
随机推荐
Backup and restore of database
【2022新生学习】第二周要点
Sealing agent glycerol sealing neutral resin sealing dosage form
go run,go build,go install有什么不同
Frequently asked questions about MySQL
为什么使用opengaussjdbc的时候老是出现FATAL?(标签-数据库|关键词-user)
FIO performance testing tool
Study note 7 -- traffic environment behavior prediction
V self built n_ Deployment and use
IIS 部署.NetCore
fastadmin,非超级管理员,已赋予批量更新权限,仍显示无权限
Go interface: go deep into internal principles
Cuibaoqiu, vice president of Xiaomi group: open source is the best platform and model for human technological progress
The new business form of smart civil aviation has emerged, and Tupo digital twin has entered the civil aviation flight network of the Bureau
Une solution complète au problème du sac à dos dans la programmation dynamique
pytest接口自动化测试框架 | pytest常用运行参数
PgSQL mistakenly deletes PG_ Wal file, service startup failed
大屏可视化的适配方案
mysql多表查询之_内连接_显示内连接
Dynamic programming knapsack problem 01 knapsack explanation