当前位置:网站首页>tf.reduce_mean()与tf.reduce_sum()
tf.reduce_mean()与tf.reduce_sum()
2022-08-11 06:45:00 【phac123】
简介
TF中常常使用tf.reduce_mean()与tf.reduce_sum()分别对指定张量的指定维度求平均值,求和。
# 计算张量沿着指定维度的平均值
tf.reduce_mean (张量名,axis=操作轴)
# 计算张量沿着指定维度的和
tf.reduce_sum (张量名,axis=操作轴)
代码
import tensorflow as tf
x = tf.constant([[1, 2, 3], [2, 2, 3]])
print("x: ", x)
print("mean of x: ", tf.reduce_mean(x))
print("mean of x: ", tf.reduce_mean(x, axis = 0))
print("mean of x: ", tf.reduce_mean(x, axis = 1))
print("mean of x: ", tf.reduce_sum(x))
print("sum of x: ", tf.reduce_sum(x, axis = 0))
print("sum of x: ", tf.reduce_sum(x, axis = 1))

axis指定哪个,就把那个维度变成1行/列/…
边栏推荐
- 一种用于EEG超扫描研究的分析流程
- JVM学习——3——数据一致性
- unable to extend table xxx by 1024 in tablespace xxxx
- 常见激活函数及其导数
- Implement general-purpose, high-performance sorting and quicksort optimizations
- Douyin get douyin share password url API return value description
- Pinduoduo API interface (attach my available API)
- Strongly recommend an easy-to-use API interface
- 网络电话软件或迎整顿 “免费”通话须迈安全关
- Coordinate system in navigation and positioning
猜你喜欢

易观分析联合中小银行联盟发布海南数字经济指数,敬请期待!

基于FPGA的FIR滤波器的实现(4)— 串行结构FIR滤波器的FPGA代码实现

详述MIMIC 的ICU患者检测时间信息表(十六)

【Pytorch】nn.PixelShuffle

Implement general-purpose, high-performance sorting and quicksort optimizations

每日sql-员工奖金过滤和回答率排序第一

第一个C函数:如何实现板级初始化?

技术分享 | 实战演练接口自动化如何处理 Form 请求?

下一代 无线局域网--强健性

When MySQL uses GROUP BY to group the query, the SELECT query field contains non-grouping fields
随机推荐
mysql视图与索引
C语言每日一练——Day02:求最小公倍数(3种方法)
MySQL使用GROUP BY 分组查询时,SELECT 查询字段包含非分组字段
linux 安装mysql服务报错
Douyin get douyin share password url API return value description
6月各手机银行活跃用户较快增长,创半年新高
JVM学习——3——数据一致性
深度监督(中继监督)
Redis测试
js判断图片是否存在
ROS 服务通信理论模型
恒源云-Pycharm远程训练避坑指南
Pico neo3 Unity打包设置
break pad源码编译--参考大佬博客的总结
JD.com product details API call example explanation
Daily sql: request for friend application pass rate
每日sql-员工奖金过滤和回答率排序第一
How to choose professional, safe and high-performance remote control software
Cobbleland 博览会 基础系列 1
jar服务导致cpu飙升问题-带解决方法