""" kwargs['width_per_group'] = 64 * 2 return _resnet('wide_resnet50_2', Bottleneck, [3, 4, 6, 3], pretrained, progress, **kwargs) def wide_resnet101_2(pretrained: bool = False, progress: bool = True, **kwargs: Any) -> ResNet: r"""Wide ResNet-101-2 model from `"Wide Residual Networks" <https://arxiv.org/pdf/1605.07146.pdf>`_. The model is the same as ResNet except for the bottleneck number of channels which is twice larger in every block. The number of channels in outer 1x1 convolutions is the same, e.g. last block in ResNet-50 has 2048-512-2048 channels, and in Wide ResNet-50-2 has 2048-1024-2048. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet progress (bool): If True, displays a progress bar of the download to stderr """ kwargs['width_per_group'] = 64 * 2 return _resnet('wide_resnet101_2', Bottleneck, [3, 4, 23, 3], pretrained, progress, **kwargs) input = torch.randn(64, 3, 224, 224) model = resnet18() ff_torch_model = PyTorchModel(model) ff_torch_model.torch_to_file("resnet.ff")
self.linear1 = nn.Linear(512, 512) self.linear2 = nn.Linear(512, 10) self.relu = nn.ReLU() def forward(self, input1, input2): y1 = self.conv1(input1) y1 = self.relu(y1) y2 = self.conv1(input2) y2 = self.relu(y2) y = torch.cat((y1, y2), 1) (y1, y2) = torch.split(y, 1) y = torch.cat((y1, y2), 1) y = self.conv2(y) y = self.relu(y) y = self.pool1(y) y = self.conv3(y) y = self.relu(y) y = self.conv4(y) y = self.relu(y) y = self.pool2(y) y = self.flat1(y) y = self.linear1(y) y = self.relu(y) yo = self.linear2(y) return (yo, y) model = CNN() ff_torch_model = PyTorchModel(model) ff_torch_model.torch_to_file("cnn.ff")
import torch.nn as nn import torchvision.models as models from flexflow.torch.model import PyTorchModel # model = models.alexnet() # model = models.vgg16() # model = models.squeezenet1_0() # model = models.densenet161() # model = models.inception_v3() model = models.googlenet() # model = models.shufflenet_v2_x1_0() # model = models.mobilenet_v2() ff_torch_model = PyTorchModel(model) ff_torch_model.torch_to_file("googlenet.ff")
import torch.nn as nn from flexflow.torch.model import PyTorchModel class MLP(nn.Module): def __init__(self): super().__init__() self.linear1 = nn.Linear(784, 512) self.linear2 = nn.Linear(512, 512) self.linear3 = nn.Linear(512, 10) self.relu = nn.ReLU() self.softmax = nn.Softmax() def forward(self, x): y = self.linear1(x) y = self.relu(y) y = self.linear2(y) y = self.relu(y) y = self.linear3(y) y = self.softmax(y) return y model = MLP() ff_torch_model = PyTorchModel(model) ff_torch_model.torch_to_file("mlp.ff")
import classy_vision.models.regnet as rgn from flexflow.torch.model import PyTorchModel import torch.nn as nn model = rgn.RegNetX32gf() model = nn.Sequential(model, nn.Flatten(), nn.Linear(2520 * 7 * 7, 1000)) ff_torch_model = PyTorchModel(model) ff_torch_model.torch_to_file("regnetX32gf.ff")