Beispiel #1
0
    def __init__(self, args):
        super(ResNet18Image2IMU, self).__init__()
        assert args.sequence_length == 2, "ResNet18Image2IMU supports seq-len=2"
        assert args.input_length == 2, "input length not currect"
        assert args.output_length == 1, "output length not currect"

        self.class_weights = args.dataset.CLASS_WEIGHTS[torch.LongTensor(
            args.imus)]
        self.output_length = args.output_length
        self.lr = args.lrm
        self.step_size = args.step_size
        self.decay = args.weight_decay

        resnet_model = torchvision_resnet18(pretrained=args.pretrain)
        # Remove the last fully connected layer.
        del resnet_model.fc
        self.resnet = resnet_model

        num_features = 512
        num_frames = 2
        num_classes = args.num_classes
        # Make num_imu fc layers
        self.imus = args.imus
        for i in self.imus:
            setattr(self, 'imu{}'.format(i),
                    nn.Linear(num_frames * num_features, num_classes))
        self.dropout = nn.Dropout(p=args.dropout_ratio)
    def __init__(self, args):
        super(ResNet18Image2IMUOneTowerPrediction, self).__init__()

        self.class_weights = args.dataset.CLASS_WEIGHTS[torch.LongTensor(
            args.imus)]

        resnet_model = torchvision_resnet18(pretrained=args.pretrain)
        # Remove the last fully connected layer.
        del resnet_model.fc
        self.resnet = resnet_model

        num_features = 512
        num_frames = args.input_length
        self.args = args

        self.resnet.conv1 = nn.Conv2d(num_frames * 3,
                                      64,
                                      kernel_size=(7, 7),
                                      stride=(2, 2),
                                      padding=(3, 3),
                                      bias=False)

        num_classes = args.num_classes
        # Make num_imu fc layers
        self.imus = args.imus
        for i in self.imus:
            setattr(self, 'imu{}'.format(i),
                    nn.Linear(num_features, num_classes))
        self.dropout = nn.Dropout()
    def __init__(self, args):
        super(FullyConvolutional, self).__init__()

        self.class_weights = args.dataset.CLASS_WEIGHTS

        self.args = args
        self.lr = args.lrm
        self.decay = args.weight_decay
        self.step_size = args.step_size

        resnet_model = torchvision_resnet18(pretrained=args.pretrain)
        # Remove the last fully connected layer.
        del resnet_model.fc
        self.resnet = resnet_model

        num_features = 512
        num_frames = 2

        self.imus = args.imus
        self.relu = nn.ReLU()
        self.dropout = nn.Dropout(p=args.dropout_ratio)
        self.conv4 = conv(512, 256, stride=2, transposed=True, kernel_size=3)
        self.bn4 = nn.BatchNorm2d(256)
        self.conv3 = conv(256, 128, stride=2, transposed=True, kernel_size=3)
        self.bn3 = nn.BatchNorm2d(128)
        self.conv2 = conv(128, 64, stride=2, transposed=True, kernel_size=3)
        self.bn2 = nn.BatchNorm2d(64)
        self.conv1 = conv(64, 1, kernel_size=3)
    def __init__(self, args):
        super(ResNetSceneCategorization, self).__init__()

        self.class_weights = args.dataset.CLASS_WEIGHTS

        self.args = args
        self.dropout = nn.Dropout()

        resnet_model = torchvision_resnet18(pretrained=args.pretrain)
        # Remove the last fully connected layer.
        del resnet_model.fc

        self.resnet = resnet_model
        self.fc = nn.Linear(512, 397)
    def __init__(self, args):
        super(FeatureLearnerModule, self).__init__()
        self.base_lr = args.base_lr
        self.lrm = args.lrm
        self.read_features = args.read_features
        self.number_of_trained_resnet_blocks = args.number_of_trained_resnet_blocks
        resnet_model = torchvision_resnet18(pretrained=args.pretrain)
        del resnet_model.fc
        self.resnet = resnet_model
        self.detach_level = args.detach_level

        self.fixed_feature_weights = args.fixed_feature_weights
        self.intermediate_features = None

        imagenet_feature_testing = args.pretrain and self.fixed_feature_weights and 'imagenet' in args.title and self.detach_level == 0
        imagenet_feature_training = args.pretrain and 'imagenet_train_all_the_way' in args.title

        assert imagenet_feature_testing or (
            not args.pretrain) or imagenet_feature_training
Beispiel #6
0
    def __init__(self, args):
        super(ResNet18Image2IMURegress, self).__init__()
        assert args.sequence_length == 1, "ResNet18Image2IMURegress supports seq-len=1"
        assert args.regression, "--regression must be true"

        self.class_weights = args.dataset.CLASS_WEIGHTS[torch.LongTensor(
            args.imus)]

        resnet_model = torchvision_resnet18(pretrained=args.pretrain)
        # Remove the last fully connected layer.
        del resnet_model.fc
        self.resnet = resnet_model

        num_features = 512
        num_frames = 2
        num_output = 4
        # Make num_imu fc layers
        self.imus = args.imus
        for i in self.imus:
            setattr(self, 'imu{}'.format(i),
                    nn.Linear(num_frames * num_features, num_output))