矩陣形式的范數(shù)歸一設(shè)計(jì)到矩陣除法
舉個(gè)簡(jiǎn)單的例子:
假設(shè)一個(gè)數(shù)據(jù)矩陣規(guī)模為(4贰镣,3,2)诅蝶,可以理解為4個(gè)樣本,每個(gè)樣本是一個(gè)時(shí)間長(zhǎng)度為3的點(diǎn)同眯,點(diǎn)是(x, y)形式的二維空間的樣本。
> A = np.random.random((4,3,2))
array([[[0.89239403, 0.12214923],
[0.51232698, 0.15274605],
[0.60971146, 0.07217262]],
[[0.19267784, 0.11648302],
[0.09225679, 0.95131037],
[0.25777361, 0.23847847]],
[[0.77162583, 0.05490807],
[0.61026345, 0.1172357 ],
[0.9613178 , 0.56668329]],
[[0.8195157 , 0.44777402],
[0.77027723, 0.90067652],
[0.48683648, 0.80049979]]])
記對(duì)每個(gè)(x, y)點(diǎn)求范數(shù)后的矩陣為陶舞,即相應(yīng)規(guī)模為(4,3,1)
> B = np.random.random((4,3,1))
array([[[0.79237377],
[0.17657666],
[0.06914004]],
[[0.76301106],
[0.4939386 ],
[0.64676006]],
[[0.73634844],
[0.78604091],
[0.14897835]],
[[0.2775787 ],
[0.69762266],
[0.42144431]]])
的結(jié)果則為(x, y)的點(diǎn)除以相應(yīng)范數(shù)的結(jié)果嗽测。
> a/b
array([[[1.12622865, 0.15415608],
[2.90144227, 0.86504101],
[8.8185003 , 1.04386148]],
[[0.25252299, 0.1526623 ],
[0.18677785, 1.92596887],
[0.39856143, 0.36872789]],
[[1.04790856, 0.07456805],
[0.77637619, 0.14914707],
[6.45273499, 3.80379628]],
[[2.95237238, 1.61314255],
[1.10414594, 1.29106545],
[1.15516206, 1.89942009]]])
驗(yàn)證
> 0.89239403/0.79237377
1.1262286357611258
> 0.19267784/0.76301106
0.2525229975041253
> 0.12214923/0.79237377
0.15415607460100553