Overview
TheBaseModel class provides a common interface for all model implementations in the UC Intel Final platform. It defines the core methods that every model must implement and provides utility methods for model inspection.
Class Definition
app/models/base.py:11
Constructor
__init__(config: Dict[str, Any])
Initialize model with configuration dictionary.
Model configuration dictionary containing model-specific parameters. At minimum, should include:
num_classes: Number of output classesmodel_type: Type of model (e.g., “CNN”, “Transfer”, “Transformer”)architecture: Architecture name or description
Abstract Methods
These methods must be implemented by all subclasses.build() -> nn.Module
Build and return the PyTorch model.
PyTorch neural network module ready for training or inference
get_parameters_count() -> Tuple[int, int]
Get total and trainable parameter counts.
Total number of parameters in the model
Number of trainable parameters (where
requires_grad=True)Instance Methods
get_model_summary() -> Dict[str, Any]
Get comprehensive model summary statistics.
Dictionary containing:
total_parameters: Total parameter counttrainable_parameters: Trainable parameter countmodel_type: Model type from configarchitecture: Architecture name from confignum_classes: Number of output classes
validate_config() -> bool
Validate model configuration before building.
Returns
True if configuration is valid, False otherwisenum_classesmust be present in confignum_classesmust be greater than 0
Attributes
Model configuration dictionary passed during initialization
Built PyTorch model instance. Initially
None until build() is calledImplementation Guide
When creating a new model class, inherit fromBaseModel and implement the required abstract methods:
See Also
- CNNBuilder - Custom CNN implementation
- Transfer Learning - Pre-trained model fine-tuning
- Transformers - Vision Transformer implementation