Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Keras · Class

layers.Multiply

Keras Multiply performs elementwise multiplication on a list of same-shaped tensors and returns one tensor with that shape. It is useful for combining parallel branches or applying tensor-valued gates.

How it works

Multiply receives a list of tensors and combines them by multiplying corresponding elements. The result keeps the same shape as the inputs, so each input must have matching dimensions.

Syntax

keras.layers.Multiply(**kwargs)

Returns

A single tensor with the same shape as the input tensors.

Key points

  • Multiplies corresponding elements across the supplied tensors.
  • Produces one output tensor whose shape matches the inputs.
  • The class is constructed with the standard Keras layer keyword arguments.
  • Apply the layer by passing the input tensors as a list.
  • The class-based form has a functional helper equivalent.

Common mistakes

  • Pass a list whose tensors have identical shapes.

Example: Elementwise multiplication

import numpy as np
import keras

x1 = np.array([[1., 2., 3.]])
x2 = np.array([[4., 5., 6.]])
y = keras.layers.Multiply()([x1, x2])
print(y)  # [[ 4. 10. 18.]]

Creates a Multiply layer and applies it to two same-shaped arrays.

When to use it

Branch fusion

Combine parallel neural-network branches by multiplying their corresponding activations.

Feature gating

Apply a learned or computed tensor as an elementwise gate to another tensor.

Functional model composition

Build Functional API graphs where multiple symbolic outputs must be combined multiplicatively.

Interview questions

QWhat does the Keras Multiply layer do?

Multiply performs elementwise multiplication over a list of tensors and returns one tensor. The inputs must all have the same shape, and the output preserves that shape.

Follow-up: How could you use it in a Functional model? Pass multiple symbolic tensors as a list to keras.layers.Multiply(), then connect the returned tensor to subsequent layers.

QWhat input does Multiply expect?

Its call input is a list rather than a single tensor. Each position in the list is multiplied element by element with the corresponding positions from the other tensors.

Follow-up: What shape constraint follows from this behavior? Every tensor supplied to the layer must have the same shape.

QHow is Multiply used in a Keras model?

Instantiate it with keras.layers.Multiply(**kwargs) and invoke it with tensors, for example keras.layers.Multiply()([x1, x2]). The output is a single tensor with the inputs' shape.

Follow-up: What is the functional equivalent named in the documentation? The equivalent operation is keras.layers.multiply([x1, x2]).

  • keras.layers.multiply
  • keras.layers.Add
  • keras.layers.Average
  • keras.layers.Maximum
  • keras.layers.Minimum

Source: Multiply layer - Keras. Checked 2026-10-15.