微信扫一扫打赏支持

TensorFlow2_200729系列---7、广播

TensorFlow2_200729系列---7、广播

一、总结

一句话总结:

a、手动或自动扩充维度进行运行,numpy也有类似的功能
b、比如x=tf.random.normal([4,32,32,3]); (x+tf.random.normal([3])).shape; TensorShape([4,32,32,3])

 

 

1、Why broadcasting?

1、for real demanding
2、memory consumption



▪ 1. for real demanding
▪ [classes, students, scores]
▪ Add bias for every student: +5 score
▪ [4, 32, 8] + [4, 32, 8] ▪ [4, 32, 8] + [5.0]

▪ 2. memory consumption
▪ [4, 32, 8] → 1024
▪ bias=[8]: [5.0,5.0,5.0,…] → 8

 

2、Broadcastable(怎样才能广播)?

最后的维度要一样:Match from Last dim!


▪ Match from Last dim!
▪ If current dim=1, expand to same
▪ If either has no dim, insert one dim and expand to same
▪ otherwise, NOT broadcastable

 

 

 

二、内容在总结中

博客对应课程的视频位置:

 

 

 
posted @ 2020-08-02 02:41  范仁义  阅读(96)  评论(1编辑  收藏  举报