当前位置:网站首页>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行/列/…
边栏推荐
- Unity程序员如何提升自己的能力
- Unity底层是如何处理C#的
- 囍楽云任务源码
- daily sql - query for managers and elections with at least 5 subordinates
- Redis源码:Redis源码怎么查看、Redis源码查看顺序、Redis外部数据结构到Redis内部数据结构查看源码顺序
- 进制转换间的那点事
- 接入网、承载网、核心网是什么,交换机路由器是什么、这个和网络的协议有什么关系呢?
- Activity的四种状态
- JVM学习——3——数据一致性
- Redis源码-String:Redis String命令、Redis String存储原理、Redis字符串三种编码类型、Redis String SDS源码解析、Redis String应用场景
猜你喜欢

Daily sql-statistics of the number of professionals (including the number of professionals is 0)

EasyPlayer针对H.265视频不自动播放设置下,loading状态无法消失的解决办法

Daily sql-seek the sum of successful investments in 2016

go-grpc TSL认证 解决 transport: authentication handshake failed: x509 certificate relies on ... ...

技能在赛题解析:交换机防环路设置

语音信号处理:预处理【预加重、分帧、加窗】

一种用于EEG超扫描研究的分析流程

Pinduoduo API interface (attach my available API)

Douyin API interface

radix-4 FFT principle and C language code implementation
随机推荐
Taobao product details API interface
【@网络工程师:用好这6款工具,让你的工作效率大翻倍!】
下一代 无线局域网--强健性
梅科尔工作室——BP神经网络
MySQL 版本升级心得
【LeetCode每日一题】——844.比较含退格的字符串
囍楽云任务源码
语音信号处理:预处理【预加重、分帧、加窗】
Taobao sku API interface (PHP example)
2022-08-09 Group 4 Self-cultivation class study notes (every day)
A used in the study of EEG ultra scanning analysis process
【LeetCode每日一题】——682.棒球比赛
Edge provides label grouping functionality
计算YUV文件的PSNR与SSIM
Coordinate system in navigation and positioning
Pinduoduo API interface (attach my available API)
第一个C函数:如何实现板级初始化?
When MySQL uses GROUP BY to group the query, the SELECT query field contains non-grouping fields
break pad源码编译--参考大佬博客的总结
LeetCode刷题系列 -- 46. 全排列