def get_conv_output(self, x): # Layer 2: Convolutional + Batch Norm conv2_out = self.conv2(x) bn2_out = self.bn2(conv2_out) # Layer 3: Convolutional + 2x2 Max Pooling + Batch Norm conv3_out = self.conv3(bn2_out) pool3_out = F.max_pool2d(conv3_out, 2) bn3_out = HF.modified_bn(self.bn3, pool3_out) # Layer 4: Convolutional + Batch Norm conv4_out = self.conv4(bn3_out) bn4_out = HF.modified_bn(self.bn4, conv4_out) # Build dictionary containing outputs of each layer conv_out = { self.CONV2: conv2_out, self.BN2: bn2_out, self.CONV3: conv3_out, self.POOL3: pool3_out, self.BN3: bn3_out, self.CONV4: conv4_out, self.BN4: bn4_out, } return conv_out
def get_conv_output(self, x): # Layer 5: Convolutional + 2x2 Max Pooling + Batch Norm conv5_out = self.conv5(x) pool5_out = F.max_pool2d(conv5_out, 2) bn5_out = self.bn5(pool5_out) # Layer 6: Convolutional + Batch Norm conv6_out = self.conv6(bn5_out) bn6_out = self.bn6(conv6_out) # Layer 7: Convolutional + 2x2 Max Pooling + Batch Norm conv7_out = self.conv7(bn6_out) pool7_out = F.max_pool2d(conv7_out, 2) bn7_out = HF.modified_bn(self.bn7, pool7_out) # Layer 8: Convolutional + Batch Norm conv8_out = self.conv8(bn7_out) bn8_out = HF.modified_bn(self.bn8, conv8_out) # Build dictionary containing outputs of each layer conv_out = { self.CONV5: conv5_out, self.POOL5: pool5_out, self.BN5: bn5_out, self.CONV6: conv6_out, self.BN6: bn6_out, self.CONV7: conv7_out, self.POOL7: pool7_out, self.BN7: bn7_out, self.CONV8: conv8_out, self.BN8: bn8_out, } return conv_out
def get_conv_output(self, x): # Layer 4: Convolutional + Batch Norm conv4_out = self.conv4(x) bn4_out = HF.modified_bn(self.bn4, conv4_out) # Build dictionary containing outputs of each layer conv_out = { self.CONV4: conv4_out, self.BN4: bn4_out, } return conv_out
def get_conv_output(self, x): # Layer 8: Convolutional + Batch Norm conv8_out = self.conv8(x) bn8_out = HF.modified_bn(self.bn8, conv8_out) # Build dictionary containing outputs of each layer conv_out = { self.CONV8: conv8_out, self.BN8: bn8_out, } return conv_out
def forward(self, x): # Compute the output feature map from the convolutional layers out = self.get_conv_output(x) # Layer 9: FC + Batch Norm fc9_out = self.fc9(out[self.CONV_OUTPUT]) bn9_out = HF.modified_bn(self.bn9, fc9_out) # Linear FC layer, outputs are the class scores fc10_out = self.fc10(bn9_out).view(-1, self.NUM_CLASSES) # Build dictionary containing outputs from convolutional and FC layers out[self.FC9] = fc9_out out[self.BN9] = bn9_out out[self.FC10] = fc10_out return out
def forward(self, x): out = {} # Hidden Layer: FC + Batch Norm fc1_out = self.fc1(x if len(self.get_input_shape()) >= 3 else x. view(x.size(0), x.size(1), 1, 1)) bn1_out = HF.modified_bn(self.bn1, fc1_out) # Output Layer, outputs are the class scores fc2_out = self.fc2(bn1_out).view(-1, self.NUM_CLASSES) # Build dictionary containing outputs from convolutional and FC layers out[self.FC1] = fc1_out out[self.BN1] = bn1_out out[self.FC2] = fc2_out return out
def forward(self, x): # Compute the output feature map from the convolutional layers out = self.get_conv_output(x) # Layer 5: FC + Batch Norm fc5_out = self.fc5(out[self.CONV_OUTPUT]) bn5_out = HF.modified_bn(self.bn5, fc5_out) # Linear FC layer, outputs are the class scores fc6_out = self.fc6(bn5_out).view(-1, self.NUM_CLASSES) # Build dictionary containing outputs from convolutional and FC layers out[self.FC5] = fc5_out out[self.BN5] = bn5_out out[self.FC6] = fc6_out out[self.CLASS_SCORES] = {P.KEY_CLASS_SCORES: fc6_out} return out
def get_conv_output(self, x): # Layer 1: Convolutional + 3x3 Max Pooling + Batch Norm conv1_out = self.conv1(x) pool1_out = F.max_pool2d(conv1_out, 3) bn1_out = self.bn1(pool1_out) # Layer 2: Convolutional + Batch Norm conv2_out = self.conv2(bn1_out) bn2_out = self.bn2(conv2_out) # Layer 3: Convolutional + 2x2 Max Pooling + Batch Norm conv3_out = self.conv3(bn2_out) pool3_out = F.max_pool2d(conv3_out, 2) bn3_out = self.bn3(pool3_out) # Layer 4: Convolutional + Batch Norm conv4_out = self.conv4(bn3_out) bn4_out = self.bn4(conv4_out) # Layer 5: Convolutional + 2x2 Max Pooling + Batch Norm conv5_out = self.conv5(bn4_out) pool5_out = F.max_pool2d(conv5_out, 2) bn5_out = self.bn5(pool5_out) # Layer 6: Convolutional + Batch Norm conv6_out = self.conv6(bn5_out) bn6_out = self.bn6(conv6_out) # Layer 7: Convolutional + 2x2 Max Pooling + Batch Norm conv7_out = self.conv7(bn6_out) pool7_out = F.max_pool2d(conv7_out, 2) bn7_out = HF.modified_bn(self.bn7, pool7_out) # Layer 8: Convolutional + Batch Norm conv8_out = self.conv8(bn7_out) bn8_out = HF.modified_bn(self.bn8, conv8_out) # Build dictionary containing outputs of each layer conv_out = { self.CONV1: conv1_out, self.POOL1: pool1_out, self.BN1: bn1_out, self.CONV2: conv2_out, self.BN2: bn2_out, self.CONV3: conv3_out, self.POOL3: pool3_out, self.BN3: bn3_out, self.CONV4: conv4_out, self.BN4: bn4_out, self.CONV5: conv5_out, self.POOL5: pool5_out, self.BN5: bn5_out, self.CONV6: conv6_out, self.BN6: bn6_out, self.CONV7: conv7_out, self.POOL7: pool7_out, self.BN7: bn7_out, self.CONV8: conv8_out, self.BN8: bn8_out, } return conv_out