Skip to content

Mul

Description

Info

Parent class: Module

Derived classes: -

This module performs the elementwise multiplication of tensors.

Initializing

def __init__(self, name=None):

Parameters

Parameter Allowed types Description Default
name str Layer name None

Explanations

-

Examples

Necessary imports.

import numpy as np
from PuzzleLib.Backend import gpuarray
from PuzzleLib.Modules import Mul

Info

gpuarray is required to properly place the tensor in the GPU

maps, h, w = 1, 2, 2
data1 = gpuarray.to_gpu(np.arange(maps * h * w).reshape((maps, h, w)).astype(np.float32))
data2 = gpuarray.to_gpu(np.arange(maps * h * w).reshape((maps, h, w)).astype(np.float32))
print(data1)
[[[0. 1.]
  [2. 3.]]]
mul = Mul()
print(mul([data1, data2]))
[[[0. 1.]
  [4. 9.]]]