Skip to content

SurgeryPlan

Source code

A surgery plan for shrinking a layer, removing shrink_rate amount of the units in layer.

Reducing the units in a layer will also reduce the number units in all connected weights and bias. The index of removal is random and shared across all weights and biases.

Parameters:

Name Type Description Default
layer str

The layer name to shrink. e.g.(hidden, phonology, cleanup in PMSP).

required
original_units int

The original number of units in the layer.

required
shrink_rate float

The shrink rate, between 0 and 1.

required
make_model_fn Callable

A function that make the original and new model.

required

__post_init__()

Validate plan and random sample the indices of unit to keep.