find_layers¶
- probly.traverse_nn.utils.find_layers(model: object, layer_types: type | tuple[type, ...]) list[Any][source]¶
Return all layers of the given type(s) contained in a model.
Walks
modelusing the neural-network traverser and collects every visited layer that is an instance oflayer_types, in forward DFS order. The check is a plainisinstance, so no per-backend handlers are needed; any backend supported bynn_traverser(currently torch and flax NNX) works out of the box. The walk does not mutate or deep-copy the model.- Parameters:
model – The model to search.
layer_types – A layer type or tuple of layer types to match.
- Returns:
All matching layers in traversal order; empty if none match.