当前位置:网站首页>TF中使用softmax函数;
TF中使用softmax函数;
2022-08-11 06:45:00 【phac123】
简介

代码
import tensorflow as tf
x1 = tf.constant([[5.8, 4.0, 1.2, 0.2]]) # 5.8,4.0,1.2,0.2(0)
w1 = tf.constant([[-0.8, -0.34, -1.4],
[0.6, 1.3, 0.25],
[0.5, 1.45, 0.9],
[0.65, 0.7, -1.2]])
b1 = tf.constant([2.52, -3.1, 5.62])
y = tf.matmul(x1, w1) + b1
print("x1.shape:", x1.shape)
print("w1.shape:", w1.shape)
print("b1.shape:", b1.shape)
print("y.shape:", y.shape)
print("y:", y)
#####以下代码可将输出结果y转化为概率值#####
y_dim = tf.squeeze(y) # 去掉y中纬度1(观察y_dim与 y 效果对比)
y_pro = tf.nn.softmax(y_dim) # 使y_dim符合概率分布,输出为概率值了
print("y_dim:", y_dim)
print("y_pro:", y_pro)
边栏推荐
猜你喜欢

Spatial Pyramid Pooling -Spatial Pyramid Pooling (including source code)

【预约观看】Ambire 智能钱包 AMA 活动第四期即将举行

MySQL使用GROUP BY 分组查询时,SELECT 查询字段包含非分组字段

接口测试的基础流程和用例设计方法你知道吗?

【软件测试】(北京)字节跳动科技有限公司二面笔试题

Pico neo3在Unity中的交互操作

Douyin get douyin share password url API return value description

radix-4 FFT principle and C language code implementation

囍楽云任务源码

Edge provides label grouping functionality
随机推荐
js判断图片是否存在
软件测试主要做什么工作,难不难?
MySQL使用GROUP BY 分组查询时,SELECT 查询字段包含非分组字段
Unity游戏排行榜的制作与优化
一张图了解JVM八大原子操作
【sdx62】XBL设置共享内存变量,然后内核层获取变量实现
STM32CUBEIDE(11)----输出PWM及修改PWM频率与占空比
ROS 话题通信理论模型
求职简历这样写,轻松搞定面试官
Activity的四种启动模式
线程交替输出(你能想出几种方法)
关于Android Service服务的面试题
concept noun
Get Pinduoduo product information operation details
接入网、承载网、核心网是什么,交换机路由器是什么、这个和网络的协议有什么关系呢?
Daily sql-employee bonus filtering and answer rate ranking first
Redis源码-String:Redis String命令、Redis String存储原理、Redis字符串三种编码类型、Redis String SDS源码解析、Redis String应用场景
Pinduoduo API interface
Unity开发者必备的C#脚本技巧
C语言每日一练——Day02:求最小公倍数(3种方法)