tf.keras.layers.Multiply
Stay organized with collections
Save and categorize content based on your preferences.
Layer that multiplies (element-wise) a list of inputs.
Inherits From: Layer
, Module
tf.keras.layers.Multiply(
**kwargs
)
It takes as input a list of tensors, all of the same shape, and returns
a single tensor (also of the same shape).
tf.keras.layers.Multiply()([np.arange(5).reshape(5, 1),
np.arange(5, 10).reshape(5, 1)])
<tf.Tensor: shape=(5, 1), dtype=int64, numpy=
array([[ 0],
[ 6],
[14],
[24],
[36]])>
x1 = tf.keras.layers.Dense(8)(np.arange(10).reshape(5, 2))
x2 = tf.keras.layers.Dense(8)(np.arange(10, 20).reshape(5, 2))
multiplied = tf.keras.layers.Multiply()([x1, x2])
multiplied.shape
TensorShape([5, 8])
Args |
**kwargs
|
standard layer keyword arguments.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-01-23 UTC.
[null,null,["Last updated 2024-01-23 UTC."],[],[],null,["# tf.keras.layers.Multiply\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/keras-team/keras/tree/v2.15.0/keras/layers/merging/multiply.py#L24-L51) |\n\nLayer that multiplies (element-wise) a list of inputs.\n\nInherits From: [`Layer`](../../../tf/keras/layers/Layer), [`Module`](../../../tf/Module) \n\n tf.keras.layers.Multiply(\n **kwargs\n )\n\nIt takes as input a list of tensors, all of the same shape, and returns\na single tensor (also of the same shape). \n\n tf.keras.layers.Multiply()([np.arange(5).reshape(5, 1),\n np.arange(5, 10).reshape(5, 1)])\n \u003ctf.Tensor: shape=(5, 1), dtype=int64, numpy=\n array([[ 0],\n [ 6],\n [14],\n [24],\n [36]])\u003e\n\n x1 = tf.keras.layers.Dense(8)(np.arange(10).reshape(5, 2))\n x2 = tf.keras.layers.Dense(8)(np.arange(10, 20).reshape(5, 2))\n multiplied = tf.keras.layers.Multiply()([x1, x2])\n multiplied.shape\n TensorShape([5, 8])\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|------------|-----------------------------------|\n| `**kwargs` | standard layer keyword arguments. |\n\n\u003cbr /\u003e"]]