当前位置:网站首页>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)
边栏推荐
猜你喜欢
随机推荐
unable to extend table xxx by 1024 in tablespace xxxx
Edge provides label grouping functionality
易观分析联合中小银行联盟发布海南数字经济指数,敬请期待!
LeetCode刷题系列 -- 46. 全排列
docker安装mysql5.7(仅供测试使用)
NFT 的价值从何而来
js根据当天获取前几天的日期
【推荐系统】:协同过滤和基于内容过滤概述
2021-08-11 for循环结合多线程异步查询并收集结果
Daily sql-statistics of the number of professionals (including the number of professionals is 0)
Tidb二进制集群搭建
Pinduoduo API interface (attach my available API)
Discourse's Close Topic and Reopen Topic
从何跟踪伦敦金最新行情走势?
CIKM 2022 AnalytiCup Competition: 联邦异质任务学习
easyrecovery15数据恢复软件收费吗?功能强大吗?
LeetCode brushing series -- 46. Full arrangement
【预约观看】Ambire 智能钱包 AMA 活动第四期即将举行
【软件测试】(北京)字节跳动科技有限公司二面笔试题
Douyin share password url API tool









