当前位置:网站首页>tensorflow scatter_ Nd function
tensorflow scatter_ Nd function
2022-07-24 06:58:00 【Live up to your youth】
The function prototype
tf.scatter_nd(
indices, updates, shape, name=None
)
Function description
Will tensor updates The shape of extends to the new shape shape, Tensor in new shape shape The coordinates in are indices, Other element values are 0.
Parameters indices Index representing tensor , Parameters updates Represents the value scattered to the output tensor , Parameters shape Represents the shape of the output tensor .
Function USES
1、 One dimensional tensor 
>>> indices = tf.constant([[1], [3], [5], [7]])
>>> updates = tf.constant([2, 3, 4, 5])
>>> shape = tf.constant([8])
>>> tf.scatter_nd(indices, updates, shape)
<tf.Tensor: shape=(8,), dtype=int32, numpy=array([0, 2, 0, 3, 0, 4, 0, 5])>
2、 Two dimensional tensor
>>> indices = tf.constant([[1], [2]])
>>> updates = tf.constant([[1, 2], [3, 4]])
>>> updates
<tf.Tensor: shape=(2, 2), dtype=int32, numpy=
array([[1, 2],
[3, 4]])>
>>> shape = tf.constant([4, 2])
>>> tf.scatter_nd(indices, updates, shape)
<tf.Tensor: shape=(4, 2), dtype=int32, numpy=
array([[0, 0],
[1, 2],
[3, 4],
[0, 0]])>
3、 Three dimensional tensor 
>>> indices = tf.constant([[0], [2]])
>>> updates = tf.constant([[[5, 5, 5, 5], [6, 6, 6, 6],
[7, 7, 7, 7], [8, 8, 8, 8]],
[[5, 5, 5, 5], [6, 6, 6, 6],
[7, 7, 7, 7], [8, 8, 8, 8]]])
>>> updates
<tf.Tensor: shape=(2, 4, 4), dtype=int32, numpy=
array([[[5, 5, 5, 5],
[6, 6, 6, 6],
[7, 7, 7, 7],
[8, 8, 8, 8]],
[[5, 5, 5, 5],
[6, 6, 6, 6],
[7, 7, 7, 7],
[8, 8, 8, 8]]])>
>>> shape = tf.constant([4, 4, 4])
>>> tf.scatter_nd(indices, updates, shape)
<tf.Tensor: shape=(4, 4, 4), dtype=int32, numpy=
array([[[5, 5, 5, 5],
[6, 6, 6, 6],
[7, 7, 7, 7],
[8, 8, 8, 8]],
[[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]],
[[5, 5, 5, 5],
[6, 6, 6, 6],
[7, 7, 7, 7],
[8, 8, 8, 8]],
[[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]]])>
边栏推荐
- 安装snownlp包过程出现Requirement already satisfied:及Read timed out.问题解决方法
- xavier_normal_ 初始化测试
- Getting started with redis
- [learning notes] what happens when the URL is input into the page presentation?
- Special effects - click with the mouse and the fireworks will burst
- STM32 MP3 music player based on FatFs r0.14b & SD card (also a simple application of FatFs)
- [learning notes] Web page rendering process
- Redis基本类型-哈希Hash
- MySQL gets the self incrementing line mark (different from MySQL version)
- [lvgl (2)]
猜你喜欢

MySQL gets the self incrementing line mark (different from MySQL version)

【C语言】操作符详解(深入理解+整理归类)
![(note sorting is not completed) [graph theory: find the shortest path of single source]](/img/58/e61aea3c4d0a33d3615144763160f7.png)
(note sorting is not completed) [graph theory: find the shortest path of single source]

(笔记整理未完成)【图论:求单源最短路径】

Detailed analysis of the process (life cycle) of class loading

An AI plays 41 games, and the comprehensive performance score of Google's latest multi game decision transformer is twice that of dqn

tensorflow scatter_nd函数

Neural network superparameter adjustment (based on ray package)

MGR_ mysqlsh_ Keepalive high availability architecture deployment document

GE口:SGMII模式和serdes模式
随机推荐
Redis basic type - hash
Redis special data type Geo
安装snownlp包过程出现Requirement already satisfied:及Read timed out.问题解决方法
OWASP TOP10 penetration test
Can you increase muscle without exercise??? Just get an injection of hibernating black bear serum
[lvgl (2)]
MapReduce(一)
owasp top10 渗透测试
Sealos 打包部署 KubeSphere 容器平台
别太在意别人的眼光,那会抹杀你的光彩
Introduction to pyqt5 - student management system
MGR_ mysqlsh_ Keepalive high availability architecture deployment document
Three level classification / menu query tree structure
济南人社已签1W+电子劳动合同,法大大助力HR数字化
Redis基本类型-结合Set
反射
2022-07-22 mysql/stonedb并行hashJoin内存占用分析
[lvgl layout] grid layout
[lvgl (4)] event and event bubble of the object
永远不要迷失自我!