|
|
|
@ -10407,13 +10407,14 @@ Examples:
|
|
|
|
|
x = fluid.data(name="x", shape=[3], dtype='float32')
|
|
|
|
|
y = fluid.data(name="y", shape=[3], dtype='float32')
|
|
|
|
|
z = fluid.layers.elementwise_add(x, y)
|
|
|
|
|
# z = x + y
|
|
|
|
|
|
|
|
|
|
place = fluid.CPUPlace()
|
|
|
|
|
exe = fluid.Executor(place)
|
|
|
|
|
z_value = exe.run(feed=gen_data(),
|
|
|
|
|
fetch_list=[z.name])
|
|
|
|
|
|
|
|
|
|
print(z_value) #[3., 8., 6.]
|
|
|
|
|
print(z_value) # [3., 8., 6.]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
@ -10430,6 +10431,7 @@ Examples:
|
|
|
|
|
x = fluid.data(name="x", shape=[2,3,4,5], dtype='float32')
|
|
|
|
|
y = fluid.data(name="y", shape=[3,4], dtype='float32')
|
|
|
|
|
z = fluid.layers.elementwise_add(x, y, axis=1)
|
|
|
|
|
# z = x + y
|
|
|
|
|
|
|
|
|
|
place = fluid.CPUPlace()
|
|
|
|
|
exe = fluid.Executor(place)
|
|
|
|
@ -10454,6 +10456,7 @@ Examples:
|
|
|
|
|
x = fluid.data(name="x", shape=[2,3,4,5], dtype='float32')
|
|
|
|
|
y = fluid.data(name="y", shape=[5], dtype='float32')
|
|
|
|
|
z = fluid.layers.elementwise_add(x, y, axis=3)
|
|
|
|
|
# z = x + y
|
|
|
|
|
|
|
|
|
|
place = fluid.CPUPlace()
|
|
|
|
|
exe = fluid.Executor(place)
|
|
|
|
@ -10488,13 +10491,14 @@ Examples:
|
|
|
|
|
x = fluid.data(name="x", shape=[3], dtype='float32')
|
|
|
|
|
y = fluid.data(name="y", shape=[3], dtype='float32')
|
|
|
|
|
z = fluid.layers.elementwise_div(x, y)
|
|
|
|
|
# z = x / y
|
|
|
|
|
|
|
|
|
|
place = fluid.CPUPlace()
|
|
|
|
|
exe = fluid.Executor(place)
|
|
|
|
|
z_value = exe.run(feed=gen_data(),
|
|
|
|
|
fetch_list=[z.name])
|
|
|
|
|
|
|
|
|
|
print(z_value) #[2., 0.6, 2.]
|
|
|
|
|
print(z_value) # [2., 0.6, 2.]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
@ -10511,6 +10515,7 @@ Examples:
|
|
|
|
|
x = fluid.data(name="x", shape=[2,3,4,5], dtype='float32')
|
|
|
|
|
y = fluid.data(name="y", shape=[3,4], dtype='float32')
|
|
|
|
|
z = fluid.layers.elementwise_div(x, y, axis=1)
|
|
|
|
|
# z = x / y
|
|
|
|
|
|
|
|
|
|
place = fluid.CPUPlace()
|
|
|
|
|
exe = fluid.Executor(place)
|
|
|
|
@ -10535,6 +10540,7 @@ Examples:
|
|
|
|
|
x = fluid.data(name="x", shape=[2,3,4,5], dtype='float32')
|
|
|
|
|
y = fluid.data(name="y", shape=[5], dtype='float32')
|
|
|
|
|
z = fluid.layers.elementwise_div(x, y, axis=3)
|
|
|
|
|
# z = x / y
|
|
|
|
|
|
|
|
|
|
place = fluid.CPUPlace()
|
|
|
|
|
exe = fluid.Executor(place)
|
|
|
|
@ -10569,13 +10575,14 @@ Examples:
|
|
|
|
|
x = fluid.data(name="x", shape=[3], dtype='float32')
|
|
|
|
|
y = fluid.data(name="y", shape=[3], dtype='float32')
|
|
|
|
|
z = fluid.layers.elementwise_sub(x, y)
|
|
|
|
|
# z = x - y
|
|
|
|
|
|
|
|
|
|
place = fluid.CPUPlace()
|
|
|
|
|
exe = fluid.Executor(place)
|
|
|
|
|
z_value = exe.run(feed=gen_data(),
|
|
|
|
|
fetch_list=[z.name])
|
|
|
|
|
|
|
|
|
|
print(z_value) #[1., -2., 2.]
|
|
|
|
|
print(z_value) # [1., -2., 2.]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
@ -10592,6 +10599,7 @@ Examples:
|
|
|
|
|
x = fluid.data(name="x", shape=[2,3,4,5], dtype='float32')
|
|
|
|
|
y = fluid.data(name="y", shape=[3,4], dtype='float32')
|
|
|
|
|
z = fluid.layers.elementwise_sub(x, y, axis=1)
|
|
|
|
|
# z = x - y
|
|
|
|
|
|
|
|
|
|
place = fluid.CPUPlace()
|
|
|
|
|
exe = fluid.Executor(place)
|
|
|
|
@ -10616,6 +10624,7 @@ Examples:
|
|
|
|
|
x = fluid.data(name="x", shape=[2,3,4,5], dtype='float32')
|
|
|
|
|
y = fluid.data(name="y", shape=[5], dtype='float32')
|
|
|
|
|
z = fluid.layers.elementwise_sub(x, y, axis=3)
|
|
|
|
|
# z = x - y
|
|
|
|
|
|
|
|
|
|
place = fluid.CPUPlace()
|
|
|
|
|
exe = fluid.Executor(place)
|
|
|
|
@ -10650,13 +10659,14 @@ Examples:
|
|
|
|
|
x = fluid.data(name="x", shape=[3], dtype='float32')
|
|
|
|
|
y = fluid.data(name="y", shape=[3], dtype='float32')
|
|
|
|
|
z = fluid.layers.elementwise_mul(x, y)
|
|
|
|
|
# z = x * y
|
|
|
|
|
|
|
|
|
|
place = fluid.CPUPlace()
|
|
|
|
|
exe = fluid.Executor(place)
|
|
|
|
|
z_value = exe.run(feed=gen_data(),
|
|
|
|
|
fetch_list=[z.name])
|
|
|
|
|
|
|
|
|
|
print(z_value) #[2., 15., 8.]
|
|
|
|
|
print(z_value) # [2., 15., 8.]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
@ -10673,6 +10683,7 @@ Examples:
|
|
|
|
|
x = fluid.data(name="x", shape=[2,3,4,5], dtype='float32')
|
|
|
|
|
y = fluid.data(name="y", shape=[3,4], dtype='float32')
|
|
|
|
|
z = fluid.layers.elementwise_mul(x, y, axis=1)
|
|
|
|
|
# z = x * y
|
|
|
|
|
|
|
|
|
|
place = fluid.CPUPlace()
|
|
|
|
|
exe = fluid.Executor(place)
|
|
|
|
@ -10697,6 +10708,7 @@ Examples:
|
|
|
|
|
x = fluid.data(name="x", shape=[2,3,4,5], dtype='float32')
|
|
|
|
|
y = fluid.data(name="y", shape=[5], dtype='float32')
|
|
|
|
|
z = fluid.layers.elementwise_mul(x, y, axis=3)
|
|
|
|
|
# z = x * y
|
|
|
|
|
|
|
|
|
|
place = fluid.CPUPlace()
|
|
|
|
|
exe = fluid.Executor(place)
|
|
|
|
|