peal.adaptors.clarc.split_model¶
- peal.adaptors.clarc.split_model(model, split_at, device)[source]¶
Split a model into
Sequentialfeature extractor and downstream head.- Parameters:
model (
torch.nn.Module) – Model whose (recursively flattened) children are split.split_at (
int) – Index into the flattened child list; children before it form the feature extractor, the rest the head.device – Device both parts are moved to.
- Returns:
(feature_extractor, downstream_head). For torchvisionResNetaFlattenis inserted before the finalfclayer since the flattening is not a child module.- Return type:
(torch.nn.Module,torch.nn.Module)