回答編集履歴
2
例にバージョン出力を追加
test
CHANGED
@@ -48,11 +48,15 @@
|
|
48
48
|
|
49
49
|
import tensorflow as tf
|
50
50
|
|
51
|
+
print(tf.__version__)
|
52
|
+
|
51
53
|
a = tf.constant([1, 2, 3, 4], shape=[2, 2])
|
52
54
|
|
53
55
|
b = tf.constant([5, 6, 7, 8], shape=[2, 2])
|
54
56
|
|
57
|
+
#mu = tf.mul(a, b) # AttributeError: module 'tensorflow' has no attribute 'mul'
|
58
|
+
|
55
|
-
mt = tf.multiply(a, b) # 要素毎
|
59
|
+
mt = tf.multiply(a, b) # 要素毎に乗算
|
56
60
|
|
57
61
|
mm = tf.matmul(a, b) # 行列の乗算
|
58
62
|
|
@@ -72,6 +76,8 @@
|
|
72
76
|
|
73
77
|
```
|
74
78
|
|
79
|
+
1.0.0
|
80
|
+
|
75
81
|
[[1 2]
|
76
82
|
|
77
83
|
[3 4]]
|
1
例を追加
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
`tf.mul`の代替は`tf.matmul`ではなく`tf.multiply`ではないでしょうか?
|
1
|
+
要素毎の乗算`tf.mul`の代替は行列の乗算`tf.matmul`ではなく`tf.multiply`ではないでしょうか?
|
2
2
|
|
3
3
|
|
4
4
|
|
@@ -39,3 +39,53 @@
|
|
39
39
|
Returns:
|
40
40
|
|
41
41
|
A Tensor. Has the same type as x.
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
例
|
46
|
+
|
47
|
+
```Python
|
48
|
+
|
49
|
+
import tensorflow as tf
|
50
|
+
|
51
|
+
a = tf.constant([1, 2, 3, 4], shape=[2, 2])
|
52
|
+
|
53
|
+
b = tf.constant([5, 6, 7, 8], shape=[2, 2])
|
54
|
+
|
55
|
+
mt = tf.multiply(a, b) # 要素毎の乗算
|
56
|
+
|
57
|
+
mm = tf.matmul(a, b) # 行列の乗算
|
58
|
+
|
59
|
+
with tf.Session() as sess:
|
60
|
+
|
61
|
+
print(a.eval())
|
62
|
+
|
63
|
+
print(b.eval())
|
64
|
+
|
65
|
+
print(mt.eval())
|
66
|
+
|
67
|
+
print(mm.eval())
|
68
|
+
|
69
|
+
```
|
70
|
+
|
71
|
+
結果
|
72
|
+
|
73
|
+
```
|
74
|
+
|
75
|
+
[[1 2]
|
76
|
+
|
77
|
+
[3 4]]
|
78
|
+
|
79
|
+
[[5 6]
|
80
|
+
|
81
|
+
[7 8]]
|
82
|
+
|
83
|
+
[[ 5 12]
|
84
|
+
|
85
|
+
[21 32]]
|
86
|
+
|
87
|
+
[[19 22]
|
88
|
+
|
89
|
+
[43 50]]
|
90
|
+
|
91
|
+
```
|