utils
21 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_norm→ TensorClip the global gradient norm of parameters in place.
clip_grad_value_→ NoneClamp every gradient element to in place.
get_total_norm→ TensorCompute the norm of tensors, taken jointly.
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.
weight_norm→ ModuleReparametrise a weight as direction times magnitude (Salimans & Kingma 2016).
remove_spectral_norm→ ModuleReverse spectral_norm and restore a plain leaf parameter.
spectral_norm→ ModuleConstrain a weight's spectral norm via power iteration (Miyato et al. 2018).
pack_padded_sequence→ PackedSequencePack a padded 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.
skip_init→ ModuleConstruct a module while skipping its parameter initialisation.