> 文章列表 > broadcast自动扩展/合并与分割/基本运算

broadcast自动扩展/合并与分割/基本运算

broadcast自动扩展/合并与分割/基本运算

文章目录

  • 一、broadcast
    • Key idea
    • match from last dim
  • 二、合并
    • cat
    • stack
  • 三、拆分
    • split:
  • 四、基本运算
    • matmul
    • An example
    • matmul
    • power
    • exp log
    • approximation
    • clamp
  • 五、统计属性
  • 总结

一、broadcast

Key idea

▪ Insert 1 dim ahead
▪ Expand dims with size 1 to same size
▪ Feature maps: [4, 32, 14, 14]
▪ Bias: [32, 1, 1] => [1, 32, 1, 1] => [4, 32, 14, 14]
broadcast自动扩展/合并与分割/基本运算Situation 1:
▪ [4, 32, 14, 14]
▪ [1, 32, 1, 1] => [4, 32, 14, 14]
Situation 2
▪ [4, 32, 14, 14]
▪ [14, 14] => [1, 1, 14, 14] => [4, 32, 14, 14]
Situation 3
▪ [4, 32, 14, 14]
▪ [2, 32, 14, 14]
▪ Dim 0 has dim, can NOT insert and expand to same
▪ Dim 0 has distinct dim, NOT size 1
▪ NOT broadcasting-able

match from last dim

When it has no dim
▪ treat it as all own the same
▪ [class, student, scores] + [scores]
▪ When it has dim of size 1
▪ Treat it shared by all
▪ [class, student, scores] + [student, 1]

It’s effective and critically, intuitive
▪ [4, 3, 32, 32]
▪ + [32, 32]
▪ + [3, 1, 1]
▪ + [1, 1, 1, 1]

二、合并

cat

broadcast自动扩展/合并与分割/基本运算

broadcast自动扩展/合并与分割/基本运算

stack

create new dim
broadcast自动扩展/合并与分割/基本运算

三、拆分

split:

broadcast自动扩展/合并与分割/基本运算 ## chunk
broadcast自动扩展/合并与分割/基本运算

四、基本运算

broadcast自动扩展/合并与分割/基本运算

matmul

broadcast自动扩展/合并与分割/基本运算

An example

broadcast自动扩展/合并与分割/基本运算

matmul

broadcast自动扩展/合并与分割/基本运算

power

broadcast自动扩展/合并与分割/基本运算

exp log

broadcast自动扩展/合并与分割/基本运算

approximation

floor() ceil() round() trunc() ,frac()

broadcast自动扩展/合并与分割/基本运算

clamp

broadcast自动扩展/合并与分割/基本运算

五、统计属性

broadcast自动扩展/合并与分割/基本运算
broadcast自动扩展/合并与分割/基本运算

总结