当前位置:网站首页>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行/列/…
边栏推荐
- JD.com product details API call example explanation
- Waldom Electronics宣布成立顾问委员会
- 6月各手机银行活跃用户较快增长,创半年新高
- Redis源码-String:Redis String命令、Redis String存储原理、Redis字符串三种编码类型、Redis String SDS源码解析、Redis String应用场景
- Daily SQL - find each of the students school gpa minimum (window)
- Unity程序员如何提升自己的能力
- Pinduoduo api interface application example
- Daily sql-seek the sum of successful investments in 2016
- MySQL使用GROUP BY 分组查询时,SELECT 查询字段包含非分组字段
- prometheus学习4Grafana监控mysql&blackbox了解
猜你喜欢
第一个C函数:如何实现板级初始化?
Douyin API interface
Multiscale communication in cortical-cortical networks
Daily sql-employee bonus filtering and answer rate ranking first
Coordinate system in navigation and positioning
【LeetCode每日一题】——844.比较含退格的字符串
jar服务导致cpu飙升问题-带解决方法
详述 MIMIC护理人员信息表(十五)
每日sql-员工奖金过滤和回答率排序第一
每日sql -查询至少有5名下属的经理和选举
随机推荐
Unity3D 学习路线?
公牛10-11德里克·罗斯最强赛季记录
计算YUV文件的PSNR与SSIM
数仓开发知识总结
基于FPGA的FIR滤波器的实现(4)— 串行结构FIR滤波器的FPGA代码实现
详述 MIMIC护理人员信息表(十五)
unable to extend table xxx by 1024 in tablespace xxxx
深度监督(中继监督)
已解决EROR 1064 (42000): You have an error in. your SOL syntax. check the manual that corresponds to yo
博途PLC 1200/1500PLC ModbusTcp通信梯形图优化汇总(多服务器多从站轮询)
求职简历这样写,轻松搞定面试官
Implement general-purpose, high-performance sorting and quicksort optimizations
【latex异常和错误】Missing $ inserted.<inserted text>You can‘t use \spacefactor in math mode.输出文本要注意特殊字符的转义
LeetCode brushing series -- 46. Full arrangement
Discourse 的关闭主题(Close Topic )和重新开放主题
2022-08-10 第四小组 修身课 学习笔记(every day)
prometheus学习5altermanager
线程交替输出(你能想出几种方法)
Daily sql-employee bonus filtering and answer rate ranking first
Unity开发者必备的C#脚本技巧