当前位置:网站首页>tensorflow boolean_ Mask function
tensorflow boolean_ Mask function
2022-07-24 06:57:00 【Live up to your youth】
The function prototype
tf.boolean_mask(
tensor, mask, axis=None, name='boolean_mask'
)
Function description
For preserving tensors tenso Part of , It depends on the tensor mask The subscript .
Parameters tensor Represents the tensor to be manipulated , Parameters mask Is a Boolean matrix , decision tensor Those places should be preserved , Parameters axis Indicates which axis to start from .
Function USES
1、 One dimensional tensor
>>> tensor = tf.constant([1, 2, 3, 4])
>>> mask = tf.constant([True, True, False, False])
>>> tf.boolean_mask(tensor, mask)
<tf.Tensor: shape=(2,), dtype=int32, numpy=array([1, 2])>
2、 Two dimensional tensor ,mask If it is a one-dimensional tensor , You need to be with axis The length of the corresponding axis is equal , If it is a two-dimensional tensor , You need to be with tensor Of shape identical .
>>> tensor = tf.constant([[1, 2], [3, 4]])
>>> mask = tf.constant([True, False])
# The default from the axis=0 Start
>>> tf.boolean_mask(tensor, mask)
<tf.Tensor: shape=(1, 2), dtype=int32, numpy=array([[1, 2]])>
>>> tensor = tf.constant([[1, 2], [3, 4]])
>>> mask = tf.constant([True, False])
>>> tf.boolean_mask(tensor, mask, axis=1)
<tf.Tensor: shape=(2, 1), dtype=int32, numpy=
array([[1],
[3]])>
>>> tensor = tf.constant([[1, 2], [3, 4]])
>>> mask = tf.constant([[True, True], [True, False]])
>>> tf.boolean_mask(tensor, mask)
<tf.Tensor: shape=(3,), dtype=int32, numpy=array([1, 2, 3])>
边栏推荐
- Mac解决 Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘ (2)问题
- Special effects - bubble tailing occurs when the mouse moves
- Prediction of advertising investment and sales based on regression analysis -- K neighborhood, decision tree, random forest, linear regression, ridge regression
- 《大厂面试》之JVM篇21问与答
- tensorflow boolean_mask函数
- OWASP TOP10 penetration test
- [lvgl (important)] style attribute API function and its parameters
- Sealos packages and deploys kubesphere container platform
- Special effects - cobweb background effects
- 先爱自己,再爱别人。
猜你喜欢

Redis.conf details

Can you increase muscle without exercise??? Just get an injection of hibernating black bear serum
![[lvgl (4)] event and event bubble of the object](/img/1e/9fe3d34f5f8d8c7298a106dca8d949.png)
[lvgl (4)] event and event bubble of the object

XXL execute node error log swiping

Metaltc5.0 realizes webrtc version IPC of Junzheng pure C

PyQt5入门——学生管理系统

OWASP TOP10 penetration test

Experiment: creation, expansion, and deletion of LVM logical volumes
![[lvgl (1)] a brief introduction to lvgl](/img/2e/2e155f1d3669c27ad1b090ca954224.png)
[lvgl (1)] a brief introduction to lvgl

Kubernetes rapid installation
随机推荐
2022-07-22 mysql/stonedb parallel hashjoin memory usage analysis
STM32外部中断(寄存器版本)
OWASP TOP10 penetration test
Don't compare with anyone, just be yourself
kubernetes 的Deployment(部署),Service概念,动态扩缩容
【学习笔记】网页出现白屏可能的原因与优化方法
一个AI玩41个游戏,谷歌最新多游戏决策Transformer综合表现分是DQN的两倍
Introduction to pyqt5 - student management system
永远不要迷失自我!
[wechat applet] understand conditional rendering, list rendering and wxss template style
[media controller] open source project learning notes (based on Arduino micro development board)
xavier_normal_ 初始化测试
Redis特殊数据类型-HyperLogLog
Love yourself first, then others.
自己的人生无须浪费在别人的标准中
SparkSQL核心使用,220724,
你就是你,没有人可以取代
MySQL gets the self incrementing line mark (different from MySQL version)
MGR_ mysqlsh_ Keepalive high availability architecture deployment document
Special effects - click with the mouse and the fireworks will burst