当前位置:网站首页>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,numpy两种方法实现nms类间+类内
Taobao product details API interface
Activity的四种状态
公牛10-11德里克·罗斯最强赛季记录
Pico neo3 Unity打包设置
Douyin share password url API tool
Amazon Get AMAZON Product Details API Return Value Description
【推荐系统】:协同过滤和基于内容过滤概述
Unity游戏排行榜的制作与优化
Redis源码:Redis源码怎么查看、Redis源码查看顺序、Redis外部数据结构到Redis内部数据结构查看源码顺序
易观分析联合中小银行联盟发布海南数字经济指数,敬请期待!
Implement general-purpose, high-performance sorting and quicksort optimizations
软件测试基本流程有哪些?北京专业第三方软件检测机构安利
Daily sql: request for friend application pass rate
Douyin API interface
从 dpdk-20.11 移植 intel E810 百 G 网卡 pmd 驱动到 dpdk-16.04 中
Douyin API interface
【软件测试】(北京)字节跳动科技有限公司终面HR面试题
【@网络工程师:用好这6款工具,让你的工作效率大翻倍!】
DDR4内存条电路设计