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

二、内容在总结中

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

 
我的旨在学过的东西不再忘记(主要使用艾宾浩斯遗忘曲线算法及其它智能学习复习算法)的偏公益性质的完全免费的编程视频学习网站: fanrenyi.com;有各种前端、后端、算法、大数据、人工智能等课程。
博主25岁,前端后端算法大数据人工智能都有兴趣。
大家有啥都可以加博主联系方式(qq404006308,微信fan404006308)互相交流。工作、生活、心境,可以互相启迪。
聊技术,交朋友,修心境,qq404006308,微信fan404006308
26岁,真心找女朋友,非诚勿扰,微信fan404006308,qq404006308
人工智能群:939687837

作者相关推荐

原文地址:https://www.cnblogs.com/Renyi-Fan/p/13417535.html