当前位置:网站首页>The softmax function is used in TF;
The softmax function is used in TF;
2022-08-11 07:51: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)
#####The following code will output the resultyConvert to probability value#####
y_dim = tf.squeeze(y) # 去掉y中纬度1(观察y_dim与 y 效果对比)
y_pro = tf.nn.softmax(y_dim) # 使y_dim符合概率分布,The output is a probability value
print("y_dim:", y_dim)
print("y_pro:", y_pro)
边栏推荐
- 1106 2019 Sequence (15 points)
- 1.1-Regression
- Pico neo3 Unity打包设置
- Redis source code: how to view the Redis source code, the order of viewing the Redis source code, the sequence of the source code from the external data structure of Redis to the internal data structu
- Edge 提供了标签分组功能
- 年薪40W测试工程师成长之路,你在哪个阶段?
- How Unity handles C# under the hood
- What are the things that should be planned from the beginning when developing a project with Unity?How to avoid a huge pit in the later stage?
- easyrecovery15数据恢复软件收费吗?功能强大吗?
- SQL sliding window
猜你喜欢
随机推荐
Production and optimization of Unity game leaderboards
Use tf.argmax in Tensorflow to return the index of the maximum value of the tensor along the specified dimension
1051 复数乘法 (15 分)
1096 大美数 (15 分)
Service的两种状态形式
[Recommender System]: Overview of Collaborative Filtering and Content-Based Filtering
1106 2019 Sequence (15 points)
关于#sql#的问题:怎么将下面的数据按逗号分隔成多行,以列的形式展示出来
Dynamic Agent Learning
【LeetCode每日一题】——682.棒球比赛
3GPP LTE/NR信道模型
3.1-分类-概率生成模型
1046 punches (15 points)
TF中的四则运算
About # SQL problem: how to set the following data by commas into multiple lines, in the form of column display
How Unity handles C# under the hood
oracle19c不支持实时同步参数,请教一下大佬们有什么好的解决办法吗?
Edge provides label grouping functionality
【LeetCode每日一题】——844.比较含退格的字符串
The most complete documentation on Excel's implementation of grouped summation