clip

Implement a clip module as pytorch only has a simple clamp function.

Classes

Clip

Clip tensor.

class Clip

Bases: Module

Clip tensor.

Parameters:
  • clip_value_min – A number or tensor of lower bound to clip

  • clip_value_max – A number of tensor of upper bound to clip

  • learn_min – A boolean. If True, learn min. clip_value_min will be used to initialize. Default False

  • learn_max – A boolean. Similar as learn_min but for max.

Raises:

ValueError

__init__(clip_value_min, clip_value_max, learn_min=False, learn_max=False)

Initialize.

forward(inputs)

Clip input tensor.