pulsatrix 1.1.0
Loading...
Searching...
No Matches
vision_models.hpp File Reference

torchvision's ResNet and VGG, built from pulsatrix layers with torchvision's parameter names, so their published ImageNet weights load once converted to safetensors (KS-9). More...

#include <cstdint>
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include "pulsatrix/adaptive_avg_pool2d_module.hpp"
#include "pulsatrix/batch_norm_fold.hpp"
#include "pulsatrix/batch_norm_module.hpp"
#include "pulsatrix/conv2d_module.hpp"
#include "pulsatrix/dropout_module.hpp"
#include "pulsatrix/flatten_module.hpp"
#include "pulsatrix/linear_module.hpp"
#include "pulsatrix/max_pool2d_module.hpp"
#include "pulsatrix/module.hpp"
#include "pulsatrix/relu_module.hpp"
#include "pulsatrix/residual_module.hpp"
#include "pulsatrix/sequential_module.hpp"
Include dependency graph for vision_models.hpp:

Go to the source code of this file.

Classes

struct  pulsatrix::ResNetConfig
 A torchvision ResNet with basic blocks (ResNet18 and ResNet34; ResNet18 is the one tested on the published weights). More...
 
class  pulsatrix::TorchvisionResNet
 torchvision's ResNet(BasicBlock, ...): a 7x7 stride-2 convolution, BatchNorm, ReLU and 3x3 stride-2 max pooling; four stages of basic blocks (two 3x3 convolutions with BatchNorm, and a 1x1 convolution with BatchNorm on the shortcut where the shape changes); global average pooling and a linear classifier. Input (N, 3, H, W), output (N, classes). More...
 
struct  pulsatrix::VGGConfig
 A torchvision VGG without BatchNorm (VGG11 to VGG19; VGG16 is the one tested on the published weights). More...
 
class  pulsatrix::TorchvisionVGG
 torchvision's VGG: 3x3 convolutions with bias and ReLU, 2x2 max pooling, adaptive average pooling to (pool_size, pool_size), then Linear, ReLU, Dropout, Linear, ReLU, Dropout, Linear. Parameter names are torchvision's (features.0.weight, classifier.6.bias, ...). Every layer is top-level in layers(), so the first convolution can take ZBox in an EpsilonGammaBox composite. More...
 
struct  pulsatrix::TorchvisionLoadReport
 What LoadTorchvisionWeights() did. More...
 

Namespaces

namespace  pulsatrix
 

Functions

TorchvisionLoadReport pulsatrix::LoadTorchvisionWeights (Module &model, const std::string &safetensors_path)
 Loads a torchvision state dict converted to safetensors (tools/convert/pickle_to_safetensors.py) into model by name: every parameter and buffer of the model is looked up under the same name. Linear weights (every rank-2 parameter), stored (out, in) by PyTorch, are transposed; num_batches_tracked counters are ignored.
 

Detailed Description

torchvision's ResNet and VGG, built from pulsatrix layers with torchvision's parameter names, so their published ImageNet weights load once converted to safetensors (KS-9).