utils
17 memberslucid.nn.utilslucid.nn.utils: utility functions for neural networks.
Classes
Functions
clip_grad_norm_→ TensorClip the global gradient norm of `parameters` in place.
clip_grad_value_→ NoneClamp every gradient element to $[-\text{clip\_value}, \text{clip\_value}]$ in place.
get_total_norm→ TensorCompute the global gradient $\ell_p$ norm without clipping.
parameters_to_vector→ TensorFlatten an iterable of parameters into a single 1-D `Tensor`.
vector_to_parameters→ NoneCopy a flat 1-D tensor back into the supplied parameters in place.
remove_weight_norm→ ModuleReverse `weight_norm` and restore a plain leaf parameter.
remove_spectral_norm→ ModuleReverse `spectral_norm` and restore a plain leaf parameter.
pack_padded_sequence→ PackedSequencePack a padded $(T, B, *)$ batch into a `PackedSequence`.
pack_sequence→ PackedSequenceOne-shot pack-from-list — equivalent to `pad_sequence` then `pack_padded_sequence`.
pad_packed_sequence→ TensorInverse of `pack_padded_sequence` — produce a padded tensor.
pad_sequence→ TensorStack a list of variable-length tensors into a padded batch.
copy_parameters_and_buffers→ NoneCopy all parameter / buffer values from `source` into `dest`.
fuse_conv_bn_eval→ ModuleFold a BatchNorm layer into the preceding Conv weights (inference-only).
fuse_conv_bn_weights→ (Tensor, Tensor)Low-level form of `fuse_conv_bn_eval` operating on raw tensors.
fuse_linear_bn_eval→ ModuleFold a BatchNorm1d into the preceding Linear weights (inference-only).
fuse_linear_bn_weights→ (Tensor, Tensor)Low-level form of `fuse_linear_bn_eval` operating on raw tensors.