그림에서처럼 행렬 내적은 왼쪽 행렬의 행(가로)과 오른쪽 행렬의 열(세로 방향)을 원소별로
곱하고 그 값들을 더해서 계산합니다. 그리고 그 계산 결과가 새로운 다차원 배열의 원소가 됩
니다. 예를 들어
A
의
1
행과
B
의
1
열을 곱한 값은 결과 행렬의
1
행
1
번째 원소가 되고,
A
의
2
행과
B
의
1
열을 곱한 결과는
2
행
1
번째 원소가 됩니다. 참고로 이 책에서는 ‘수식에서의 행
렬’을 굵은 글씨로 표기합니다. 예를 들어 행렬은
A
처럼 표기하여 원소가 하나인 스칼라값(예
컨대
a
와
b
)이나 파이썬 코드에서의 변수명과 구별합니다. 이 계산을 파이썬으로 구현하면 다
음과 같습니다.
>>>
A
=
np
.
array
([[
1
,
2
],
[
3
,
4
]])
>>>
A
.
shape
(
2
,
2
)
>>>
B
=
np
.
array
([[
5
,
6
],
[
7
,
8
]])
>>>
B
.
shape
(
2
,
2
)
>>>
np
.
dot
(
A
,
B
)
array
([[
19
,
22
],
[
43
,
50
]])
이 코드에서
A
와
B
는
2
×
2
행렬이며,
*
이들 두 행렬의 내적은 넘파이 함수
np
.
dot
()으로 계
*
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.