Models / resnet-50

ResNet-50

The 50-layer residual network (v1.5) for ImageNet-1k: a 7x7 stem, four stages of bottleneck blocks 3, 4, 6, and 3 deep, and a linear classifier.

25.6M parametersresnetApache-2.0image-classificationvisionconvolutional

The forward entry with one level of blocks expanded. Every edge carries the tensor type the compiler inferred at that point, in the model's own generics.

ResNet-50: forwardResNet-50: forward

Entries ​

EntrySignature
forwardforward<B: Dim>(image: Tensor[B, 3, Height, Width; T]) -> Tensor[B, Classes; T]

Generics ​

The root block's generics as this checkpoint binds them.

Height224
Width224
Classes1000
Tf32

Blocks ​

Every block of the program with its members and functions, as linnet inspect prints them.

Bottleneck ​

text
resnet::Bottleneck<C: Dim, T: Float>
  sub reduce: ConvNorm<C, C / 4, 1, 1, 0, T>
  sub conv: ConvNorm<C / 4, C / 4, 3, 1, 1, T>
  sub expand: ConvNorm<C / 4, C, 1, 1, 0, T>
  pub fn forward<B: Dim, H: Dim, W: Dim>(x: Tensor[B, C, H, W; T]) -> Tensor[B, C, H, W; T]

Conv1d ​

text
std.nn.conv::Conv1d<Cin: Dim, Cout: Dim, K: Dim, Stride: Dim, Pad: Dim, T: Float = f32>
  param weight: Tensor[Cout, Cin, K; T]
  param bias: Tensor[Cout; T]?
  pub fn forward<B: Dim, L: Dim>(x: Tensor[B, Cin, L; T]) -> Tensor[B, Cout, 1 + (-1 * K + L + 2 * Pad) / Stride; T]

Conv2d ​

text
std.nn.conv::Conv2d<Cin: Dim, Cout: Dim, K: Dim, Stride: Dim, Pad: Dim, T: Float = f32>
  param weight: Tensor[Cout, Cin, K, K; T]
  param bias: Tensor[Cout; T]?
  pub fn forward<B: Dim, H: Dim, W: Dim>(x: Tensor[B, Cin, H, W; T]) -> Tensor[B, Cout, 1 + (-1 * K + H + 2 * Pad) / Stride, 1 + (-1 * K + W + 2 * Pad) / Stride; T]

Conv2dRect ​

text
std.nn.conv::Conv2dRect<Cin: Dim, Cout: Dim, KH: Dim, KW: Dim, StrideH: Dim, StrideW: Dim, PadH: Dim, PadW: Dim, T: Float = f32>
  param weight: Tensor[Cout, Cin, KH, KW; T]
  param bias: Tensor[Cout; T]?
  pub fn forward<B: Dim, H: Dim, W: Dim>(x: Tensor[B, Cin, H, W; T]) -> Tensor[B, Cout, 1 + (-1 * KH + H + 2 * PadH) / StrideH, 1 + (-1 * KW + W + 2 * PadW) / StrideW; T]

ConvNorm ​

text
resnet::ConvNorm<Cin: Dim, Cout: Dim, K: Dim, Stride: Dim, Pad: Dim, T: Float>
  sub convolution: Conv2d<Cin, Cout, K, Stride, Pad, T>
  param running_mean: Tensor[Cout; T]
  param running_var: Tensor[Cout; T]
  param weight: Tensor[Cout; T]
  param bias: Tensor[Cout; T]
  pub fn forward<B: Dim, H: Dim, W: Dim>(x: Tensor[B, Cin, H, W; T]) -> Tensor[B, Cout, 1 + (-1 * K + 2 * Pad + H) / Stride, 1 + (-1 * K + 2 * Pad + W) / Stride; T]

DownBottleneck ​

text
resnet::DownBottleneck<Cin: Dim, Cout: Dim, Stride: Dim, T: Float>
  sub reduce: ConvNorm<Cin, Cout / 4, 1, 1, 0, T>
  sub conv: ConvNorm<Cout / 4, Cout / 4, 3, Stride, 1, T>
  sub expand: ConvNorm<Cout / 4, Cout, 1, 1, 0, T>
  sub shortcut: ConvNorm<Cin, Cout, 1, Stride, 0, T>
  pub fn forward<B: Dim, H: Dim, W: Dim>(x: Tensor[B, Cin, H, W; T]) -> Tensor[B, Cout, 1 + (-1 + H) / Stride, 1 + (-1 + W) / Stride; T]

Linear ​

text
std.nn.linear::Linear<In: Dim, Out: Dim, T: Float = bf16>
  param weight: Tensor[Out, In; T]
  param bias: Tensor[Out; T]?
  pub fn forward<*S: Shape>(x: Tensor[*S, In; T]) -> Tensor[*S, Out; T]

Model ​

text
resnet::Model<Height: Dim, Width: Dim, Classes: Dim, T: Float = f32>
  sub stem: ConvNorm<3, 64, 7, 2, 3, T>
  sub stage_0: Stage<64, 256, 1, 3, T>
  sub stage_1: Stage<256, 512, 2, 4, T>
  sub stage_2: Stage<512, 1024, 2, 6, T>
  sub stage_3: Stage<1024, 2048, 2, 3, T>
  sub classifier: Linear<2048, Classes, T>
  pub entry forward<B: Dim>(image: Tensor[B, 3, Height, Width; T]) -> Tensor[B, Classes; T]

RmsNorm ​

text
std.nn.norm::RmsNorm<H: Dim, T: Float = bf16>
  param weight: Tensor[H; T]
  pub fn forward<*S: Shape>(x: Tensor[*S, H; T]) -> Tensor[*S, H; T]

Stage ​

text
resnet::Stage<Cin: Dim, Cout: Dim, Stride: Dim, Depth: Dim, T: Float>
  sub down: DownBottleneck<Cin, Cout, Stride, T>
  sub rest: [Bottleneck<Cout, T>; -1 + Depth]
  pub fn forward<B: Dim, H: Dim, W: Dim>(x: Tensor[B, Cin, H, W; T]) -> Tensor[B, Cout, 1 + (-1 + H) / Stride, 1 + (-1 + W) / Stride; T]