当前位置:网站首页>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)
边栏推荐
- 【Pytorch】nn.PixelShuffle
- How Unity handles C# under the hood
- 基于FPGA的FIR滤波器的实现(5)— 并行结构FIR滤波器的FPGA代码实现
- 为什么我使用C#操作MySQL进行中文查询失败
- Pinduoduo API interface
- JVM学习——3——数据一致性
- Activity的四种状态
- 【LaTex-错误和异常】\verb ended by end of line.原因是因为闭合边界符没有在\verb命令所属行中出现;\verb命令的正确和错误用法、verbatim环境的用法
- Daily sql - judgment + aggregation
- 【软件测试】(北京)字节跳动科技有限公司二面笔试题
猜你喜欢
伦敦银规则有哪些?
Resolved EROR 1064 (42000): You have an error in. your SOL syntax. check the manual that corresponds to yo
年薪40W测试工程师成长之路,你在哪个阶段?
Discourse 的关闭主题(Close Topic )和重新开放主题
恒源云-Pycharm远程训练避坑指南
Daily sql-seek the sum of successful investments in 2016
Douyin API interface
Taobao API common interface and acquisition method
Daily sql: request for friend application pass rate
从苹果、SpaceX等高科技企业的产品发布会看企业产品战略和敏捷开发的关系
随机推荐
NTT的Another Me技术助力创造歌舞伎演员中村狮童的数字孪生体,将在 “Cho Kabuki 2022 Powered by NTT”舞台剧中首次亮相
sql--7天内(含当天)购买次数超过3次(含),且近7天的购买金额超过1000的用户
Taobao API interface reference
linux 安装mysql服务报错
Resolved EROR 1064 (42000): You have an error in. your SOL syntax. check the manual that corresponds to yo
【软件测试】(北京)字节跳动科技有限公司终面HR面试题
ROS 服务通信理论模型
Taobao sku API interface (PHP example)
Taobao API common interface and acquisition method
1688 product interface
Redis源码:Redis源码怎么查看、Redis源码查看顺序、Redis外部数据结构到Redis内部数据结构查看源码顺序
go-grpc TSL认证 解决 transport: authentication handshake failed: x509 certificate relies on ... ...
Activity的四种状态
Daily sql-seek the sum of successful investments in 2016
buu—Re(5)
进制转换间的那点事
【Pytorch】nn.ReLU(inplace=True)
Edge 提供了标签分组功能
Douyin get douyin share password url API return value description
第一个C函数:如何实现板级初始化?