当前位置:网站首页>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行/列/…
边栏推荐
- pytorch,numpy两种方法实现nms类间+类内
- js根据当天获取前几天的日期
- 软件测试基本流程有哪些?北京专业第三方软件检测机构安利
- Service的两种启动方式与区别
- JVM学习——3——数据一致性
- Find the shops that have sold more than 1,000 yuan per day for more than 30 consecutive days in the past six months
- Douyin share password url API tool
- Amazon API interface Daquan
- Get Pinduoduo product information operation details
- 【latex异常和错误】Missing $ inserted.<inserted text>You can‘t use \spacefactor in math mode.输出文本要注意特殊字符的转义
猜你喜欢
随机推荐
基于FPGA的FIR滤波器的实现(5)— 并行结构FIR滤波器的FPGA代码实现
redis操作
Redis源码-String:Redis String命令、Redis String存储原理、Redis字符串三种编码类型、Redis String SDS源码解析、Redis String应用场景
囍楽云任务源码
联想集团:2022/23财年第一季度业绩
梅科尔工作室——BP神经网络
机器学习总结(二)
linux 安装mysql服务报错
技术分享 | 实战演练接口自动化如何处理 Form 请求?
break pad源码编译--参考大佬博客的总结
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?
每日sql -查询至少有5名下属的经理和选举
【预约观看】Ambire 智能钱包 AMA 活动第四期即将举行
sql--7天内(含当天)购买次数超过3次(含),且近7天的购买金额超过1000的用户
Attitude solution - gyroscope + Euler method
Activity的四种启动模式
golang fork 进程的三种方式
每日sql-员工奖金过滤和回答率排序第一
【LeetCode每日一题】——844.比较含退格的字符串
MySQL使用GROUP BY 分组查询时,SELECT 查询字段包含非分组字段









