FrancescoSaverioZuppichini / glasses

High-quality Neural Networks for Computer Vision 😎
https://francescosaveriozuppichini.github.io/glasses-webapp/
MIT License
431 stars 37 forks source link

Resnet #4

Closed FrancescoSaverioZuppichini closed 3 years ago

FrancescoSaverioZuppichini commented 4 years ago

Implement ResNet in a scalable way

TODO

francescocicala commented 4 years ago

In nn.resnet we could subclass ResNetBottleNeckBlock and ResNetBasicBlock from a parent class by overwriting self.block, since they differ only for that attribute.

FrancescoSaverioZuppichini commented 4 years ago

Probably the best thing is to have a class ResidualBlock

class ResidualAddBlock(nn.Module):
    def __init__()
        super().__init__()
        self.block = None
        self.shortcut = None

    def forward(self, x: Tensor) -> Tensor:
        res = x
        if self.shortcut is not None:
            res = self.shortcut(res)
        x = self.block(x)
        x += res
        return x
class ResNetBasicBlock(ResidualAddBlock):
   def __init__(...):
      self.block = // weights here
      self.shortcut = ResNetShortcut if self.shold_apply_shortcut ....
      self.act = // relu
   def forward(self, x):
       x = super()(x)
       return self.act(x)

class ResNetBottleNeckBlock(ResNetBasicBlock):
   def __init__(...):
      self.block = // bottleneck weights here
FrancescoSaverioZuppichini commented 4 years ago

We need to write a test for ResNet, I think a good lazy idea can be just passing input to the model. If we have an output it means that at least the weights features are correct. What do you think?

FrancescoSaverioZuppichini commented 4 years ago

Add parameter shortcut to ResNetBasicBlock

FrancescoSaverioZuppichini commented 4 years ago

Done!

FrancescoSaverioZuppichini commented 4 years ago

Add wide resnet from "Wide Residual Networks" and resnetxt "Aggregated Residual Transformation for Deep Neural Networks

FrancescoSaverioZuppichini commented 3 years ago

Add Bag of Tricks for Image Classification with Convolutional Neural Networks