当前位置:网站首页>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)
边栏推荐
猜你喜欢
随机推荐
A used in the study of EEG ultra scanning analysis process
常见激活函数及其导数
【LaTex-错误和异常】\verb ended by end of line.原因是因为闭合边界符没有在\verb命令所属行中出现;\verb命令的正确和错误用法、verbatim环境的用法
prometheus学习5altermanager
【Pytorch】nn.ReLU(inplace=True)
Internet phone software or consolidation of attack must be "free" calls security clearance
Strongly recommend an easy-to-use API interface
ROS 服务通信理论模型
daily sql - query for managers and elections with at least 5 subordinates
Discourse's Close Topic and Reopen Topic
Shell:三剑客之awk
详述MIMIC 的ICU患者检测时间信息表(十六)
李沐d2l(十)--卷积层Ⅰ
求职简历这样写,轻松搞定面试官
微信小程序功能上新(2022.06.01~2022.08.04)
计算YUV文件的PSNR与SSIM
软件测试主要做什么工作,难不难?
SQL滑动窗口
unable to extend table xxx by 1024 in tablespace xxxx
Unity开发者必备的C#脚本技巧