Replicate

Description

Info

Parent class: Module

Derived classes: -

This module replicates the output of the previous layer and is used to branch the neural network when it is built using Sequential.

Initializing

def __init__(self, times, name=None):

Parameters

Parameter Allowed types Description Default
name str Layer name None
times int How many times to copy the output of the previous layer – 

Explanations

-

Examples

Necessary imports.

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

Info

gpuarray is required to properly place the tensor in the GPU

np.random.seed(123)
batchsize, maps, h, w = 1, 1, 5, 5
data = gpuarray.to_gpu(np.random.randint(0, 9, (batchsize, maps, h, w)).astype(np.float32))
print(data)
[[[[2. 2. 6. 1. 3.]
   [6. 1. 0. 1. 0.]
   [0. 3. 4. 0. 0.]
   [4. 1. 7. 3. 2.]
   [4. 7. 2. 4. 8.]]]]
repl = Replicate(times=3)
print(repl(data))
[[[[2. 2. 6. 1. 3.]
   [6. 1. 0. 1. 0.]
   [0. 3. 4. 0. 0.]
   [4. 1. 7. 3. 2.]
   [4. 7. 2. 4. 8.]]]],
[[[[2. 2. 6. 1. 3.]
   [6. 1. 0. 1. 0.]
   [0. 3. 4. 0. 0.]
   [4. 1. 7. 3. 2.]
   [4. 7. 2. 4. 8.]]]],
[[[[2. 2. 6. 1. 3.]
   [6. 1. 0. 1. 0.]
   [0. 3. 4. 0. 0.]
   [4. 1. 7. 3. 2.]
   [4. 7. 2. 4. 8.]]]]