def forward(self, input, label): network = torch.cat([input, label], dim=1) network = self.gc_full(network) network = ReLU(inplace=True)(network) network = network.view(-1, 512, 1, 1) network = ReLU()(self.bn2(self.dconv1(network))) network = ReLU()(self.bn3(self.dconv2(network))) network = ReLU()(self.bn4(self.dconv3(network))) network = Sigmoid()(self.dconv4(network)) return network
def forward(self, inputs): """Return the output of a forward pass of the ToyNetwork :param inputs: batch of input images, of shape (batch_size, n_channels, height, width) :type inputs: torch.Tensor :return: outputs of a ToyNetwork model, of shape (batch_size, n_classes) :rtype: torch.Tensor """ layer = self.conv(inputs) layer = ReLU()(layer) layer = layer.view(layer.size(0), -1) outputs = self.linear(layer) return outputs
def forward(self, inputs): """Return the output of a forward pass of AlexNet :param inputs: batch of input images, of shape (batch_size, height, width, n_channels) :type inputs: torch.Tensor :return: outputs of an AlexNet model, of shape (batch_size, n_classes) :rtype: torch.Tensor """ # === convolutional block 1 === # layer = self.conv1(inputs) layer = ReLU()(layer) layer = MaxPool2d(kernel_size=(3, 3), stride=(2, 2))(layer) # === convolutional block 2 === # layer = self.conv2(layer) layer = ReLU()(layer) layer = MaxPool2d(kernel_size=(3, 3), stride=(2, 2))(layer) # === convolutional blocks 3, 4, 5 === # layer = self.conv3(layer) layer = ReLU()(layer) layer = self.conv4(layer) layer = ReLU()(layer) layer = self.conv5(layer) layer = ReLU()(layer) layer = MaxPool2d(kernel_size=(3, 3), stride=(2, 2))(layer) # === dense layers (2) === # layer = layer.view(layer.size(0), -1) layer = self.linear1(layer) layer = ReLU()(layer) layer = Dropout(0.5)(layer) layer = self.linear2(layer) layer = ReLU()(layer) layer = Dropout(0.5)(layer) # === output layer === # outputs = self.linear3(layer) return outputs
def forward(self, inputs): """Return the outputs from a forward pass of the network :param inputs: batch of input images, of shape (BATCH_SIZE, n_channels, height, width) :type inputs: torch.Tensor :return: outputs of SimpleCNN, of shape (BATCH_SIZE, NUM_CLASSES) :rtype: torch.Tensor """ layer = self.conv1(inputs) layer = ReLU()(layer) layer = self.conv2(layer) layer = ReLU()(layer) layer = MaxPool2d(kernel_size=(2, 2))(layer) layer = Dropout(0.25)(layer) layer = layer.view(layer.size(0), -1) layer = self.linear1(layer) layer = Dropout(0.5)(layer) outputs = self.linear2(layer) return outputs