{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 「要素ごとの積 (element-wise product)」とは" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "> 数学におけるアダマール積(英: Hadamard product)は、同じサイズの行列に対して成分ごとに積を取ることによって定まる行列の積である。要素ごとの積(英: element-wise product)、シューア積(英: Schur product)、点ごとの積(英: pointwise product)、成分ごとの積(英: entrywise product)などとも呼ばれる。\n", "> [アダマール積 - Wikipedia](https://ja.wikipedia.org/wiki/%E3%82%A2%E3%83%80%E3%83%9E%E3%83%BC%E3%83%AB%E7%A9%8D)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 🤔「行列の積」っていろいろあるの? \n", "💡いろいろあります! [行列の乗法 - Wikipedia](https://ja.wikipedia.org/wiki/%E8%A1%8C%E5%88%97%E3%81%AE%E4%B9%97%E6%B3%95)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 🤔3DCGで使用されている、行列の積はなに?\n", "\n", "💡行列の内積 (行列をベクトルと扱うときの、内積)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy\n", "\n", "# 現在地の座標を (x, y) = (0, 0) とする\n", "pos = numpy.array([0.0, 0.0, 0.0, 1.0])\n", "\n", "# そこから、x = 2, y = 3 に移動する\n", "movePos = numpy.array([[1.0, 0.0, 0.0, 0.0],[0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [2.0, 3.0, 0.0, 1.0]])" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[0., 0., 0., 0.],\n", " [0., 0., 0., 0.],\n", " [0., 0., 0., 0.],\n", " [0., 0., 0., 1.]])" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# 要素ごとの積\n", "pos * movePos" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([2., 3., 0., 1.])" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# 行列の内積\n", "numpy.dot(pos, movePos)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 🤔NumPyではなぜ、「要素ごとの積」を乗算の標準としたのか" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "TODO: きっとNumPyの仕様書か、ディスカッションでも見ないと見つからない疑問" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.8.3 32-bit ('ManteraStudio-ReadingCircle-DeepLearningFromScratch': pipenv)", "language": "python", "name": "python38332bitmanterastudioreadingcircledeeplearningfromscratchpipenv21a57b96d5f0461d91c6487fcb569097" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.3" } }, "nbformat": 4, "nbformat_minor": 4 }