回答編集履歴
1
edit
test
CHANGED
@@ -23,3 +23,47 @@
|
|
23
23
|
それともtf.multiplyがお探しの関数ですか?
|
24
24
|
|
25
25
|
https://www.tensorflow.org/versions/r0.12/api_docs/python/math_ops/arithmetic_operators#multiply
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
---
|
30
|
+
|
31
|
+
```python
|
32
|
+
|
33
|
+
import tensorflow as tf
|
34
|
+
|
35
|
+
import numpy as np
|
36
|
+
|
37
|
+
with tf.Session() as sess:
|
38
|
+
|
39
|
+
x = tf.Variable([1, 2, 3])
|
40
|
+
|
41
|
+
y = tf.Variable([[[1, 2, 3], [4, 5, 6]]])
|
42
|
+
|
43
|
+
sess.run(tf.global_variables_initializer())
|
44
|
+
|
45
|
+
print('x.shape\n', x.shape)
|
46
|
+
|
47
|
+
print('y.shape\n', y.shape)
|
48
|
+
|
49
|
+
print('x*y\n', sess.run(tf.multiply(x, y)))
|
50
|
+
|
51
|
+
'''
|
52
|
+
|
53
|
+
x.shape
|
54
|
+
|
55
|
+
(3,)
|
56
|
+
|
57
|
+
y.shape
|
58
|
+
|
59
|
+
(1, 2, 3)
|
60
|
+
|
61
|
+
x*y
|
62
|
+
|
63
|
+
[[[ 1 4 9]
|
64
|
+
|
65
|
+
[ 4 10 18]]]
|
66
|
+
|
67
|
+
'''
|
68
|
+
|
69
|
+
```
|