Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Principle:LaurentMazare Tch rs Pretrained Model Instantiation

From Leeroopedia


Knowledge Sources
Domains Computer_Vision, Model_Architecture
Last Updated 2026-02-08 14:00 GMT

Overview

Pattern for instantiating a predefined vision model architecture by registering its parameters into a VarStore with a specified number of output classes.

Description

Pretrained model instantiation creates the full computational graph of a known architecture (ResNet, VGG, EfficientNet, etc.) and registers all learnable parameters in a VarStore. The model is constructed with randomly initialized weights, which are then overwritten by loading pretrained weights via VarStore::load. The constructor takes a VarStore path for parameter namespacing and a class count (typically 1000 for ImageNet). The returned model implements ModuleT for training-aware forward passes.

Usage

Use this when performing image classification with a known architecture. After instantiation, load pretrained weights to enable inference or use as a starting point for fine-tuning.

Theoretical Basis

ResNet-18 architecture:

Input [3, 224, 224]
  -> conv1 (7x7, stride 2) -> bn1 -> relu -> maxpool (3x3, stride 2)
  -> layer1 (2 BasicBlocks, 64 channels)
  -> layer2 (2 BasicBlocks, 128 channels, stride 2)
  -> layer3 (2 BasicBlocks, 256 channels, stride 2)
  -> layer4 (2 BasicBlocks, 512 channels, stride 2)
  -> adaptive_avg_pool2d -> flatten -> fc (512 -> num_classes)
Output [num_classes]

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment