### New to Peltarion? Discover our deep learning Platform

A single deep learning platform to build and deploy your projects, even if you’re not an AI superstar.

# Scaling

The Scaling block represents a simple multiplication of each input by the same user-defined scalar value.

## Usage

Use, e.g., when scaling the residual branch of residual connections as in the ResNet snippet.

If your model includes a Scaling block and you want to download an .h5-model, you can use the additional code below. You need to do this since the .h5-format comes from Keras, and Keras doesn’t support the Scaling block, so some extra code is needed.

import tensorflow as tf

class Scaling(tf.keras.layers.Layer):

def __init__(self, scale: float, offset: float, **kwargs):
super().__init__(**kwargs)
self._scale = scale
self._offset = offset

def call(self, inputs):
return inputs * self._scale + self._offset

def get_config(self):
config = super().get_config()
config['scale'] = self._scale
config['offset'] = self._offset
return config

model = tf.keras.models.load_model('my_model.h5', custom_objects={'Scaling': Scaling})

## Parameters

Factor: The real number used to multiply each input.
Default: 1.