回答編集履歴
1
d
answer
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
numpy 同様、演算 * は要素ごとの積になるので、行列積 (matrix multiplication) を計算したい場合は `tf.matmul` をお使いください。
|
1
|
+
numpy 同様、演算 * は要素ごとの積になるので、行列積 (matrix multiplication) を計算したい場合は `tf.matmul` または `@` 演算子をお使いください。
|
2
2
|
|
3
3
|
形状が (3,) と (1, 5) のテンソル同士では行列積が計算できないので、tf.reshape で (3, 1) に変更した上で計算を行います。
|
4
4
|
|
@@ -10,6 +10,7 @@
|
|
10
10
|
x = tf.Variable(tf.ones(3))
|
11
11
|
W = tf.Variable(tf.ones((1, 5)))
|
12
12
|
y = tf.matmul(tf.reshape(x, (3, 1)), W)
|
13
|
+
# y = tf.reshape(x, (3, 1)) @ W でもよい。
|
13
14
|
|
14
15
|
with tf.Session() as sess:
|
15
16
|
sess.run(tf.global_variables_initializer())
|