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;有各种前端、后端、算法、大数据、人工智能等课程。
版权申明:欢迎转载,但请注明出处
一些博文中有一些参考内容因时间久远找不到来源了没有注明,如果侵权请联系我删除。
AI交流资料群:753014672